[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11963] trunk/blender/release/scripts/ import_dxf.py: update from mingus

Campbell Barton cbarton at metavr.com
Sat Sep 8 01:33:31 CEST 2007


Revision: 11963
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11963
Author:   campbellbarton
Date:     2007-09-08 01:33:30 +0200 (Sat, 08 Sep 2007)

Log Message:
-----------
update from mingus

Modified Paths:
--------------
    trunk/blender/release/scripts/import_dxf.py

Modified: trunk/blender/release/scripts/import_dxf.py
===================================================================
--- trunk/blender/release/scripts/import_dxf.py	2007-09-07 23:12:24 UTC (rev 11962)
+++ trunk/blender/release/scripts/import_dxf.py	2007-09-07 23:33:30 UTC (rev 11963)
@@ -1,54 +1,168 @@
 #!BPY
 
-# """
-# Name: 'Drawing eXchange Format (.dxf)'
-# Blender: 243
-# Group: 'Import'
-# Tooltip: 'Import DXF file.'
-# """
-__author__ = 'Kitsu (Ed Blake)'
-__version__ = '0.9 1/2007'
-__url__ = ["elysiun.com", "BlenderArtists.org"]
-__email__ = ["Kitsune_e at yahoo.com"]
+"""
+Name: 'Autodesk DXF (.dxf)'
+Blender: 244
+Group: 'Import'
+Tooltip: 'Import for DXF geometry data (Drawing eXchange Format).'
+"""
+__author__ = 'Kitsu(Ed Blake) & migius(Remigiusz Fiedler)'
+__version__ = '1.0.beta09 by migius 02.09.2007'
+__url__ = ["http://blenderartists.org/forum/showthread.php?t=84319",
+	 "http://wiki.blender.org/index.php/Scripts/Manual/Import/DXF-3D"]
+__email__ = ["Kitsune_e(at)yahoo.com", "remi_(at)gmx.de"]
 __bpydoc__ = """\
-This is a Blender import script for dxf files.
+This script imports DXF objects (2d/3d) into Blender.
 
-This script imports the dxf Geometery from dxf versions 2007 and earlier.
+This script imports 2d and 3d Geometery from DXFr12 format files.
+This version is focused on import of 3d-objects.
 
-Supported:<br>
-   At this time only mesh based imports are supported.<br>
-   Future support for all curve import is planned.<br>
-  <br>
-Currently Supported DXF Ojects:<br>
-     Lines<br>
-     LightWeight polylines<br>
-     True polylines<br>
-     Text<br>
-     Mtext<br>
-     Circles<br>
-     Arcs<br>
-     Ellipses<br>
-     Blocks<br>
-     3Dfaces<br>
+Supported DXF Objects:
+LINE
+POINT
+SOLID
+TRACE
+TEXT
+INSERT (=block)
+MINSERT (=array)
+CIRCLE
+ARC
+3DFACE
+2d-POLYLINE (=plane, incl. arc, variable-width, curve, spline)
+3d-POLYLINE (=no-plane)
+3d-POLYMESH
+3d-POLYFACE
+under construction, partly supported DXF>r12:
+LWPOLYLINE (LightWeight), MLINE, MTEXT, ELLIPSE
 
-Known issues:<br>
-   Does not convert perfectly between Object Coordinate System (OCS) 
-   and World Coordinate System (WCS).  Only rudimentary support for
-   true polylines have been implimented - splines/fitted curves/
-   3d plines/polymeshes are not supported.
-   No support for most 3d entities. Doesn't support the new style object 
-   visability.  There are problems importing some curves/arcs/circles.
+Unsupported DXF Objects:
+DXF r12: DIMENSION, XREF (External Reference)
+DXF>r12: SPLINE, GROUP, RAY/XLINE, LEADER, 3DSOLID, BODY, REGION, dynamic BLOCK
 
-Notes:<br>
-   This is primarally a 2d drawing release.  Currently only support for
-   3d faces has been added.
-   Blocks are created on layer 19 then referenced at each insert point.  The
-   insert point is designated with a small 3d crosshair.  This handle does not render.
+Supported Properties:
+Hierarchy: Entire DXF BLOCKs hierarchy is preserved after import into Blender
+visibility, frozen
+COLOR
+LAYER
+thickness
+width
+(todo: grouped, XDATA)
+It is recommended to use DXF-object properties for coding Blender materials.
 
+Notes:
+- Recommend that you run 'RemoveDoubles' on each imported mesh after using this script
+- Blocks are created on layer 19 then referenced at each insert point.
+* Big DXF-files (over 1500 objects) decrease import performance. The problem is not the inefficiency of python-scripting but Blenders performance in creating new objects in his database - probably a database management problem.
+* The Blender curves of imported ARCs and POLYLINE-arc-segments have light malformed ends.(to fix in beta10)
+- Bug in newScene-option: ARCs and CIRCLEs are drawn at (0,0,0). (wip)
+	
+TODO:  
+- filtering of unused/not-inserted Blocks
+- the new style object visibility
+- support for Spline-curves, Besier-curves
+- support for real 3d-solids (ACIS)
+- (to see more, search for "-todo-" in script)
+
+
+History:
+ v1.0 08.2007 by migius: "full 3d"-release
+    TODO:
+ -- command-line-mode/batch-mode
+ -- human-formating of data in INI-File
+ -- suport for MLine
+ -- suport for Ellipse
+ -- suport for Mtext
+ -- blender_object.ID.properties[dxf_layer_name]
+ -- Configuration files(.ini) can handle various material setups
+ -- added f_layerFilter
+ -- to-check: new_scene-idea from ideasman42: each import create a new scene
+ -- to-check: obj/mat/group/_mapping-idea from ideasman42:
+ -- better support for long dxf-layer-names 
+ -- support width_force for LINEs/ARCs/CIRCLEs/ELLIPSEs = "solidify"
+ -- added fill/non-fill option for closed curves: CIRCLEs,PLINEs
+ -- bug:? Circle/Arcs in each "newScene" drawn at <0,0,0>
+ -- bug:? object = Object.Get(obname) -> = SCENE.getChildren(obname)
+ beta09: 02.09.2007 by migius
+ g5 redesign UI: grouping of buttons
+ g3 update multi-import-mode: <*.*> button
+ g- added multi-import-mode: (path/*) for importing many dxf-files at once
+ g- added import into newScene
+ g- redesign UI: user presets, into newScene-import  
+ f- cleanup code
+ f- bugfix: thickness for Bezier/Bsplines into Blender-curves
+ f- BlenderWiki documentation, on-line Manual
+ f- added import POLYLINE-Bsplines into Blender-NURBSCurves
+ f- added import POLYLINE-arc-segments into Blender-BezierCurves
+ f- added import POLYLINE-Bezier-curves into Blender-Curves
+ d5 rewrite: Optimization Levels, added 'directDrawing'
+ d4 added: f_set_thick(cntrolled by ini-parameters)
+ d4 bugfix: face-normals in objects with minus thickness
+ d4 added: placeholder'Empty'-size in f_Insert.draw
+ d3 rewrite f_Text.Draw: added suport for all Text's parameters
+ d2 redesign: progressbar 
+ e- tuning by ideasman42: better use of the Py API.
+ c- tuning by ideasman42
+ b- rewrite f_Text.Draw rotation/transform
+ b- bugfix: POLYLINE-segment-intersection more reliable now
+ b- bugfix: circle:_thic, 'Empties':no material_assignement
+ b- added material assignment (from layer and/or color)
+ a- added empty, cylinder and UVsphere for POINTs
+ a- added support for 2d-POLYLINE: splines, fitted curves, fitted surfaces
+ a- redesign f_Drawer for block_definitions
+ a- rewrite import into Blender-Curve-Object
+ beta08: 27.07.2007 by migius
+ l- bugfix: solid_vgroups, clean:scene.objects.new()
+ l- redesign UI to standard Draw.Register+FileSelector, advanced_config_option
+ k- bugfix UI:fileSelect() for MacOSX os.listdir()
+ k- added reset/save/load for config-data
+ k- redesign keywords/drawTypes/Draw.Create_Buttons
+ j- new interface using UIBlock() with own FileSelector, cause Window.FileSelector() too buggy
+ i- rewritten Class:Settings for better config-parameter management
+ h- bugfix: face-normals in objects with minus thickness
+ h- added Vertex-Groups in polylines and solids generated Meshes, for easier material assignment
+ h- beautify code, whitespace->tabs
+ h- added settings.thic_force switch for forcing thickness
+ h- added one Object/Mesh for all simple-entities from the same Layer,
+	sorted in Vertex-Groups(color_name)  (fewer objects = better import performance)
+ g- rewrote: insert-point-handle-object is a small tetrahedron
+ e- bugfix: closed-polymesh3d
+ - rewrote: startUI, type_map.keys, f_drawer, for all class_f_draw(added "settings" as attribut)
+ - added 2d/3d-support for Polyline_Width incl. angleintersection
+ beta07: 19.06.2007 by migius
+ - added 3d-support for LWPolylines
+ - added 2d/3d-support for Points
+ beta06: 15.06.2007 by migius
+ - cleanup code
+ - added 2d/3d-support for MINSERT=BlockArray in f_drawer, added f_rotXY_Vec
+ beta05: 14.06.2007 by migius
+ - added 2d/3d-support for 3d-PolyLine, PolyMesh and PolyFace
+ - added Global-Scale for size control of imported scenes
+ beta04: 12.06.2007 by migius
+ - rewrote the f_drawBulge for correct import the arc-segments of Polylines
+ beta03: 10.06.2007 by migius
+ - rewrote interface
+ beta02: 09.06.2007 by migius
+ - added 3d-support for Arcs and Circles
+ - added support for Object_Thickness(=height)
+ beta01: 08.06.2007 by migius
+ - added 3d-support for Blocks/Inserts within nested-structures
+ - rewrote f_transform for correct 3d-location/3d-rotation
+ - added 3d-support Lines, 3dFaces
+ - added 2d+3d-support for Solids and Traces
+
+ v0.9 by kitsu 01.2007: (for 2.43)
+ -
+
+ v0.8 by kitsu 12.2007:
+ -
+
+ v0.5b by kitsu 10.2006 (for 2.42a)
+ -
+
 """
 
 # --------------------------------------------------------------------------
-# DXF Import v0.9 by Ed Blake (AKA Kitsu)
+# DXF Import v1.0 by Ed Blake (AKA kitsu) and Remigiusz Fiedler (AKA migius)
 # --------------------------------------------------------------------------
 # ***** BEGIN GPL LICENSE BLOCK *****
 #
@@ -70,37 +184,68 @@
 # --------------------------------------------------------------------------
 
 import Blender
+import bpy
 from Blender import *
-Sys = sys
+#from Blender.Mathutils import Vector, Matrix
+#import BPyMessages
 
-from dxfReader import readDXF, get_name, get_layer
+
+from dxfReader import readDXF      # get_name, get_layer
 from dxfReader import Object as dxfObject
 from dxfColorMap import color_map
 from math import *
 
 try:
-    import os
-    if os.name:# != 'mac':
-        import psyco
-        psyco.log()
-        psyco.full(memory=100)
-        psyco.profile(0.05, memory=100)
-        psyco.profile(0.2)
+	import os
+	if os.name:# != 'mac':
+		import psyco
+		psyco.log()
+		psyco.full(memory=100)
+		psyco.profile(0.05, memory=100)
+		psyco.profile(0.2)
 except ImportError:
-    pass
+	pass
 
-SCENE = Scene.GetCurrent()
+print '\n\n\n\n'
+print 'Import DXF to Blender *** START ***'   #---------------------
+
+SCENE = None
 WORLDX = Mathutils.Vector((1,0,0))
+WORLDY = Mathutils.Vector((1,1,0))
+WORLDZ = Mathutils.Vector((0,0,1))
+
+G_SCALE = 1.0		#(0.0001-1000) global scaling factor for all dxf data
+MIN_DIST = 0.001	#cut-off value for sort out short-distance polyline-"duoble_vertex"
+ARC_RESOLUTION = 64   #(4-500) arc/circle resolution - number of segments
+ARC_RADIUS = 1.0   #(0.01-100) arc/circle radius for number of segments algorithm
+THIN_RESOLUTION = 8   #(4-500) thin_cylinder arc_resolution - number of segments
+MIN_THICK = MIN_DIST * 10.0  #minimal thickness by forced thickness
+MIN_WIDTH = MIN_DIST * 10.0  #minimal width by forced width
+ANGLECUT_LIMIT = 3.0	 #limit for anglecut of polylines-wide-segments (values:1.0 - 5.0)
+TARGET_LAYER = 3    #target blender_layer
+GROUP_BYLAYER = 0   #(0/1) all entities from same layer import into one blender-group
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list