diff options
Diffstat (limited to 'release/scripts/import_dxf.py')
-rw-r--r-- | release/scripts/import_dxf.py | 87 |
1 files changed, 51 insertions, 36 deletions
diff --git a/release/scripts/import_dxf.py b/release/scripts/import_dxf.py index ceb4dd56722..36a1a048075 100644 --- a/release/scripts/import_dxf.py +++ b/release/scripts/import_dxf.py @@ -2,12 +2,12 @@ """ Name: 'Autodesk DXF (.dxf .dwg)' -Blender: 246 +Blender: 249 Group: 'Import' Tooltip: 'Import for DWG/DXF geometry data.' """ __author__ = 'Kitsu(Ed Blake) & migius(Remigiusz Fiedler)' -__version__ = '1.12 - 2009.04.11 by migius' +__version__ = '1.12 - 2009.05.27 by migius' __url__ = ["http://blenderartists.org/forum/showthread.php?t=84319", "http://wiki.blender.org/index.php/Scripts/Manual/Import/DXF-3D"] __email__ = ["migius(at)4d-vectors.de","Kitsune_e(at)yahoo.com"] @@ -44,8 +44,8 @@ Supported DXF>r12 objects: ELLIPSE, LWPOLYLINE (LightWeight Polyline), SPLINE, -(wip v1.13) MLINE, -(wip v1.13) MTEXT +(todo v1.13) MLINE, +(todo v1.13) MTEXT Unsupported objects: DXF r12: DIMENSION. @@ -74,7 +74,7 @@ thickness, width, color, layer, -(wip v1.13: XDATA, grouped status) +(todo v1.13: XDATA, grouped status) It is recommended to use DXF-object properties for assign Blender materials. Notes: @@ -111,7 +111,11 @@ History: -- support DXF-definitions of scene, lights and cameras -- support ortho mode for VIEWs and VPORTs as cameras - + v1.12 - 2009.05.27 by migius + d6 todo: bugfix negative scaled INSERTs - isLeftHand(Matrix) check + v1.12 - 2009.05.26 by migius + d5 changed to the new 2.49 method Vector.cross() + d5 bugfix WORLDY(1,1,0) to (0,1,0) v1.12 - 2009.04.11 by migius d4 added DWG support, Stani Michiels idea for binding an extern DXF-DWG-converter v1.12 - 2009.03.14 by migius @@ -309,7 +313,7 @@ History: import Blender from Blender import Mathutils, BezTriple, Draw, Registry, sys,\ -Text3d, Window, Mesh, Material, Group +Text3d, Window, Mesh, Material, Group, Curve #from Blender.Mathutils import Vector, Matrix #import bpy #not used yet #import BPyMessages @@ -343,14 +347,12 @@ if os.name != 'mac': except ImportError: print 'psyco not imported' -#try: Curve.orderU - print '\n\n\n' print 'DXF/DWG-Importer v%s *** start ***' %(__version__) #--------------------- SCENE = None WORLDX = Mathutils.Vector((1,0,0)) -WORLDY = Mathutils.Vector((1,1,0)) +WORLDY = Mathutils.Vector((0,1,0)) WORLDZ = Mathutils.Vector((0,0,1)) G_SCALE = 1.0 #(0.0001-1000) global scaling factor for all dxf data @@ -375,7 +377,7 @@ GROUP_BYLAYER = 0 #(0/1) all entities from same layer import into one blender- LAYER_DEF_NAME = 'AAAA' #default layer name LAYER_DEF_COLOR = 4 #default layer color E_M = 0 -LAB = "*) parts under construction" +LAB = ". wip .. todo" #"*) parts under construction" M_OBJ = 0 FILENAME_MAX = 180 #max length of path+file_name string (FILE_MAXDIR + FILE_MAXFILE) @@ -392,7 +394,20 @@ ALIGN = BezTriple.HandleTypes.ALIGN UI_MODE = True #activates UI-popup-print, if not multiple files imported - +#---- migration to 2.49------------------------------------------------- +if 'cross' in dir(Mathutils.Vector()): + #Draw.PupMenu('DXF exporter: Abort%t|This script version works for Blender up 2.49 only!') + def M_CrossVecs(v1,v2): + return v1.cross(v2) #for up2.49 + def M_DotVecs(v1,v2): + return v1.dot(v2) #for up2.49 +else: + def M_CrossVecs(v1,v2): + return Mathutils.CrossVecs(v1,v2) #for pre2.49 + def M_DotVecs(v1,v2): + return Mathutils.DotVecs(v1,v2) #for pre2.49 + + #-------- DWG support ------------------------------------------ extCONV_OK = True extCONV = 'DConvertCon.exe' @@ -2237,7 +2252,6 @@ class LWpolyline(Polyline): #-------------------------------------------------- self.spline = False self.curved = False - #print 'deb:LWpolyline.obj.data:\n', obj.data #------------------------ #print 'deb:LWpolyline.ENDinit:----------------' #------------------------ @@ -4419,11 +4433,11 @@ def getOCS(az): #-------------------------------------------------------------- cap = 0.015625 # square polar cap value (1/64.0) if abs(az.x) < cap and abs(az.y) < cap: - ax = Mathutils.CrossVecs(WORLDY, az) + ax = M_CrossVecs(WORLDY,az) else: - ax = Mathutils.CrossVecs(WORLDZ, az) + ax = M_CrossVecs(WORLDZ,az) ax = ax.normalize() - ay = Mathutils.CrossVecs(az, ax) + ay = M_CrossVecs(az, ax) ay = ay.normalize() return ax, ay, az @@ -5166,17 +5180,17 @@ GUI_B = {} # GUI-buttons dictionary for drawingTypes # settings default, initialize ------------------------ -points_as_menu = "convert to: %t|empty %x1|mesh.vertex %x2|thin sphere %x3|thin box %x4|*curve.vertex %x5" -lines_as_menu = "convert to: %t|*edge %x1|mesh %x2|*thin cylinder %x3|thin box %x4|Bezier-curve %x5|*NURBS-curve %x6" -mlines_as_menu = "convert to: %t|*edge %x1|*mesh %x2|*thin cylinder %x3|*thin box %x|*curve %x5" -plines_as_menu = "convert to: %t|*edge %x1|mesh %x2|*thin cylinder %x3|*thin box %x4|Bezier-curve %x5|NURBS-curve %x6" -splines_as_menu = "convert to: %t|mesh %x2|*thin cylinder %x3|*thin box %x4|*Bezier-curve %x5|NURBS-curve %x6" -plines3_as_menu = "convert to: %t|*edge %x1|mesh %x2|*thin cylinder %x3|*thin box %x4|Bezier-curve %x5|NURBS-curve %x6" -plmesh_as_menu = "convert to: %t|*edge %x1|mesh %x2|*NURBS-surface %x6" -solids_as_menu = "convert to: %t|*edge %x1|mesh %x2" -blocks_as_menu = "convert to: %t|dupliGroup %x1|*real.Group %x2|*exploded %x3" -texts_as_menu = "convert to: %t|text %x1|*mesh %x2|*curve %x5" -material_from_menu= "material from: %t|*LINESTYLE %x7|COLOR %x1|LAYER %x2|*LAYER+COLOR %x3|*BLOCK %x4|*XDATA %x5|*INI-File %x6" +points_as_menu = "convert to: %t|empty %x1|mesh.vertex %x2|thin sphere %x3|thin box %x4|..curve.vertex %x5" +lines_as_menu = "convert to: %t|..edge %x1|mesh %x2|..thin cylinder %x3|thin box %x4|Bezier-curve %x5|..NURBS-curve %x6" +mlines_as_menu = "convert to: %t|..edge %x1|..mesh %x2|..thin cylinder %x3|..thin box %x|..curve %x5" +plines_as_menu = "convert to: %t|..edge %x1|mesh %x2|..thin cylinder %x3|..thin box %x4|Bezier-curve %x5|NURBS-curve %x6" +splines_as_menu = "convert to: %t|mesh %x2|..thin cylinder %x3|..thin box %x4|Bezier-curve %x5|NURBS-curve %x6" +plines3_as_menu = "convert to: %t|..edge %x1|mesh %x2|..thin cylinder %x3|..thin box %x4|Bezier-curve %x5|NURBS-curve %x6" +plmesh_as_menu = "convert to: %t|..edge %x1|mesh %x2|..NURBS-surface %x6" +solids_as_menu = "convert to: %t|..edge %x1|mesh %x2" +blocks_as_menu = "convert to: %t|dupliGroup %x1|..real.Group %x2|..exploded %x3" +texts_as_menu = "convert to: %t|text %x1|..mesh %x2|..curve %x5" +material_from_menu= "material from: %t|..LINESTYLE %x7|COLOR %x1|LAYER %x2|..LAYER+COLOR %x3|..BLOCK %x4|..XDATA %x5|..INI-File %x6" g_scale_list = ''.join(( 'scale factor: %t', '|user def. %x12', @@ -5662,7 +5676,7 @@ def draw_UI(): #--------------------------------------------------------------- y -= 20 Draw.BeginAlign() - GUI_B['mline'] = Draw.Toggle('*MLINE', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['mline'].val, "(*wip)support dxf-MLINE on/off") + GUI_B['mline'] = Draw.Toggle('..MLINE', EVENT_REDRAW, b0, y, b0_, 20, GUI_B['mline'].val, "(*todo)support dxf-MLINE on/off") if GUI_B['mline'].val: GUI_A['mlines_as'] = Draw.Menu(mlines_as_menu, EVENT_NONE, but1c, y, but_1c, 20, GUI_A['mlines_as'].val, "select target Blender-object") Draw.EndAlign() @@ -5713,7 +5727,7 @@ def draw_UI(): #--------------------------------------------------------------- y -= 20 GUI_B['text'] = Draw.Toggle('TEXT', EVENT_NONE, b0, y, b0_, 20, GUI_B['text'].val, "support dxf-TEXT on/off") - GUI_B['mtext'] = Draw.Toggle('*MTEXT', EVENT_NONE, b1, y, b1_, 20, GUI_B['mtext'].val, "(*wip)support dxf-MTEXT on/off") + GUI_B['mtext'] = Draw.Toggle('..MTEXT', EVENT_NONE, b1, y, b1_, 20, GUI_B['mtext'].val, "(*todo)support dxf-MTEXT on/off") # GUI_A['texts_as'] = Draw.Menu(texts_as_menu, EVENT_NONE, but3c, y, but_3c, 20, GUI_A['texts_as'].val, "select target Blender-object") y -= 20 @@ -5732,8 +5746,8 @@ def draw_UI(): #--------------------------------------------------------------- Draw.BeginAlign() GUI_A['views_on'] = Draw.Toggle('views', EVENT_NONE, b0, y, b0_-25, 20, GUI_A['views_on'].val, "imports VIEWs and VIEWPORTs as cameras on/off") - GUI_A['cams_on'] = Draw.Toggle('*cams', EVENT_NONE, b1-25, y, b1_-25, 20, GUI_A['cams_on'].val, "(*wip) support ASHADE cameras on/off") - GUI_A['lights_on'] = Draw.Toggle('*lights', EVENT_NONE, b1+25, y, b1_-25, 20, GUI_A['lights_on'].val, "(*wip) support AVE_RENDER lights on/off") + GUI_A['cams_on'] = Draw.Toggle('..cams', EVENT_NONE, b1-25, y, b1_-25, 20, GUI_A['cams_on'].val, "(*todo) support ASHADE cameras on/off") + GUI_A['lights_on'] = Draw.Toggle('..lights', EVENT_NONE, b1+25, y, b1_-25, 20, GUI_A['lights_on'].val, "(*todo) support AVE_RENDER lights on/off") Draw.EndAlign() @@ -5749,10 +5763,10 @@ def draw_UI(): #--------------------------------------------------------------- Draw.BeginAlign() GUI_A['paper_space_on'] = Draw.Toggle('paper', EVENT_NONE, b0+but_*0, y, but_, 20, GUI_A['paper_space_on'].val, "import only from Paper-Space on/off") GUI_A['layFrozen_on'] = Draw.Toggle ('frozen', EVENT_NONE, b0+but_*1, y, but_, 20, GUI_A['layFrozen_on'].val, "import also from frozen LAYERs on/off") - GUI_A['layerFilter_on'] = Draw.Toggle('layer', EVENT_NONE, b0+but_*2, y, but_, 20, GUI_A['layerFilter_on'].val, "(*wip) LAYER filtering on/off") - GUI_A['colorFilter_on'] = Draw.Toggle('color', EVENT_NONE, b0+but_*3, y, but_, 20, GUI_A['colorFilter_on'].val, "(*wip) COLOR filtering on/off") - GUI_A['groupFilter_on'] = Draw.Toggle('group', EVENT_NONE, b0+but_*4, y, but_, 20, GUI_A['groupFilter_on'].val, "(*wip) GROUP filtering on/off") - GUI_A['blockFilter_on'] = Draw.Toggle('block', EVENT_NONE, b0+but_*5, y, but_, 20, GUI_A['blockFilter_on'].val, "(*wip) BLOCK filtering on/off") + GUI_A['layerFilter_on'] = Draw.Toggle('..layer', EVENT_NONE, b0+but_*2, y, but_, 20, GUI_A['layerFilter_on'].val, "(*todo) LAYER filtering on/off") + GUI_A['colorFilter_on'] = Draw.Toggle('..color', EVENT_NONE, b0+but_*3, y, but_, 20, GUI_A['colorFilter_on'].val, "(*todo) COLOR filtering on/off") + GUI_A['groupFilter_on'] = Draw.Toggle('..group', EVENT_NONE, b0+but_*4, y, but_, 20, GUI_A['groupFilter_on'].val, "(*todo) GROUP filtering on/off") + GUI_A['blockFilter_on'] = Draw.Toggle('..block', EVENT_NONE, b0+but_*5, y, but_, 20, GUI_A['blockFilter_on'].val, "(*todo) BLOCK filtering on/off") #GUI_A['dummy_on'] = Draw.Toggle('-', EVENT_NONE, but3c, y, but_3c, 20, GUI_A['dummy_on'].val, "dummy on/off") Draw.EndAlign() @@ -5853,7 +5867,7 @@ def draw_UI(): #--------------------------------------------------------------- y -= 10 y -= 20 Draw.BeginAlign() - GUI_A['Z_force_on'] = Draw.Toggle('*elevation', EVENT_REDRAW, b0, y, b0_, 20, GUI_A['Z_force_on'].val, "*set objects Z-coordinates to elevation on/off") + GUI_A['Z_force_on'] = Draw.Toggle('.elevation', EVENT_REDRAW, b0, y, b0_, 20, GUI_A['Z_force_on'].val, ".set objects Z-coordinates to elevation on/off") if GUI_A['Z_force_on'].val: GUI_A['Z_elev'] = Draw.Number('', EVENT_NONE, b1, y, b1_, 20, GUI_A['Z_elev'].val, -1000, 1000, "set default elevation(Z-coordinate)") Draw.EndAlign() @@ -6155,6 +6169,7 @@ def multi_import(DIR): if __name__ == "__main__": + #Draw.PupMenu('DXF importer: Abort%t|This script version works for Blender up 2.49 only!') UI_MODE = True # recall last used DXF-file and INI-file names dxffilename = check_RegistryKey('dxfFileName') |