[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11704] branches/2-44-stable/blender/ release/scripts/import_dxf.py: another update from migius, added batch import, can create new scenes.
Campbell Barton
cbarton at metavr.com
Sun Aug 19 17:22:10 CEST 2007
Revision: 11704
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11704
Author: campbellbarton
Date: 2007-08-19 17:22:10 +0200 (Sun, 19 Aug 2007)
Log Message:
-----------
another update from migius, added batch import, can create new scenes.
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-19 15:14:05 UTC (rev 11703)
+++ branches/2-44-stable/blender/release/scripts/import_dxf.py 2007-08-19 15:22:10 UTC (rev 11704)
@@ -7,7 +7,7 @@
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'
+__version__ = '1.0.beta09 by migius 19.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"]
@@ -75,20 +75,24 @@
-- 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
+ beta09: 19.08.2007 by migius
+ -- redesign UI: grouping of buttons
+ 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: Optimisations Levels, added 'directDrawing'
+ 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
+ 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
@@ -214,7 +218,7 @@
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_DEFAULT_NAME = 'importDXF'
INIFILE_EXTENSION = '.ini'
INIFILE_HEADER = 'ImportDXF.py ver.1.0 config data'
@@ -562,7 +566,7 @@
activObjectLayer = self.layer
#print ('deb:line.draw new line.ob+mesh:"%s" created!' %ob.name) #---------------------
- #if settings.var['width_force']: # todo-----------
+ #if settings.var['width_force']: # -todo-----------
faces, edges = [], []
n = len(me.verts)
@@ -1131,12 +1135,8 @@
ob.LocZ = thic + LocZ
transform(self.extrusion, 0, ob)
- # scaleZ to the thickness
if thic != 0.0:
- #old_LocZ = ob.LocZ
- #ob.LocZ = 0.0
ob.SizeZ *= abs(thic)
- #ob.LocZ = old_LocZ
#print 'deb:polyline2dCurve.draw.END:----------------' #-----
return ob
@@ -1579,7 +1579,7 @@
self.width_factor = getit(obj, 41, 1) # Scaling factor along local x axis
self.oblique = getit(obj, 51, 0) # oblique angle: skew in degrees -90 <= oblique <= 90
- #self.style = getit(obj, 7, 'STANDARD') # todo---- Text style name (optional, default = STANDARD)
+ #self.style = getit(obj, 7, 'STANDARD') # --todo---- Text style name (optional, default = STANDARD)
#Text generation flags (optional, default = 0):
#2 = backward (mirrored in X),
@@ -1870,6 +1870,18 @@
curve.flagU = 1 # Set curve cyclic=closed
c.update()
+ #remi --todo-----to check---------------------------
+ ob = SCENE.objects.new(c) # create a new circle_mesh_object
+ ob.loc = tuple(self.loc)
+ if thic != 0.0: #hack: Blender<2.45 curve-extrusion
+ thic = thic * 0.5
+ c.setExt1(1.0) # curve-extrusion accepts only (0.0 - 2.0)
+ ob.LocZ = thic + self.loc[2]
+ transform(self.extrusion, 0, ob)
+ if thic != 0.0:
+ ob.SizeZ *= abs(thic)
+ return ob
+
else:
if radius < 2 * settings.var['dist_min']: # if circumfence is very small
verts_num = settings.var['thin_res'] # set a fixed number of verts
@@ -1885,10 +1897,10 @@
else:
c = Mesh.Primitives.Circle(int(verts_num), radius*2)
- ob = SCENE.objects.new(c, obname) # create a new circle_mesh_object
- ob.loc = tuple(self.loc)
- transform(self.extrusion, 0, ob)
- return ob
+ ob = SCENE.objects.new(c, obname) # create a new circle_mesh_object
+ ob.loc = tuple(self.loc)
+ transform(self.extrusion, 0, ob)
+ return ob
@@ -1965,6 +1977,18 @@
curve.flagU = 0 # Set curve not cyclic=open
arc.update()
+ #remi --todo-----to check---------------------------
+ ob = SCENE.objects.new(arc) # create a new circle_mesh_object
+ ob.loc = tuple(self.loc)
+ if thic != 0.0: #hack: Blender<2.45 curve-extrusion
+ thic = thic * 0.5
+ arc.setExt1(1.0) # curve-extrusion accepts only (0.0 - 2.0)
+ ob.LocZ = thic + self.loc[2]
+ transform(self.extrusion, 0, ob)
+ if thic != 0.0:
+ ob.SizeZ *= abs(thic)
+ return ob
+
else:
arc = Mesh.New(obname) # create a new mesh
verts, edges = drawArc(None, radius, start, end, settings.var['arc_res'])
@@ -1988,14 +2012,14 @@
arc.verts.extend(verts) # add vertices to mesh
arc.edges.extend(edges) # add edges to the mesh
- ob = SCENE.objects.new(arc) # create a new arc_object
- ob.loc = tuple(center)
- transform(self.extrusion, 0, ob)
- #ob.size = (1,1,1)
+ ob = SCENE.objects.new(arc) # create a new arc_object
+ ob.loc = tuple(center)
+ transform(self.extrusion, 0, ob)
+ #ob.size = (1,1,1)
+
+ return ob
- return ob
-
class BlockRecord: #-----------------------------------------------------------------
"""Class for objects representing dxf block_records.
"""
@@ -2437,7 +2461,7 @@
if type(item) != list and item.type == 'table':
item.data = objectify(item.data) # tables have sub-objects
objects.append(item)
- elif type(item) != list and item.type == 'polyline': #remi todo-----------
+ elif type(item) != list and item.type == 'polyline': #remi --todo-----------
#print 'deb:gosub Polyline\n' #-------------
pline = Polyline(item)
while 1:
@@ -2528,9 +2552,10 @@
global color_map
mat = Material.New('ColorNr-%s' %color)
mat.setRGBCol(color_map[color])
- try:
- mat.setMode('Shadeless', 'Wire') #work-around for 2.45rc-bug
- except: pass
+ mat.mode |= Material.Modes.SHADELESS
+ mat.mode |= Material.Modes.WIRE
+# try: mat.setMode('Shadeless', 'Wire') #work-around for 2.45rc-bug
+# except: pass
self.colMaterials[color] = mat
@@ -2575,9 +2600,10 @@
#print 'deb:MatLayers layer_color: ', color #-----------
global color_map
mat.setRGBCol(color_map[color])
- try:
- mat.setMode('Shadeless', 'Wire') #work-around for 2.45rc-bug
- except: pass
+ mat.mode |= Material.Modes.SHADELESS
+ mat.mode |= Material.Modes.WIRE
+# try: mat.setMode('Shadeless', 'Wire') #work-around for 2.45rc-bug
+# except: pass
self.layMaterials[layername] = mat
@@ -2793,17 +2819,16 @@
-def main(): #---------------#############################-----------
+def main(dxfFile): #---------------#############################-----------
#print 'deb:filename:', filename #--------------
global SCENE
editmode = Window.EditMode() # are we in edit mode? If so ...
if editmode:
Window.EditMode(0) # leave edit mode before
- #SCENE = Scene.GetCurrent()
SCENE = bpy.data.scenes.active
SCENE.objects.selected = [] # deselect all
-
+
global cur_COUNTER #counter for progress_bar
cur_COUNTER = 0
@@ -2831,9 +2856,11 @@
if not settings:
#Draw.PupMenu('DXF importer: EXIT!%t')
print '\nDXF Import: terminated by user!'
+ Window.WaitCursor(False)
+ if editmode: Window.EditMode(1) # and put things back how we fond them
return None
- dxfFile = dxfFileName.val
+ #no more used dxfFile = dxfFileName.val
#print 'deb: dxfFile file: ', dxfFile #----------------------
if dxfFile.lower().endswith('.dxf') and sys.exists(dxfFile):
Window.WaitCursor(True) # Let the user know we are thinking
@@ -2845,6 +2872,8 @@
else:
if UI_MODE: Draw.PupMenu('DXF importer: EXIT----------!%t| no valid DXF-file selected!')
print "DXF importer: error, no DXF-file selected. Abort!"
+ Window.WaitCursor(False)
+ if editmode: Window.EditMode(1) # and put things back how we fond them
return None
settings.validate(drawing)
@@ -2866,14 +2895,18 @@
# Set the visable layers
SCENE.setLayers([i+1 for i in range(18)])
Blender.Redraw(-1)
+
+ time_text = Blender.sys.time() - time2
Window.WaitCursor(False)
- settings.write("Import DXF to Blender: *** DONE ***")
+ message = 'DXF Import to Blender: done in %.4f sec. --------------------' % time_text
settings.progress(1.0/settings.obj_number, 'DXF import done!')
- print 'DXF importer: done in %.4f sec.' % (Blender.sys.time()-time2)
- if UI_MODE: Draw.PupMenu('DXF importer: Done!|finished in %.4f sec.' % (Blender.sys.time()-time2))
+ print message
+ #settings.write(message)
+ if UI_MODE: Draw.PupMenu('DXF importer: Done!|finished in %.4f sec.' % time_text)
finally:
# restore state even if things didn't work
+ #print 'deb:drawEntities finally!' #-----------------------
Window.WaitCursor(False)
if editmode: Window.EditMode(1) # and put things back how we fond them
@@ -3193,9 +3226,10 @@
mat = Material.Get('dxf-neutral')
except:
mat = Material.New('dxf-neutral')
- try:
- mat.setMode('Shadeless', 'Wire') #work-around for 2.45rc-bug
- except: pass
+ mat.mode |= Material.Modes.SHADELESS
+ mat.mode |= Material.Modes.WIRE
+# try:mat.setMode('Shadeless', 'Wire') #work-around for 2.45rc1-bug
+# except: pass
try:
#print 'deb:material mat:', mat #-----------
ob.setMaterials([mat]) #assigns Blender-material to object
@@ -3384,7 +3418,9 @@
EVENT_CHOOSE_DXF = 8
EVENT_HELP = 9
EVENT_CONFIG = 10
-EVENT_PRESET2D = 11
+EVENT_PRESETS = 11
+EVENT_CHOOSE_DIR = 12
+EVENT_PRESET2D = 20
EVENT_EXIT = 100
GUI_EVENT = EVENT_NONE
@@ -3406,7 +3442,8 @@
g_scale_list = "scale factor: %t|x 1000 %x3|x 100 %x2|x 10 %x1|x 1 %x0|x 0.1 %x-1|x 0.01 %x-2|x 0.001 %x-3|x 0.0001 %x-4|x 0.00001 %x-5"
dxfFileName = Draw.Create("")
-iniFileName = Draw.Create(INIFILE_DEFAULT_NAME)
+iniFileName = Draw.Create(INIFILE_DEFAULT_NAME + INIFILE_EXTENSION)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list