[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15132] trunk/blender/release/scripts/ import_dxf.py: import_dxf.py script update: ver.

Remigiusz Fiedler migius at 4d-vectors.de
Thu Jun 5 14:31:16 CEST 2008


Revision: 15132
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15132
Author:   migius
Date:     2008-06-05 14:31:16 +0200 (Thu, 05 Jun 2008)

Log Message:
-----------
import_dxf.py script update: ver. 1.0.12b3-2008.06.05 
bugfix: ob.name conflict with existing meshes (different ob.name/mesh.name)
refactor/support for LWPOLYLINEs

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

Modified: trunk/blender/release/scripts/import_dxf.py
===================================================================
--- trunk/blender/release/scripts/import_dxf.py	2008-06-05 11:08:51 UTC (rev 15131)
+++ trunk/blender/release/scripts/import_dxf.py	2008-06-05 12:31:16 UTC (rev 15132)
@@ -1,5 +1,5 @@
 #!BPY
-# coding: utf-8
+
 """
 Name: 'Autodesk DXF (.dxf)'
 Blender: 244
@@ -7,14 +7,15 @@
 Tooltip: 'Import for DXF geometry data (Drawing eXchange Format).'
 """
 __author__ = 'Kitsu(Ed Blake) & migius(Remigiusz Fiedler)'
-__version__ = '1.0.12 - 2008.02.08 by migius'
+__version__ = '1.0.12 - 2008.06.05 by migius'
 __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", "migius(at)4d-vectors.de"]
 __bpydoc__ = """\
 This script imports objects from DXF (2d/3d) into Blender.
 
-This script imports 2d and 3d geometery from DXFr12 format files.
+This script imports 2d and 3d geometery from DXF files.
+Supported DXF format versions: from (r2.5) r12 up to 2008.
 Enhanced features are:
 - configurable object filtering and geometry manipulation,
 - configurable material pre-processing,
@@ -40,22 +41,23 @@
 
 Supported DXF>r12 objects:
 ELLIPSE,
-(wip v1.0.12 partly supported) LWPOLYLINE (LightWeight),
-(wip v1.0.12) MLINE,
-(wip v1.0.12) MTEXT
+LWPOLYLINE (LightWeight Polylines),
+(wip v1.0.12) SPLINE,
+(wip v1.0.13) MLINE,
+(wip v1.0.13) MTEXT
 
-Unsupported Objects:
+Unsupported objects:
 DXF r12: DIMENSION.
-DXF>r12: SPLINE, GROUP, RAY/XLINE, LEADER, 3DSOLID, BODY, REGION, dynamic BLOCK
+DXF>r12: GROUP, RAY/XLINE, LEADER, 3DSOLID, BODY, REGION, dynamic BLOCK
 
-Supported Geometry: 2d and 3d DXF-objects.
-Curves imported as curves or meshes optionally.
+Supported geometry: 2d and 3d DXF-objects.
+Curves imported as Blender curves or meshes optionally.
 
 Supported layout modes:
 "model space" is default,
 "paper space" as option (= "layout views")
 
-Scene definitions produced with AVE_RENDER:
+Supported scene definition objescts produced with AVE_RENDER:
 scene: selection of lights assigned to the camera,
 lights: DIRECT, OVERHEAD, SH_SPOT,
 (wip v1.0.13 import of AVE_RENDER material definitions)
@@ -77,14 +79,10 @@
 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.
+- support for DXF-files up to 160MB on systems with 1GB RAM
+- DXF-files with 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.
-	
-TODO:  
-- the new style object visibility
-- support for real 3d-solids (ACIS)
-- (to see more, search for "--todo--" in script code)
+in creating new objects in scene database - probably a database management problem.
 
 """
 
@@ -92,6 +90,7 @@
 History:
  v1.0 - 2008.01. by migius
  planned tasks:
+ -- (to see more, search for "--todo--" in script code)
  -- command-line-mode/batch-mode
  -- in-place-editing for dupliGroups
  -- support for MLINE (is exported to r12 as BLOCK*Unnamed with LINEs)
@@ -102,17 +101,23 @@
  -- added f_layerFilter
  -- to-check: obj/mat/group/_mapping-idea from ideasman42:
  -- curves: added "fill/non-fill" option for closed curves: CIRCLEs,ELLIPSEs,POLYLINEs
- -- bug:? object = Object.Get(obname) -> = SCENE.getChildren(obname)
  -- "normalize Z" option to correct non-planar figures
  -- LINEs need "width" in 3d-space incl vGroups
  -- support width_force for LINEs/ELLIPSEs = "solidify"
  -- add better support for color_index BYLAYER=256, BYBLOCK=0 
- -- bug: "oneMesh" produces sometimes errors
+ -- bug: "oneMesh" produces irregularly errors
  -- bug: Registry recall from hd_cache ?? only win32 bug??
+ -- support DXF-definitions of scene, lights and cameras
+ -- support ortho mode for VIEWs and VPORTs as cameras 
+ -- add support for SPLINEs
 
+ v1.0.12: 2008.06.05 by migius
+ b3 bugfix: ob.name conflict with existing meshes (different ob.name/mesh.name)
+ v1.0.12: 2008.05.24 by migius
+ b2 added support for LWPOLYLINEs
+ b2 added support for ProE in readerDXF.py
  v1.0.12: 2008.02.08 by migius
- -- support DXF-definitions of scene, lights and cameras
- -- support ortho mode for VIEWs and VPORTs as cameras 
+ b1 update: object = Object.Get(obname) -> f_getSceChild().getChildren()
  a9 bugfix by non-existing tables views, vports, layers (Kai reported)
  v1.0.12: 2008.01.17 by migius
  a8 lately used INI-dir/filename persistently stored in Registry
@@ -279,9 +284,9 @@
 # --------------------------------------------------------------------------
 
 import Blender
-#import bpy
 from Blender import *
 #from Blender.Mathutils import Vector, Matrix
+import bpy
 #import BPyMessages
 
 from dxfReader import readDXF
@@ -313,6 +318,8 @@
 WORLDY = Mathutils.Vector((1,1,0))
 WORLDZ = Mathutils.Vector((0,0,1))
 
+oblist = [] #to be sure, it is an empty list
+
 G_SCALE = 1.0	   #(0.0001-1000) global scaling factor for all dxf data
 G_ORIGIN_X = 0.0   #global translation-vector (x,y,z) in DXF units
 G_ORIGIN_Y = 0.0
@@ -330,6 +337,10 @@
 
 TARGET_LAYER = 3	#target blender_layer
 GROUP_BYLAYER = 0   #(0/1) all entities from same layer import into one blender-group
+cur_COUNTER = 0  #counter for progress_bar
+M_OBJ = False
+BYBLOCK = 0
+BYLAYER = 256
 
 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)
@@ -342,77 +353,8 @@
 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.
-"""
-
-# from Stani's dxf writer v1.1 (c)www.stani.be (GPL)
-#---color values
-BYBLOCK = 0
-BYLAYER = 256
-
-#---block-type flags (bit coded values, may be combined):
-ANONYMOUS		   =1  # This is an anonymous block generated by hatching, associative dimensioning, other internal operations, or an application
-NON_CONSTANT_ATTRIBUTES =2  # This block has non-constant attribute definitions (this bit is not set if the block has any attribute definitions that are constant, or has no attribute definitions at all)
-XREF					=4  # This block is an external reference (xref)
-XREF_OVERLAY			=8  # This block is an xref overlay
-EXTERNAL				=16 # This block is externally dependent
-RESOLVED				=32 # This is a resolved external reference, or dependent of an external reference (ignored on input)
-REFERENCED	  =64 # This definition is a referenced external reference (ignored on input)
-
-#---polyline flags
-CLOSED			  =1  # This is a closed polyline (or a polygon mesh closed in the M direction)
-CURVE_FIT			   =2  # Curve-fit vertices have been added
-SPLINE_FIT		  =4  # Spline-fit vertices have been added
-POLYLINE_3D	 =8   # This is a 3D polyline
-POLYGON_MESH				=16  # This is a 3D polygon mesh
-CLOSED_N					=32  # The polygon mesh is closed in the N direction
-POLYFACE_MESH		   =64   # The polyline is a polyface mesh
-CONTINOUS_LINETYPE_PATTERN  =128	# The linetype pattern is generated continuously around the vertices of this polyline
-
-#---text flags
-#horizontal
-LEFT		= 0
-CENTER  = 1
-RIGHT   = 2
-ALIGNED  = 3 #if vertical alignment = 0
-MIDDLE  = 4 #if vertical alignment = 0
-FIT   = 5 #if vertical alignment = 0
-#vertical
-BASELINE	= 0
-BOTTOM  = 1
-MIDDLE  = 2
-TOP   = 3
-
-#---mtext flags
-#attachment point
-TOP_LEFT		= 1
-TOP_CENTER  = 2
-TOP_RIGHT   = 3
-MIDDLE_LEFT  = 4
-MIDDLE_CENTER   = 5
-MIDDLE_RIGHT	= 6
-BOTTOM_LEFT  = 7
-BOTTOM_CENTER   = 8
-BOTTOM_RIGHT	= 9
-#drawing direction
-LEFT_RIGHT  = 1
-TOP_BOTTOM  = 3
-BY_STYLE		= 5 #the flow direction is inherited from the associated text style
-#line spacing style (optional):
-AT_LEAST		= 1 #taller characters will override
-EXACT	   = 2 #taller characters will not override
-
-
 class View:  #-----------------------------------------------------------------
 	"""Class for objects representing dxf VIEWs.
 	"""
@@ -652,7 +594,15 @@
 	return vec
 
 
+#------------------------------------------
+def getSceneChild(name):
+	dudu = [i for i in SCENE.objects if i.name==name]
+#	dudu = [i for i in SCENE.getChildren() if i.name==name]
+	#print 'deb:getSceneChild %s -result: %s:' %(name,dudu) #-----------------
+	if dudu!=[]: return dudu[0]
+	return None
 
+
 class Solid:  #-----------------------------------------------------------------
 	"""Class for objects representing dxf SOLID or TRACE.
 	"""
@@ -754,16 +704,16 @@
 			if   l == 4: faces = [[0,1,3,2]]
 			elif l == 3: faces = [[0,1,2]]
 			elif l == 2: edges = [[0,1]]
-
-
-
-		me = Mesh.New(obname)		  # create a new mesh
+		
+		if M_OBJ: obname, me, ob = makeNewObject()
+		else: 
+			me = Mesh.New(obname)		# create a new mesh
+			ob = SCENE.objects.new(me) # create a new mesh_object
 		me.verts.extend(points)		# add vertices to mesh
 		if faces: me.faces.extend(faces)		   # add faces to the mesh
 		if edges: me.edges.extend(edges)		   # add faces to the mesh
 
-		ob = SCENE.objects.new(me) # create a new mesh_object
-		if settings.var['vGroup_on']:
+		if settings.var['vGroup_on'] and not M_OBJ:
 			# each MeshSide becomes vertexGroup for easier material assignment ---------------------
 			replace = Blender.Mesh.AssignModes.ADD  #or .AssignModes.ADD/REPLACE
 			if vg_left: me.addVertGroup('side.left')  ; me.assignVertsToGroup('side.left',  vg_left, 1.0, replace)
@@ -777,9 +727,6 @@
 
 		return ob
 
-
-
-
 class Line:  #-----------------------------------------------------------------
 	"""Class for objects representing dxf LINEs.
 	"""
@@ -838,7 +785,7 @@
 		elif settings.var['lines_as'] == 3: # as thin cylinder
 			cyl_rad = 0.5 * settings.var['width_min']
 
-		if settings.var['lines_as'] == 5: # LINE curve representation-------------------------
+		elif settings.var['lines_as'] == 5: # LINE curve representation-------------------------
 			obname = 'li_%s' %self.layer  # create object name from layer name

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list