-
I am very new to DXF, so I probably missed something very basic :) I am trying to save to DXF from Inkscape, but the units are not included. So I am trying to fix that with ezdxf. #simple.py
import ezdxf, sys
from ezdxf import units
doc = ezdxf.readfile('frominkscape.dxf')
print('before $INSUNITS:',doc.header.get('$INSUNITS'))
print('before doc.units:',doc.units)
doc.units = units.CM # 5
doc.saveas('outp.dxf')
print('after $INSUNITS:',doc.header.get('$INSUNITS'))
print('after doc.units:',doc.units)
outpdoc = ezdxf.readfile('outp.dxf')
print('saved file: $INSUNITS:',outpdoc.header.get('$INSUNITS')) # None
print('saved file: doc.units:',outpdoc.units) # throws exception This will output:
Why is the header not saved? :) If I run the same code with a file that already has this header defined with some value, it will be saved with the new value of that header. Also, if I create a new doc with ezdxf.new(), I am able to save this header. Sample code for frominkscape.dxf: https://gist.github.com/velle/096c7e570d69bcb40eb4aa879fa2159f#file-frominkscape-dxf Using ezdxf 1.1.4. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Thank you for providing the example file. You can attach DXF files in a zip-archive. You really missed something but its not documented (not by Autodesk and not in the ezdxf documentation). |
Beta Was this translation helpful? Give feedback.
-
Thanks :) Is there any way of getting such feedback from the library? Nothing comes up if I set the $INSUNITS header and run validate(). Should it / could it show there, or is that for something entirely different? Or are there some warning messages that I can un-suppress, so they will give me such hints? |
Beta Was this translation helpful? Give feedback.
-
There are so many quirks and edge cases to document I could just do that for the next years ... |
Beta Was this translation helpful? Give feedback.
Thank you for providing the example file. You can attach DXF files in a zip-archive.
You really missed something but its not documented (not by Autodesk and not in the ezdxf documentation).
$INSUNITS
require DXF R2000 or later, your DXF file is DXF R12.