Extensions:2.4/Py/Scripts/Export/DXF

提供: wiki
< Extensions:2.4‎ | Py‎ | Scripts‎ | Export
移動先: 案内検索
DXF Exporter
Export geometery to DXF or DWG file format.
UI location File → Export → Autodesk (.dxf .dwg)...
Version 1.37 - 2010.06.23 Author(s) Stani Michiels(AKA Stani), Remigiusz Fiedler(AKA migius)
Blender 2.46 - 2.49 License GPL
Note(s) The script is bundled with Blender 2.48 and up. The exporter doesn't need a full Python installation on Windows.


Executable information
File name export_dxf.py
Python modules dxfLibrary.py ver.1.35, dxfColorMap.py


Links DXF-Exporter - release thread on Blender Artists forum.


Introduction

Manual-Exporter-DXF-gui13.png

This script exports geometry to DXF format (and optionally to DWG format).
DWG and DXF (Drawing eXchange Format) are CAD data file formats, developed by Autodesk/AutoCAD.


Version 1.37 supports DXF-r12 format. It supports mesh and curve objects, recently also texts. Read more in compatibility details.


The exporter writes output data into DXF format with help of dxfLibrary.py v.1.35 (also known as "sdxf.py" - python library developed by Stani Michiels).


The exporter supports DWG format with help of an external DXF-DWG-converter: DConvertCon. It is not a part of Blender standard installation. It is a Windows console application (DOS-Box) and run also on Linux and OSX (on Wine). For details and for alternative solutions please look in Stani Michiels blog.

Support

Downloads

Links

Usage

Installation

Get the newest script version from downloads section.
Extract export_dxf.py script from zip archive into standard Blender script directory %blender%\.blender\scripts\.
Extract dxfLibrary.py script into directory %blender%\.blender\scripts\bpymodules\.
To avoid conflicts you have to remove older versions of the scripts from this folder. Caution: simply rename doesn't work!
If you need DWG support, the DConvertCon.exe (link above) must be copied into %blender%\.blender\scripts\.
Restart Blender (optionally, click the 'Update Menus' entry in the script window menu).
More details about handling with python scripts in Blender can be find at BlenderWiki

User Interface

Manual-Exporter-DXF-gui13.png

Select the script from the menu: File → Export → Autodesk DXF (.dxf).

All UI buttons and fields are documented with tooltips.
Options marked with (.) (dot) are WIP / "under construction" / partially functional.
Options marked with (..) are only placeholders / inactive yet.

Config activates Advanced Configuration Panel.

X resets configuration to default parameters.

2d and 3d buttons set optimal parameters for 2D or 3D export.

Dxffile > select .DXF or .DWG file with file-selector or type filename direct into the text field.

Export selected : only selected objects will be exported. Otherwise all geometry form active scene will be exported.

Visible only : exports only from visible layers.

Polyline-mode : activates a complex representation of geometry: objects will be exported to POLYLINEs(curves) and POLYFACEs(meshes). Otherwise to common LINEs / 3DFACEs.

Instances as blocks : if Mesh/Curve has multiple instances, the BLOCK and INSERTs will be created.

Apply modifiers : applies Modifiers to the Mesh before export.

Include duplis : exports Objects duplicated as Dupliframes, Duplifaces, Dupligroups.


2d projection activates a 2d projection: edge-geometry will be transformed to 2d according selected Camera or current 3D-View plane. It could be useful for exporting views and sectional views of 3d models to 2d applications. The global Scale parameter is working well with this function and helps to create proper scaled drawings.

Camera select a Camera for render from. The list shows all Cameras in the scene.

> set selected Camera to be an active one.

Remove back-faces activates a semi-"hidden line" mode: only front-oriented faces will be exported. The procedure is very fast (relative to standard hidden-line algorithm), but output needs manual post-production for good results.

Online help points the system web-browser to manual on wiki.blender.org.

Dwg converts output DXF code to DWG r12 format.

<optim: 2 > Optimization Level:
Level "0" - debug-mode: prints warnings to console, additionally draws exported entities in scene at 3d-cursor position.
Level "1" - verbose-mode.
Level "2" - non verbose-mode: only progress bar feedback, normal speed.
Level "3" - silent-mode: a bit faster?

Start import starts import job.
During the import process the UI is blocked. To stop or cancel the import, flip over to the console-window and hit ctrl-c .

To exit/cancel the script: press EXIT-button or hit Esc or ⇥ End.

Configuration

Manual-Exporter-DXF-gui13b.png

Presets Management

All configuration parameters can be stored in an .INI-file.

For select an .INI-file go to file selector with Ini-file> or type filename directly into the text field.

"#" switches through the names of standard preset .INI-files saved in the project directory. It is the easy way to switch user-defined configurations.

Load loads configuration parameters from selected .INI-file.

Save saves current configuration parameters into selected .INI-file.

Object Filtering

Buttons like Mesh Curve ... Text ... Camera activate/deactivate support for particular Blender object types. With the pop-up-menus right them you can set their counterpart representation in DXF:

Lines 3dfaces - simplified representation, connectivity information is dropped out

Polyline Polyface - complex representation, preserves connectivity and relationship information

more Filtering

Paper exports objects into "Paper Space"

..frozen (todo) exports objects into frozen layers.

..layer (todo) filters layers.

..color (todo) filters colors.

..group (todo) filters groups.

..object (todo) filters blocks.

Global Location and Scale

Location: if activated, moves the output geometry origin to new location.

Scale if activated, sets the global scale factor for exported geometry. You can use it for exact matching target CAD application requirements.

Elevation: if activated, set every Z coordinate to given elevation value. (prev. "Flatten")

DXF Styles Management

Each exported entity has a set of properties associated with: LAYER, COLOR, LINETYPE. You can set here the values for them in relation to characteristics: objects name, object data name, material name, material RGB, etc. Defaults are used if the particular object has no corresponding parameter value. Like other configuration parameters, these values can be stored in an .INI file too.



Notes

  • On Windows platform the exporter doesn't need a full Python installation.

Known issues

  • The exported DXF file has limited ACTIVE-VIEW definition support, so after opening it in CAD application, zoom to extends to see the complete geometry.

Compatibility

Concerns version 1.35 - 2009.06.18:

  • Output format is the most popular/accepted version of DXF: r12.
  • Exports objects of any orientation, scale, parenting or animation-keying.
  • Translates multiple instances of object into BLOCK definition and INSERTs.
  • Hierarchical information (parenting) is not full supported yet - is translated to plain hierarchy - the child object's coordinates are evaluated to global coordinates.
  • Hierarchies can be automatic decomposed (optionally).
  • Curve-Objects are exported into LINEs or POLYLINEs (wip: or SPLINEs). Tangent/curve information is supported for NURBS-Curves, but not for Bezier-Curves - AutoCAD/DXF-specification doesn't support this type. Workaround: convert them into NURBS before export.


Supported

Supported Object types and properties:
  Blender          AutoCAD/DXF
mesh-vertex -> POINT,
mesh-edge   -> LINE,
mesh-face   -> 3DFACE or POLYFACE,
curve       -> LINEs or POLYLINE
curve-NURBS -> curved-POLYLINE,
text        -> TEXT or (wip: MTEXT),
camera      -> POINT or VIEW or VPORT or (wip: INSERT(ATTRIB+XDATA),
lamp        -> POINT or (wip: INSERT(ATTRIB+XDATA),
empty       -> POINT or (wip: INSERT),
obj.matrix  -> extrusion(210-group), rotation, elevation
3D-View     -> (wip: VIEW, VPORT)
modifier    -> auto-applied
duplivert   -> auto-instanced or (wip: INSERT)
dupliframe  -> auto-instanced or (wip: INSERT)
dupligroup  -> auto-instanced or (wip: INSERT)
material    -> LAYER+COLOR+STYLE properties

Missing

Unsupported Object types and properties:
  Blender               AutoCAD/DXF
(wip) group          -> BLOCK+INSERT,
(wip) parenting      -> BLOCK+INSERT,
(wip) visibility status  -> LAYER_on,
(wip) frozen status  -> LAYER_frozen,
(wip) locked status  -> LAYER_locked,
Surface,
Meta,
Armature,
Lattice,
IPO/Animation,

Additional Information

To-Do list

- see Compatibility and Missing lists above
- export dupligroups and dupliverts as blocks (option for the user to decide) 
- optimize POLYFACE routine: remove double-vertices
- more stable support for X,Y-rotated curves(to POLYLINEs): fix blender negative-matrix.invert()
- support hierarchies: groups, instances(done), parented structures
- support n/f-gons as POLYFACEs with invisible edges
- mapping materials to DXF-styles
- add ProgressBar
- wip: write drawing extends for automatic view positioning in CAD
- wip: correct text-objects in persp-projection
- wip: translate Camera to VPORT/VIEW
- wip: translate current 3D-View to *ACTIVE-VPORT

Credits

Thanks go to:
- Stani Michiels (AKA Stani):
for "sdxf.py" - Python Library for generating DXF drawings,
and for the idea of binding an external DXF/DWG converters
- Yorik van Havre (AKA yorik):
for the 2d-profile-exporter script - an initial inspiration
and for the vertex-ordering procedure for correct curve creation

History

v1.37 - 2010.06.23 by migius
- APPLY-MODIFIER: added exception for modifier-free instances to export them as BLOCK/INSERTs
v1.36 - 2010.06.20 by migius
- added export Nurbs-Curves (3,4,5th-degree) into POLYLINE-NURBS(quad,cubic)
  caution: no Bezier-Curves support in autoCAD nor in DXF-specification
v1.35 - 2009.06.18 by migius
- export multiple-instances of Curve-Objects as BLOCK/INSERTs
- added export Cameras (ortho and persp) to VPORTs, incl. clipping
- added export Cameras (ortho and persp) to  VIEWs, incl. clipping
- export multiple-instances of Mesh-Objects as BLOCK/INSERTs
- on start prints dxfLibrary version
v1.34 - 2009.06.08 by migius
- export Lamps and Cameras as POINTs
- export passepartout for perspective projection
- added option for export objects only from visible layers
- optimized POLYFACE output: remove loose vertices in back-faces-mode
- cleaning code
- fix nasty bug in getExtrusion()
- support text-objects, also in ortho/persp-projection
- support XYmirrored 2d-curves to 2dPOLYLINEs
- support thickness and elevation for curve-objects
- fix extrusion 210-code (3d orientation vector)
- fix POLYFACE export, synchronized with dxfLibrary.py
- changed to the new 2.49 method Vector.cross()
- output style manager (first try)
v1.33 - 2009.05.25 by migius
- bugfix flipping normals in mirrored objects
- added UI-Button for future Shadow generator
- support curve objects in projection-2d mode
- UI stuff: camera selector/manager
v1.32 - 2009.05.22 by migius
- debug mode for curve-objects: output pass to Blender
- wip support 210-code(extrusion) calculation
- default settings for 2D and 3D export
v1.31 - 2009.05.18 by migius
- globals translated to GUI_A/B dictionary
- optimizing back-faces removal for "hidden-lines" mode
- presets for global location and scale (architecture)
- UI layout: scrollbars, pan with MMB/WHEEL, dynamic width
- new GUI with Draw.Register() from DXF-importer.py
v1.30 - 2008.12.14 by migius
- started work on GUI with Draw.Register()
v1.29 - 2009.04.11 by stani
- added DWG support, Stani Michiels idea for binding an extern DXF-DWG-converter 
v1.28 - 2009.02.05 by alxarch
- added option to apply modifiers on exported meshes
- added option to also export duplicates (from dupliverts etc)
Manual-Exporter-DXF-gui127.png
v1.27 - 2008.10.07 by migius
- exclude Stani's DXF-Library to extern module, for more flexibility
v1.26 - 2008.10.05 by migius
- add "hidden line" substitut: back-faces removal
- add support for mesh ->POLYFACE
- optimized code for "Flat" procedure
v1.25 - 2008.09.28 by migius
- modif FACE class for r12
- add mesh-polygon -> Bezier-curve converter (Yorik's code)
- add support for curves ->POLYLINEs
- add "3D-View to Flat" - geometry projection to XY-plane
v1.24 - 2008.09.27 by migius
- add start UI with preferences
- modif POLYLINE class for r12
- changing output format from r9 to r12(AC1009)
v1.23 - 2008.09.26 by migius
- add finish message-box
v1.22 - 2008.09.26 by migius
- add support for curves ->LINEs
- add support for mesh-edges ->LINEs
v1.21 - 2008.06.04 by migius
- initial adaptation for Blender
v1.1 (20/6/2005) by www.stani.be/python/sdxf
- Python library to generate dxf drawings