Units of measure in dxf import
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
-
- Posts: 67
- Joined: Mon Nov 24, 2014 7:54 pm
Units of measure in dxf import
Is there a way to specify units of measure when importing a dxf file? I am attempting to import a flat file and it appears the person who created the file was using inches instead of millimeters, so his 4.25 inch wide scale drawing imports as 4.25 mm wide.
OS: Windows 8.1
Word size of OS: 64-bit
Word size of FreeCAD: 32-bit
Version: 0.15.4671 (Git)
Branch: releases/FreeCAD-0-15
Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
OS: Windows 8.1
Word size of OS: 64-bit
Word size of FreeCAD: 32-bit
Version: 0.15.4671 (Git)
Branch: releases/FreeCAD-0-15
Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Re: Units of measure in dxf import
Basically, I know it sounds incredible but it is, the DXF file itself doesn't contain a definition of the unit being used. There is a variable that says in which unit imported blocks are expected, which many application use to choose the unit. But this seems wrong to me, I used autocad for many years and never saw anybody set that variable correctly. There isa lso a setting that says if you want your dimensions in imperial or metric units. And that's all.
So there is no reliable way for FreeCAD to know the unit of the DXF file. I would suggest to simly open it in a DXF app such as librecad and rescale everything to yuor unit of choice... It will be faster than doing it in FreeCAD I think.
We would need a quick tool to rescale a whole document one day...
So there is no reliable way for FreeCAD to know the unit of the DXF file. I would suggest to simly open it in a DXF app such as librecad and rescale everything to yuor unit of choice... It will be faster than doing it in FreeCAD I think.
We would need a quick tool to rescale a whole document one day...
- blockitectvt
- Posts: 2
- Joined: Sun May 09, 2021 6:48 pm
- Location: Burlington VT USA
- Contact:
Re: Units of measure in dxf import
I didn't see this anywhere else, so I thought I would tack this on here - some notes on my recent experience trying to import DXF in inch units:
I made some 2D plans and elevations on Autocad 2016. When trying to import the files to Freecad, I could not get the ODA converter to work properly (some error about moving the dwg file to a path without spaces..), so I exported DXF files from Autocad. Before saving as DXF, I issued the -DWGUNITS command to be sure of the export units Autocad was generating. When I set the units to inches, I then used the 25.4 scale factor in the DXF import settings in Freecad. But when I imported the file, a door that should be 3 feet wide was 1,935'-6 1/2" wide. When I set the scale factor to 1, the same dxf file imported with that same door at 76'-2".
So then I tried to change the scale factor in Freecad to be the equivalent of 1/25.4 = 0.03937, but the best I could enter in the DXF import preferences was 0.0394 - only four decimal places. It was close to the correct scale, but this is not enough precision for reasonable architectural work - a few inches of error over 100 feet.
Back in Autocad I used the -DWGUNITS command again and converted the units from inches to Millimeters. Then I imported the dxf file into Freecad with the scale factor set to 1 and the import was perfect - a 3 foot door measured exactly 3 feet. A 76' length of wall measured 76 feet exactly.
So it seems to me that the scale factor guidance in the "mouseover" in the preferences may need to be reversed. And there needs to be a way to enter more decimal places for the scale factor. Perhaps there is a way to do this from the command line directly? It would be best to have it set up right in the GUI, but if anyone knows how to set this with more precision some other way, that would be helpful to know.
It's good to have some method to get things properly scaled, but it would be nice to be able to simply import from my large library of imperial unit drawings and have Freecad do the unit conversion without having to open 2d CAD and run a conversion. In a production environment, that's a huge chunk of time saved.
-israel smith
Smith Buckley Architects
www.sbavt.com
OS: Windows 10 Version 1909
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24276 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: a88db11e0a908f6e38f92bfc5187b13ebe470438
Python version: 3.8.6+
Qt version: 5.15.1
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/United States (en_US)
I made some 2D plans and elevations on Autocad 2016. When trying to import the files to Freecad, I could not get the ODA converter to work properly (some error about moving the dwg file to a path without spaces..), so I exported DXF files from Autocad. Before saving as DXF, I issued the -DWGUNITS command to be sure of the export units Autocad was generating. When I set the units to inches, I then used the 25.4 scale factor in the DXF import settings in Freecad. But when I imported the file, a door that should be 3 feet wide was 1,935'-6 1/2" wide. When I set the scale factor to 1, the same dxf file imported with that same door at 76'-2".
So then I tried to change the scale factor in Freecad to be the equivalent of 1/25.4 = 0.03937, but the best I could enter in the DXF import preferences was 0.0394 - only four decimal places. It was close to the correct scale, but this is not enough precision for reasonable architectural work - a few inches of error over 100 feet.
Back in Autocad I used the -DWGUNITS command again and converted the units from inches to Millimeters. Then I imported the dxf file into Freecad with the scale factor set to 1 and the import was perfect - a 3 foot door measured exactly 3 feet. A 76' length of wall measured 76 feet exactly.
So it seems to me that the scale factor guidance in the "mouseover" in the preferences may need to be reversed. And there needs to be a way to enter more decimal places for the scale factor. Perhaps there is a way to do this from the command line directly? It would be best to have it set up right in the GUI, but if anyone knows how to set this with more precision some other way, that would be helpful to know.
It's good to have some method to get things properly scaled, but it would be nice to be able to simply import from my large library of imperial unit drawings and have Freecad do the unit conversion without having to open 2d CAD and run a conversion. In a production environment, that's a huge chunk of time saved.
-israel smith
Smith Buckley Architects
www.sbavt.com
OS: Windows 10 Version 1909
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24276 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: a88db11e0a908f6e38f92bfc5187b13ebe470438
Python version: 3.8.6+
Qt version: 5.15.1
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/United States (en_US)
- blockitectvt
- Posts: 2
- Joined: Sun May 09, 2021 6:48 pm
- Location: Burlington VT USA
- Contact:
Re: Units of measure in dxf import
I found the answer to this in another post.
To set the scale factor to go from inches -->> MM the value is 1/25.4 = 0.03937
The difficulty is that the GUI preferences dialog doesn't have that many decimal places. So you have to open: Tools --> Edit Parameters, and then go to "base-app, preferences, Mod Draft, and set the "dxfScaling" parameter to 0.03937, then "save to disk"
After that the preferences dialog will show it rounded to 0.0394, but the precision will be there under the hood.
To set the scale factor to go from inches -->> MM the value is 1/25.4 = 0.03937
The difficulty is that the GUI preferences dialog doesn't have that many decimal places. So you have to open: Tools --> Edit Parameters, and then go to "base-app, preferences, Mod Draft, and set the "dxfScaling" parameter to 0.03937, then "save to disk"
After that the preferences dialog will show it rounded to 0.0394, but the precision will be there under the hood.
Re: Units of measure in dxf import
Harmonized no. of digits of dxfScaling between Edit->Preferences and Tools->Edit Parameters.
Tools->Edit Parameters:
Edit->Preferences:
PR: https://github.com/FreeCAD/FreeCAD/pull/4784
Tools->Edit Parameters:
Edit->Preferences:
PR: https://github.com/FreeCAD/FreeCAD/pull/4784
-
- Posts: 6
- Joined: Mon Jun 27, 2022 11:51 pm
Re: Units of measure in dxf import
Hi there,
First of all, I would thank you very much for your priceless work.
I have similar issue when importing dxf files with mm unit,
- So to detect the origin of this issue
I created a bunch of similar files using LibreCAD, all of them with just a unit rectangle [1×1] (as shown), but each one with a different unit.
and then I imported them to FreeCAD, I have noticed that (when importing mm.dxf file) what was : 1 mm in LibreCAD becomes now 1 inch = 25.4mm in FreeCAD
All the other files with the rest of units look like they are well projected.
I opened in.dxf and mm.dxf files in VSC to compare them, as shown below, honestly I'm not expert but I think that in LibreCAD exports the files correctly .
First of all, I would thank you very much for your priceless work.
I have similar issue when importing dxf files with mm unit,
- So to detect the origin of this issue
I created a bunch of similar files using LibreCAD, all of them with just a unit rectangle [1×1] (as shown), but each one with a different unit.
and then I imported them to FreeCAD, I have noticed that (when importing mm.dxf file) what was : 1 mm in LibreCAD becomes now 1 inch = 25.4mm in FreeCAD
All the other files with the rest of units look like they are well projected.
I opened in.dxf and mm.dxf files in VSC to compare them, as shown below, honestly I'm not expert but I think that in LibreCAD exports the files correctly .
Re: Units of measure in dxf import
If the image shows all the differences then there is something wrong with the original files. You would also expect different values for the INSUNITS variable. Please post the DXF files you have used.
- thomas-neemann
- Veteran
- Posts: 11910
- Joined: Wed Jan 22, 2020 6:03 pm
- Location: Osnabrück DE 🇩🇪
- Contact:
Re: Units of measure in dxf import
everything seems to work here
from librecad
Code: Select all
OS: Ubuntu 20.04.1 LTS (XFCE/xubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 0.20)
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.9.13, Qt 5.12.9, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.3
Locale: German/Germany (de_DE)
Installed mods:
* InventorLoader 1.3.0
* Curves 0.5.0
-
- Posts: 6
- Joined: Mon Jun 27, 2022 11:51 pm
-
- Posts: 6
- Joined: Mon Jun 27, 2022 11:51 pm
Re: Units of measure in dxf import
I tried with your file
and it worked well for me too300.dxf