Revision: 15937
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15937
Author:   migius
Date:     2008-08-03 17:57:09 +0200 (Sun, 03 Aug 2008)

Log Message:
-----------
DXF-importer script. Works well with 2.46winXP
Please commit to 2.47 branch
patch history:
 v1.12 - 2008.08.03
 c2 warningfix: relocating of globals: layersmap, oblist 
 c2 modif UI: buttons newScene+targetLayer moved to start panel
 v1.12 - 2008.07.04
 c1 added control Curve's OrderU parameter
 c1 modif UI: preset buttons X-2D-3D moved to start panel
 b6 added handling exception of not registered LAYERs (Hammer-HL-editor DXF 
output)
 b5 rebuild UI: global preset 2D for Curve-Import
 b5 added UI-options: PL-MESH N+N plmesh_flip and normals_out 
 b5 added support for SPLINEs, added control OrderU parameter
 b5 rewrote draw module for NURBS_curve and Bezier_curve
 v1.12 - 2008.06.22
 b4 change versioning system 1.0.12 -> 1.12
 b4 print at start version-info to console
 b3 bugfix: ob.name conflict with existing meshes (different ob.name/mesh.name)

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-08-03 15:56:35 UTC (rev 
15936)
+++ trunk/blender/release/scripts/import_dxf.py 2008-08-03 15:57:09 UTC (rev 
15937)
@@ -2,15 +2,15 @@
 
 """
 Name: 'Autodesk DXF (.dxf)'
-Blender: 244
+Blender: 246
 Group: 'Import'
 Tooltip: 'Import for DXF geometry data (Drawing eXchange Format).'
 """
 __author__ = 'Kitsu(Ed Blake) & migius(Remigiusz Fiedler)'
-__version__ = '1.0.12 - 2008.06.05 by migius'
+__version__ = '1.12 - 2008.07.04 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"]
+__email__ = ["migius(at)4d-vectors.de","Kitsune_e(at)yahoo.com"]
 __bpydoc__ = """\
 This script imports objects from DXF (2d/3d) into Blender.
 
@@ -19,7 +19,7 @@
 Enhanced features are:
 - configurable object filtering and geometry manipulation,
 - configurable material pre-processing,
-- DXF-data analyze and raporting.
+- DXF-code analyze and reporting.
 
 Supported DXF r12 objects:
 LINE,
@@ -41,10 +41,10 @@
 
 Supported DXF>r12 objects:
 ELLIPSE,
-LWPOLYLINE (LightWeight Polylines),
-(wip v1.0.12) SPLINE,
-(wip v1.0.13) MLINE,
-(wip v1.0.13) MTEXT
+LWPOLYLINE (LightWeight Polyline),
+SPLINE,
+(wip v1.13) MLINE,
+(wip v1.13) MTEXT
 
 Unsupported objects:
 DXF r12: DIMENSION.
@@ -60,7 +60,7 @@
 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)
+(wip v1.13 import of AVE_RENDER material definitions)
 
 Hierarchy:
 Entire DXF BLOCK hierarchy is preserved after import into Blender
@@ -73,7 +73,7 @@
 width,
 color,
 layer,
-(wip v1.0.12: XDATA, grouped status)
+(wip v1.13: XDATA, grouped status)
 It is recommended to use DXF-object properties for assign Blender materials.
 
 Notes:
@@ -109,9 +109,22 @@
  -- 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
+
+ v1.12 - 2008.08.03 by migius
+ c2 warningfix: relocating of globals: layersmap, oblist 
+ c2 modif UI: buttons newScene+targetLayer moved to start panel
+ v1.12 - 2008.07.04 by migius
+ c1 added control Curve's OrderU parameter
+ c1 modif UI: preset buttons X-2D-3D moved to start panel
+ b6 added handling exception of not registered LAYERs (Hammer-HL-editor DXF 
output)
+ b5 rebuild UI: global preset 2D for Curve-Import
+ b5 added UI-options: PL-MESH N+N plmesh_flip and normals_out 
+ b5 added support for SPLINEs, added control OrderU parameter
+ b5 rewrote draw module for NURBS_curve and Bezier_curve
+ v1.12 - 2008.06.22 by migius
+ b4 change versioning system 1.0.12 -> 1.12
+ b4 print at start version-info to console
  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
@@ -310,16 +323,16 @@
        #print 'psyco not imported'
        pass
 
-print '\n\n\n\n'
-print 'DXF-Importer  *** start ***'   #---------------------
+#try: Curve.orderU
 
+print '\n\n\n'
+print 'DXF-Importer v%s *** start ***' %(__version__)   #---------------------
+
 SCENE = None
 WORLDX = Mathutils.Vector((1,0,0))
 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
@@ -335,12 +348,15 @@
 TRIM_LIMIT = 3.0        #limit for triming of polylines-wide-segments 
(values:0.0 - 5.0)
 ELEVATION = 0.0 #standard elevation = coordinate Z
 
+BYBLOCK = 0
+BYLAYER = 256
 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
+LAYER_DEF_NAME = 'AAAA' #default layer name
+LAYER_DEF_COLOR = 4 #default layer color
+E_M = 0
+LAB = "*) parts under construction"
+M_OBJ = 0
 
 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)
@@ -366,27 +382,27 @@
 
                self.type = obj.type
                self.name = obj.get_type(2)[0]
-               self.data = obj.data[:]
+#              self.data = obj.data[:]
 
 
-               self.centerX = getit(obj.data, 10, 0.0) #view center pointX (in 
DCS)
-               self.centerY = getit(obj.data, 20, 0.0) #view center pointY (in 
DCS)
+               self.centerX = getit(obj, 10, 0.0) #view center pointX (in DCS)
+               self.centerY = getit(obj, 20, 0.0) #view center pointY (in DCS)
                self.height = obj.get_type(40)[0] #view height (in DCS)
                self.width = obj.get_type(41)[0] #view width (in DCS)
 
                self.dir = [0,0,0]
-               self.dir[0] = getit(obj.data, 11, 0.0) #view directionX from 
target (in WCS)
-               self.dir[1] = getit(obj.data, 21, 0.0) #
-               self.dir[2] = getit(obj.data, 31, 0.0) #
+               self.dir[0] = getit(obj, 11, 0.0) #view directionX from target 
(in WCS)
+               self.dir[1] = getit(obj, 21, 0.0) #
+               self.dir[2] = getit(obj, 31, 0.0) #
 
                self.target = [0,0,0]
-               self.target[0] = getit(obj.data, 12, 0.0) #target pointX(in WCS)
-               self.target[1] = getit(obj.data, 22, 0.0) #
-               self.target[2] = getit(obj.data, 32, 0.0) #
+               self.target[0] = getit(obj, 12, 0.0) #target pointX(in WCS)
+               self.target[1] = getit(obj, 22, 0.0) #
+               self.target[2] = getit(obj, 32, 0.0) #
 
                self.length = obj.get_type(42)[0] #Lens length
-               self.clip_front = getit(obj.data, 43) #Front clipping plane 
(offset from target point)
-               self.clip_back = getit(obj.data, 44) #Back clipping plane 
(offset from target point)
+               self.clip_front = getit(obj, 43) #Front clipping plane (offset 
from target point)
+               self.clip_back = getit(obj, 44) #Back clipping plane (offset 
from target point)
                self.twist  = obj.get_type(50)[0] #view twist angle in degrees
 
                self.flags = getit(obj, 70, 0)
@@ -450,28 +466,28 @@
 
                self.type = obj.type
                self.name = obj.get_type(2)[0]
-               self.data = obj.data[:]
+#              self.data = obj.data[:]
                #print 'deb:vport name, data:', self.name #-------
                #print 'deb:vport data:', self.data #-------
 
                self.height = obj.get_type(40)[0] #vport height (in DCS)
-               self.centerX = getit(obj.data, 12, 0.0) #vport center pointX 
(in DCS)
-               self.centerY = getit(obj.data, 22, 0.0) #vport center pointY 
(in DCS)
+               self.centerX = getit(obj, 12, 0.0) #vport center pointX (in DCS)
+               self.centerY = getit(obj, 22, 0.0) #vport center pointY (in DCS)
                self.width = self.height * obj.get_type(41)[0] #vport aspect 
ratio - width (in DCS)
 
                self.dir = [0,0,0]
-               self.dir[0] = getit(obj.data, 16, 0.0) #vport directionX from 
target (in WCS)
-               self.dir[1] = getit(obj.data, 26, 0.0) #
-               self.dir[2] = getit(obj.data, 36, 0.0) #
+               self.dir[0] = getit(obj, 16, 0.0) #vport directionX from target 
(in WCS)
+               self.dir[1] = getit(obj, 26, 0.0) #
+               self.dir[2] = getit(obj, 36, 0.0) #
 
                self.target = [0,0,0]
-               self.target[0] = getit(obj.data, 17, 0.0) #target pointX(in WCS)
-               self.target[1] = getit(obj.data, 27, 0.0) #
-               self.target[2] = getit(obj.data, 37, 0.0) #
+               self.target[0] = getit(obj, 17, 0.0) #target pointX(in WCS)
+               self.target[1] = getit(obj, 27, 0.0) #
+               self.target[2] = getit(obj, 37, 0.0) #
 
                self.length = obj.get_type(42)[0] #Lens length
-               self.clip_front = getit(obj.data, 43) #Front clipping plane 
(offset from target point)
-               self.clip_back = getit(obj.data, 44) #Back clipping plane 
(offset from target point)
+               self.clip_front = getit(obj, 43) #Front clipping plane (offset 
from target point)
+               self.clip_back = getit(obj, 44) #Back clipping plane (offset 
from target point)
                self.twist  = obj.get_type(51)[0] #view twist angle
 
                self.flags = getit(obj, 70, 0)
@@ -528,29 +544,36 @@
        """Class for objects representing dxf LAYERs.
        """
        def __init__(self, obj, name=None, color=None, frozen=None):
-               """Expects an object of type layer as input.
+               """Expects an dxfobject of type layer as input.
+                       if no dxfobject - creates surogate layer with default 
parameters
                """
-               self.type = obj.type
-               self.data = obj.data[:]
 
-               if name:
-                       self.name = name
-                       #self.bfname = name  #--todo---see layernamesmap in 
f_getLayersmap ---
-               else:
-                       self.name = obj.get_type(2)[0] #layer name of object
+               if obj==None:
+                       self.type = 'layer'
+                       if name: self.name = name
+                       else: self.name = LAYER_DEF_NAME
 
-               if color:
-                       self.color = color
-               else:
-                       self.color = obj.get_type(62)[0]  #color of object
+                       if color: self.color = color
+                       else: self.color = LAYER_DEF_COLOR
 
-               if frozen:
-                       self.frozen = frozen
-               else:
-                       self.flags = obj.get_type(70)[0]
-                       self.frozen = self.flags & 1
-
-
+                       if frozen!=None: self.frozen = frozen
+                       else: self.frozen = 0
+               else:   
+                       if obj.type=='layer':
+                               self.type = obj.type
+                               #self.data = obj.data[:]
+                               if name: self.name = name
+                                       #self.bfname = name  #--todo---see 
layernamesmap in f_getLayersmap ---
+                               else: self.name = obj.get_type(2)[0] #layer 
name of object
+               
+                               if color: self.color = color
+                               else: self.color = obj.get_type(62)[0]  #color 
of object
+               
+                               if frozen!=None: self.frozen = frozen
+                               else:
+                                       self.flags = obj.get_type(70)[0]
+                                       self.frozen = self.flags & 1
+       
        def __repr__(self):
                return "%s: name - %s, color - %s" %(self.__class__.__name__, 
self.name, self.color)
 
@@ -615,15 +638,15 @@
                        raise TypeError, "Wrong type \'%s\' for solid/trace 
object!" %obj.type
 
                self.type = obj.type
-               self.data = obj.data[:]
+#              self.data = obj.data[:]
 
                self.space = getit(obj, 67, 0)
                self.thic =  getit(obj, 39, 0)
                self.color_index = getit(obj, 62, BYLAYER)
 
-               self.layer = getit(obj.data, 8, None)
-               self.extrusion = get_extrusion(obj.data)
-               self.points = self.get_points(obj.data)
+               self.layer = getit(obj, 8, None)
+               self.extrusion = get_extrusion(obj)
+               self.points = self.get_points(obj)
 
 
 
@@ -736,16 +759,16 @@
                if not obj.type == 'line':
                        raise TypeError, "Wrong type \'%s\' for line object!" 
%obj.type
                self.type = obj.type
-               self.data = obj.data[:]
+#              self.data = obj.data[:]
 
                self.space = getit(obj, 67, 0)
                self.thic =  getit(obj, 39, 0)

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to