Ticket #4517 - Units entry missing from .dxf file export.

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
electrotechie
Posts: 14
Joined: Sun Nov 15, 2020 10:54 am
Location: Glasgow, Scotland, sometimes France.

Ticket #4517 - Units entry missing from .dxf file export.

Post by electrotechie »

I managed to use V18 to export a .dxf file for laser cutting. The .dxf export for V19 is currently broken (a known problem) so I cannot check whether this problem exists in the latest version.

In terms of the shape of the drawing, the output seems correct. However the units of the coordinates is not output in the .dxf file
The consequence is that it is output in mm but when other systems receive it, the units default to inches. Luckily there is a big difference between 65mm and 65 inches so I spotted it.

The workaround is relatively trivial so it is really no big deal if you know what to do. The .dxf file is text. It is missing 3 lines which I edited in. The missing lines are:

Code: Select all

  9
$INSUNITS
 70
4
The format is fairly simple, it is a numeric identifier followed by information. So "9" means "name of variable", followed by the name, then that name implies another number, 70 means "integer" and the integer is 4 which is for "mm". See https://images.autodesk.com/adsk/files/ ... ce_enu.pdf for the details of the units - just look up $INSUNITS.
These line have to be inserted in the header section of the .dxf text file, so using a text editor look for something which looks like:

Code: Select all

  9
$EXTMIN
and insert the lines before that.
Obviously it would be good if this could be added directly by the export software but I am reticent about opening a bug report since it might already be in hand and I am a novice in Freecad. Meanwhile, if anyone else has the problem this workaround is fairly trivial. I verified that it worked using eDrawings free viewer see https://dl-ak.solidworks.com/nonsecure/ ... AllX64.exe
I hope that this is a useful contribution.

Regards, Ray, Electrotechie.
Linden
Posts: 109
Joined: Wed Aug 19, 2015 10:35 pm
Location: Canada/Philippines

Re: Units entry missing from .dxf file export.

Post by Linden »

Thank you I think this is an old problem I think. Your work around is much more elegant than mine. In Freecad 0.16 I had problems where Autodesck programs would not open the .dxf files exported from freecad. to get around this I would open them with libre Cad and then use the Save as function in libre cad to save them with a new name and then auto desk products could open them I didnt understand why but it just worked so I went with it.
Linden
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Units entry missing from .dxf file export.

Post by yorik »

Ok this should be simple to fix indeed... And it makes sense as FreeCAD basically always exports in mm, at least for now. I'll look at this ASAP. Would you mind opening a ticket on the tracker at https://tracker.freecadweb.org , attribute it to me and reference this forum thread, so I don't forget?
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Units entry missing from .dxf file export.

Post by ickby »

Please keep in mind that DXF does not support units in all versions of its specificstion. Last time I checked two years ago feeecad exported a version that does not support units. That means DXF export was perfectly fine, and the problem was always on importer side, which just assumed units without asking the user what units it is.

The DXF version is encoded in the file header. So if units are added please make also sure that the version is bumped to one supporting units.
Linden
Posts: 109
Joined: Wed Aug 19, 2015 10:35 pm
Location: Canada/Philippines

Re: Units entry missing from .dxf file export.

Post by Linden »

I have have opened a ticket as requested (tracker ID 0004517) and referenced this thread was not sure how to attribute to yorik.


yorik wrote: Fri Dec 18, 2020 12:14 pm Ok this should be simple to fix indeed... And it makes sense as FreeCAD basically always exports in mm, at least for now. I'll look at this ASAP. Would you mind opening a ticket on the tracker at https://tracker.freecadweb.org , attribute it to me and reference this forum thread, so I don't forget?
Linden
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #4517 - Units entry missing from .dxf file export.

Post by Kunda1 »

Linden wrote: Sun Dec 20, 2020 6:29 pm I have have opened a ticket as requested (tracker ID 0004517) and referenced this thread was not sure how to attribute to yorik.
Updated issue #4517 and assigned to yorik.
Thanks Linden
FYI, please don't bottom-quote. In the forum here we top quote, as I did with your response. Thanks!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
l3VGV
Posts: 47
Joined: Sat Oct 12, 2019 11:04 am

Re: Ticket #4517 - Units entry missing from .dxf file export.

Post by l3VGV »

Any progress on that?

Units is not exported in 0.19, i checked manualy, inside file, ther is no $INSUNITS.

OS: Windows 10 Version 2009
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: Russian/Russia (ru_RU)
Attachments
corner-Body001Sketch001.dxf
(5.54 KiB) Downloaded 27 times
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Ticket #4517 - Units entry missing from .dxf file export.

Post by yorik »

I have already adapted our dxfLibrary to be able to add global variables ( https://github.com/FreeCAD/FreeCAD/comm ... 984d60dedc ) but I haven't looked at adding $INSUNITS yet. Good reminder, I'll have a look at this
l3VGV
Posts: 47
Joined: Sat Oct 12, 2019 11:04 am

Re: Ticket #4517 - Units entry missing from .dxf file export.

Post by l3VGV »

yorik wrote: Wed Nov 24, 2021 1:46 pm I have already adapted our dxfLibrary to be able to add global variables ( https://github.com/FreeCAD/FreeCAD/comm ... 984d60dedc ) but I haven't looked at adding $INSUNITS yet. Good reminder, I'll have a look at this
Thank you!
Post Reply