Search code examples
dxfautolisp

XDATA on a Programmatically Created DXF File


I have a small vb.net app that creates DXF files from scratch, containing polylines and some text objects. It is working as intented and does its job at the moment, making use of some "minimum dxf requirements" info I found online.

As an upgrade for the app, I have decided to add some xdata on the polylines and that's where I am having some trouble.

I have added the following lines inside the polyline definition in ENTITIES section:

1001
MYAPPID01
1002
{
1000
-Some string I want to associate with the polyline-
1002
}

And also created a table section for the appid as follows:

0
SECTION
2
TABLES
0
TABLE
2
APPID
2
MYAPPID01
70
0
0
ENDTAB
0
ENDSEC

I have also added an auto-load process in acaddoc lsp file to register the app:

(if (not (tblsearch "APPID" "MYAPPID01"))   
  (regapp "MYAPPID01")
)

My dxf files aren't loading and give the "Invalid application" error. What must I do to add this xdata with minimum addition to my normal dxf routine?

Any help about APPID's and their registrations would be great. Thank you all in advance.


Solution

  • What's missing is the max table count tag (70, count) after the table type definition tag (2, APPID), the following table entries start with a (0, APPID) tag. (Solution for DXF R12)

      0
    SECTION         <<< start table section
      0
    TABLE           <<< start table
      2             <<< group code 2 for
    APPID           <<< table type definition
     70
    10              <<< max table entry count
      0             <<< group code 0 for
    APPID           <<< 1. table entry
      2
    ACAD            <<< application name
     70
    0               <<< flags, 0 is good
      0
    APPID           <<< 2. table entry
      2
    MYAPPID01       <<< application name
     70
    0               <<< flags
    
    ... and so on
    
      0
    ENDTAB
      0
    ENDSEC
    

    You can find more information here (valid for DXF R13 and later):

    DXF Group Codes