DXF: Difference between revisions

From FreeCAD Documentation
m (→‎How to use: "create" instead of "draw" to be less redundant)
(Removed Dxf_Importer_Install.)
 
(24 intermediate revisions by 10 users not shown)
Line 1: Line 1:
<languages/>
== Description ==
{{TOCright}}
[https://en.wikipedia.org/wiki/AutoCAD_DXF AutoCAD DXF] (Drawing Interchange Format, or Drawing Exchange Format) is a data file format developed by Autodesk to enable interoperability between the AutoCAD application and other programs. It was originally introduced in 1982 as part of AutoCAD 1.0.
<translate>


== Background history == <!--T:1-->
Due to the popularity of AutoCAD as a drawing application, the DXF file has become widely supported by many other drawing applications, especially to represent 2D shapes like in architectural plans and solid body projections. ASCII versions of DXF can be read with a text editor, in similar way to [[SVG]] files.


<!--T:2-->
Two common versions of the DXF specification are almost always supported:
The Drawing Exchange Format (DXF) is a proprietary CAD data format developed by Autodesk to enable file exchange between their flagship AutoCAD product and other software. There are a number of good software libraries for reading/writing the DXF format.
* The R12 version is an older and simpler version, but is well supported by most programs.
* The R14 version is newer, and includes more advanced features such a splines.


<!--T:4-->
The [https://en.wikipedia.org/wiki/.dwg DWG] file format is a related format. While DWG is the native, binary file format of AutoCAD, DXF is only a representation of the that same data. In many cases, it's easy to import and export DXF files, but it's hard to deal with DWG files due to their more complex and proprietary nature.
There are many versions of the DXF format. You will hear of certain key versions, such as R12 (from 1992) or R14 (from 1997 which had splines). Later versions of DXF have 3D elements, but these are rarely used or implemented. How you use DXF to share CAD data between programs depends mainly on the limitations and bugs in the corresponding readers/importers and writers/exporters. These are rarely fully documented and can be a great source of frustration.


<!--T:5-->
== How to use ==
If you are editing DXF files and want them to remain almost the same when you save them, we recommend you use [https://en.wikipedia.org/wiki/LibreCAD LibreCAD] or [https://en.wikipedia.org/wiki/QCad QCad] because these programs' internal data structures are compatible with the objects in the DXF file.


<!--T:6-->
FreeCAD can read and export DXF graphics using the [[Draft DXF]] function from the [[Draft Workbench]]. The [[TechDraw Workbench]] can also export drawing pages to DXF using the [[TechDraw SaveDXF]] function.
In FreeCAD the DXF readers must translate the geometry (e.g., spline shapes) from the DXF file into the specific internal representations of the Workbench.


== Methods for importing DXF to FreeCAD == <!--T:7-->
FreeCAD is primarily a 3D modelling application, and thus doesn't have many 2D drawing tools, which are mostly included in the [[Draft Workbench|Draft]] and [[Sketcher Workbench]]es. To exclusively create technical drawings in 2D, and produce DXF files, there are alternative programs like [https://en.wikipedia.org/wiki/LibreCAD LibreCAD] and [https://en.wikipedia.org/wiki/QCad QCad].


<!--T:8-->
{{Userdocnavi}}
If you intend to review the settings frequently, we recommend you go to Edit → Preferences → Import-Export → DXF and tick the box "[ ] Show this dialog when importing and exporting".
[[Category:User Documentation]]

[[Category:Draft]]
<!--T:9-->
[[Category:TechDraw]]
More information is on the pages [[Draft_DXF|Draft DXF]] and [[FreeCAD_and_DXF_Import|FreeCAD and DXF Import]].

<!--T:10-->
If you are using the imported geometry to build 3D shapes in the Part Design Workbench, try the [[Sketcher_ValidateSketch|Sketcher Validate]] after you have imported the DXF into a sketch.

=== C++ DXF importer === <!--T:11-->

<!--T:12-->
This implementation of fast, but skips features it doesn't recognize, such as DXF splines. It also can only import geometry into the Draft Workbench as individual entries in the Model tree. These can have the colors read from the file if you tick to enable this option. For further information, see [https://forum.freecadweb.org/viewtopic.php?f=3&t=32493 this forum post].

=== Python DXF importer === <!--T:13-->

<!--T:14-->
This importer has to be downloaded and installed before it can be used. Use the "[ ] Allow FreeCAD to automatically download and update the DXF libraries" option.

<!--T:15-->
This importer has more features (such as implementing splines), and has the option of loading the DXF shapes into the Sketcher Workbench. However, be warned that all the elements of the sketch will appear individually a second time in the model tree, which can be confusing. You can delete all these individual objects and retain the single sketch (which appears as the second entry in the list of new elements).

<!--T:16-->
Unfortunately, the Sketcher Workbench does not implement colors, so all the geometry will appear on the same level, which is a problem if the file contains many construction lines. One work-around is to open your drawing in LibreCAD, and delete all the geometry you don't want to appear before saving a file that contains exactly the geometry that you want to load.

=== Macros === <!--T:17-->

<!--T:18-->
Keep an eye out on the FreeCAD forum or in the [[Macros_recipes|Macros recipes]] for alternative implementations of DXF importing and cleaning up as they develop.

== Saving DXF == <!--T:19-->

<!--T:20-->
In addition to the options under the Edit Preferences, the [[TechDraw_Workbench|TechDraw Workbench]] can also export drawing pages to DXF using the [[TechDraw_ExportPageDXF|TechDraw ExportPageDXF]] function.


</translate>
{{Userdocnavi{{#translation:}}}}
[[Category:User Documentation{{#translation:}}]]
[[Category:Draft{{#translation:}}]]
[[Category:TechDraw{{#translation:}}]]
[[Category:File_Formats{{#translation:}}]]

Latest revision as of 20:03, 22 November 2023

Background history

The Drawing Exchange Format (DXF) is a proprietary CAD data format developed by Autodesk to enable file exchange between their flagship AutoCAD product and other software. There are a number of good software libraries for reading/writing the DXF format.

There are many versions of the DXF format. You will hear of certain key versions, such as R12 (from 1992) or R14 (from 1997 which had splines). Later versions of DXF have 3D elements, but these are rarely used or implemented. How you use DXF to share CAD data between programs depends mainly on the limitations and bugs in the corresponding readers/importers and writers/exporters. These are rarely fully documented and can be a great source of frustration.

If you are editing DXF files and want them to remain almost the same when you save them, we recommend you use LibreCAD or QCad because these programs' internal data structures are compatible with the objects in the DXF file.

In FreeCAD the DXF readers must translate the geometry (e.g., spline shapes) from the DXF file into the specific internal representations of the Workbench.

Methods for importing DXF to FreeCAD

If you intend to review the settings frequently, we recommend you go to Edit → Preferences → Import-Export → DXF and tick the box "[ ] Show this dialog when importing and exporting".

More information is on the pages Draft DXF and FreeCAD and DXF Import.

If you are using the imported geometry to build 3D shapes in the Part Design Workbench, try the Sketcher Validate after you have imported the DXF into a sketch.

C++ DXF importer

This implementation of fast, but skips features it doesn't recognize, such as DXF splines. It also can only import geometry into the Draft Workbench as individual entries in the Model tree. These can have the colors read from the file if you tick to enable this option. For further information, see this forum post.

Python DXF importer

This importer has to be downloaded and installed before it can be used. Use the "[ ] Allow FreeCAD to automatically download and update the DXF libraries" option.

This importer has more features (such as implementing splines), and has the option of loading the DXF shapes into the Sketcher Workbench. However, be warned that all the elements of the sketch will appear individually a second time in the model tree, which can be confusing. You can delete all these individual objects and retain the single sketch (which appears as the second entry in the list of new elements).

Unfortunately, the Sketcher Workbench does not implement colors, so all the geometry will appear on the same level, which is a problem if the file contains many construction lines. One work-around is to open your drawing in LibreCAD, and delete all the geometry you don't want to appear before saving a file that contains exactly the geometry that you want to load.

Macros

Keep an eye out on the FreeCAD forum or in the Macros recipes for alternative implementations of DXF importing and cleaning up as they develop.

Saving DXF

In addition to the options under the Edit → Preferences, the TechDraw Workbench can also export drawing pages to DXF using the TechDraw ExportPageDXF function.