Draft DXF/sv

Description

Draft DXF is a software module used by the Std Open, Std Import and Std Export commands to handle the DXF file format.

From the user's point of view, the DXF import/export module will be loaded automatically when any of those commands are invoked and the file to open, import or export is a DXF file. The main difference between Std Open and the import command is that the former will create a new FreeCAD document and then do the import, whereas the later will import the DXF file and insert the result in the currently active document.

Qcad drawing exported to DXF, which is subsequently opened in FreeCAD

Öppna

Denna funktion öppnar en DXF fil (alla versioner från 12 till 2007) i en ny ritning. Följande DXF objekttyper stöds för närvarande:

  • lines
  • polylines och lwpolylines
  • circles
  • arcs
  • layers (layers som innehåller objekt konverteras till FreeCAD Grupper)
  • texts och mtexts
  • dimensions
  • blocks (endast geometri. texter, dimensioner och attribut inuti block behandlas inte)

Andra DXF föremål importeras för närvarande inte eftersom det inte finns något motsvarande FreeCAD objekt. Allteftersom ny funktionalitet utvecklas, så kommer det att vara möjligt att importera fler föremålstyper.

Two importers are available, which one is used can be specified under Edit → Preferences... → Import-Export → DXF. One is built-in, C++-based and fast, the other is legacy, coded in Python, slower, and requires the installation of an add-on, but can handle some entities better and can create more refined FreeCAD objects. Both support all DXF versions starting from R12.

3D solids inside a DXF file are stored under a binary ACIS/SAT blob, which at the moment cannot be read by FreeCAD.


DXF importer entity support comparison
Entity C++ importer Legacy importer
Lines
Polylines (and LWPOLYLINES)
Arcs
Circles
Ellipses
Splines
Texts & MTexts
Leaders
Layers
Points
Dimensions
Blocks
(Geometry only; texts, dimensions, and attributes inside blocks are skipped)
Paper space objects
3D Faces

Exportera

Den exporterade DXF filen är kompatibel med Autocad version 12 och upp, så den ska kunna öppnas i så gott som alla applikationer som stöder dxf formatet. För närvarande så exporteras följande FreeCAD objekt:

  • linje och trådar (polylines)
  • cirkelbågar och cirklar
  • texter
  • Färger konverteras från objektens RGB färger till autocad color index (ACI). Svart komme alltid att vara "by layer"
  • lager konverteras från gruppnamn. När grupper är nästlade, så kommer lagret att får namnet på den djupaste gruppen.
  • dimensioner, vilka exporteras med "Standard" dimensioneringsstil

There are also two exporters. The legacy exporter exports to the R12 DXF format, the C++ exporter to the R14 DXF format. Both formats can be handled by many applications.

DXF exporter entity support comparison
Feature C++ exporter (R14) Legacy exporter (R12)
Supported 2D Geometry All except Bezier curves. Ellipses and Splines are exported natively. All except Points. Ellipses and B-splines may be inaccurate or exported as polylines.
Points
(If the "Export points" preference is enabled)
3D Objects Edges from faces are exported. Curved edges only if on XY plane. May create duplicate lines. Exported as flattened 2D views.
Texts and Dimensions
Colors
(Based on object line color)
Layers
(Mapped from object names)

(Mapped from layers and nested groups)
Compounds
(Exported as blocks)

Installing

For licensing reasons, the required DXF import/export libraries needed by the legacy version of the importer are not part of the FreeCAD source code. For more information see: FreeCAD and DXF Import.

Preferences

See Import Export Preferences.

DWG

Because the DWG format is a proprietary, closed and undocumented format it is hard for open-source projects like FreeCAD to support it. That is why FreeCAD relies on external converters to read and write DWG files. To import a DWG file a converter is used to create a DXF first, which can then be processed by the FreeCAD DXF importer. When exporting to DWG the opposite conversion happens: the DXF created by the FreeCAD DXF exporter is turned into a DWG.

Note that the DXF format allows a 1:1 conversion of the DWG format. All applications that can read and write DWG files can do the same with DXF files, with no data loss. So asking for DXF files instead of DWG files, and supplying DXF files in turn, should not cause any problems.

There is built-in support for the following DWG converters:

See Import Export Preferences and FreeCAD and DWG Import for more information.

Scripting

See also: Autogenerated API documentation and FreeCAD Scripting Basics.

To export objects to DXF use the export method of the importDXF module.

importDXF.export(objectslist, filename, nospline=False, lwPoly=False)

Example:

import FreeCAD as App
import Draft
import importDXF

doc = App.newDocument()

polygon1 = Draft.make_polygon(3, radius=500)
polygon2 = Draft.make_polygon(5, radius=1500)

doc.recompute()

objects = [polygon1, polygon2]
importDXF.export(objects, "/home/user/Pictures/myfile.dxf")