This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Add-ons / Standard Packages / Utilities  /

Utilities`DXF`

DXF is a graphics interchange format in plain text form created by AutoDesk, the makers of AutoCAD. This format can be used for the transfer of graphics to AutoCAD and many other programs, including ray tracers and other three-dimensional rendering packages. The package allows the export of Graphics3D objects to a file in the DXF format.


Using the DXF format.

WriteDXF does not allow writing to an OutputStream; it only writes to an unopened file. Note that the graphic must be a Graphics3D object. To export a SurfaceGraphics or other type of object, the object must first be converted to a Graphics3D object.

  • This loads the package.
  • In[1]:= <<Utilities`DXF`

  • This defines a three-dimensional graphic.
  • In[2]:= gr = Graphics3D[
    {Point[{0, 0, 0}], Point[{0, 1, 0}]}];

  • This creates a DXF file for gr.
  • In[3]:= WriteDXF["test.dxf", gr]

    Out[3]=

  • Here is what the file looks like.
  • In[4]:= !!test.dxf

    0
    SECTION
    2
    ENTITIES
    0
    POINT
    8
    0
    10
    0
    20
    0
    30
    0
    0
    POINT
    8
    0
    10
    0
    20
    1
    30
    0
    0
    ENDSEC
    0
    EOF


    Options for WriteDXF.

    In some cases (e.g., export to ray-tracing software), you may wish to output polygons only. The PolygonsOnly option allows you to do this.
    Note: The package currently writes out only certain graphics primitives (Line, Point, Polygon, and Cuboid). Any style information is lost, as are axes, boxes, etc. This results in a DXF file equivalent to one created by the "entities only" option from AutoCAD. Cuboids and polygons with more than four sides are subdivided into triangular polygons. (This process creates a temporary file; be sure you have enough disk space to accommodate it. This will consume as much disk space as a Mathematica PostScript file for the same objects.)