[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11654] branches/2-44-stable/blender/ release/scripts/import_dxf.py: Big update to kitsu' s dxf importer from migius version beta09_f, too many changes an improvements to mention

Campbell Barton cbarton at metavr.com
Sat Aug 18 08:46:10 CEST 2007


Revision: 11654
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11654
Author:   campbellbarton
Date:     2007-08-18 08:46:10 +0200 (Sat, 18 Aug 2007)

Log Message:
-----------
Big update to kitsu's dxf importer from migius version beta09_f, too many changes an improvements to mention

The scripts thread is here http://blenderartists.org/forum/showthread.php?t=84319&page=8

Modified Paths:
--------------
    branches/2-44-stable/blender/release/scripts/import_dxf.py

Modified: branches/2-44-stable/blender/release/scripts/import_dxf.py
===================================================================
--- branches/2-44-stable/blender/release/scripts/import_dxf.py	2007-08-18 06:17:50 UTC (rev 11653)
+++ branches/2-44-stable/blender/release/scripts/import_dxf.py	2007-08-18 06:46:10 UTC (rev 11654)
@@ -1,54 +1,156 @@
 #!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: '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 17.08.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
+ INSERT  (=block)
+ MINSERT (=array)
+ CIRCLE
+ ARC
+ 3DFACE
+ 2d-POLYLINE (incl.:arc-segments, variable-width-segments)
+ 2d-POLYLINE (curved, spline)
+ 3d-POLYLINE (curved, spline)
+ 3d-POLYMESH
+ 3d-POLYFACE
+ TEXT
 
-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.
+Supported DXF Objects: (*)-under construction
+ *LWPOLYLINE (DXF>r12 LightWeight POLYLINE)
+ *MTEXT   (DXF>r12)
+ *ELLIPSE (DXF>r12)
 
-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.
+Not supported DXF Objects:
+ DIMENSION
+ XREF (External Reference)
+ SPLINE  (DXF>r12)
+ GROUP   (DXF>r12)
+ RAY/XLINE  (DXF>r12)
+ LEADER  (DXF>r12)
+ 3DSOLID, BODY, REGION (DXF>r12)
+ dynamic BLOCK (DXF 2006)
 
+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.
+
+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 by migius 08.2007: "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]
+ -- 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"
+
+ beta09: 17.08.2007 by migius
+ f- cleanup code
+ f- bugfix: thickness for Bezier/Bsplines into Blender-curves
+ 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: Optimisations 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
+ 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 +172,67 @@
 # --------------------------------------------------------------------------
 
 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
+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
+
+FILENAME_MAX = 180    #max length of path+file_name string  (FILE_MAXDIR + FILE_MAXFILE)
+MAX_NAMELENGTH = 17   #max_effective_obnamelength in blender =21=17+(.001)
+INIFILE_DEFAULT_NAME = 'importDXF.ini'
+INIFILE_EXTENSION = '.ini'
+INIFILE_HEADER = 'ImportDXF.py ver.1.0 config data'
+
 AUTO = BezTriple.HandleTypes.AUTO
-BYLAYER=256
+FREE = BezTriple.HandleTypes.FREE
+VECT = BezTriple.HandleTypes.VECT
+ALIGN = BezTriple.HandleTypes.ALIGN
+cur_COUNTER = 0  #counter for progress_bar
+
+
 """This module provides wrapper objects for dxf entities.
-    
-    The wrappers expect a "dxf object" as input.  The dxf object is
-    an object with a type and a data attribute.  Type is a lowercase 
-    string matching the 0 code of a dxf entity.  Data is a list containing
-    dxf objects or lists of [code, data] pairs.
-    
-    This module is not general, and is only for dxf import.
+
+	The wrappers expect a "dxf object" as input.  The dxf object is
+	an object with a type and a data attribute.  Type is a lowercase
+	string matching the 0 code of a dxf entity.  Data is a list containing
+	dxf objects or lists of [code, data] pairs.
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list