mozman / ezdxf

Python interface to DXF
https://ezdxf.mozman.at
MIT License
937 stars 191 forks source link

XData #1079

Closed CheshireCC closed 6 months ago

CheshireCC commented 6 months ago

some times , add xdata to entity, dxf file can't be read by CAD, I tried R2000R2010R2018 format, don't work.

Error

The following error was encountered while reading POLYLINE (starting at line 4918):
Target ends early
Invalid or incomplete DXF input-drawing is discarded.

Code:

doc = ezdxf.new("R2000",setup=True)
doc.layers.new('JZD', dxfattribs={'color': 1})
msp = doc.modelspace()
points=[(0,0),(100,100),(200,300)]
pl_ = msp.add_polyline2d(points, dxfattribs={'layer': 'JZD',"default_start_width": 0.15, "default_end_width":0.15}, close=True)
pl_.set_xdata("SOUTH",[(1071,300000),(1000, "141121JC00005"),(1000, f"{pl.name}"),(1000,"0702")])
doc.saveas(r"./01.dxf")

And I also found that, change xdata code to:

pl_.set_xdata("EZDXF",[(1071,300000),(1000, "141121JC00005"),(1000, f"{pl.name}"),(1000,"0702")])

It'll work.

And if I replace "EZDXF" in 01.dxf with "SOUTH" by notepad++ , also work.

I don't know what happand, I did sth wrong?

gswifort commented 6 months ago

You need to add the application to the APPID table.

doc.appids.add("SOUTH")
CheshireCC commented 3 months ago

You need to add the application to the APPID table.

doc.appids.add("SOUTH")

Thx, that‘s right way