[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17477] trunk/blender/release/scripts/ import_dxf.py: DXF-Importer: updated version v1.12 - 2008.11.16 by migius

Remigiusz Fiedler migius at 4d-vectors.de
Mon Nov 17 00:52:31 CET 2008


Revision: 17477
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17477
Author:   migius
Date:     2008-11-17 00:52:29 +0100 (Mon, 17 Nov 2008)

Log Message:
-----------
DXF-Importer: updated version v1.12 - 2008.11.16 by migius
 - remove try_finally: cause not supported in python <2.5
 - add Bezier curves bevel radius support (default 1.0)

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-11-16 21:13:53 UTC (rev 17476)
+++ trunk/blender/release/scripts/import_dxf.py	2008-11-16 23:52:29 UTC (rev 17477)
@@ -7,7 +7,7 @@
 Tooltip: 'Import for DXF geometry data (Drawing eXchange Format).'
 """
 __author__ = 'Kitsu(Ed Blake) & migius(Remigiusz Fiedler)'
-__version__ = '1.12 - 2008.08.03 by migius'
+__version__ = '1.12 - 2008.11.16 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"]
@@ -111,6 +111,9 @@
  -- support ortho mode for VIEWs and VPORTs as cameras 
 
 
+ v1.12 - 2008.11.16 by migius
+ d1 remove try_finally: cause not supported in python <2.5
+ d1 add Bezier curves bevel radius support (default 1.0)
  v1.12 - 2008.08.03 by migius
  c2 warningfix: relocating of globals: layersmap, oblist 
  c2 modif UI: buttons newScene+targetLayer moved to start panel
@@ -299,7 +302,7 @@
 import Blender
 from Blender import *
 #from Blender.Mathutils import Vector, Matrix
-import bpy
+#import bpy #not used yet
 #import BPyMessages
 
 from dxfReader import readDXF
@@ -311,7 +314,7 @@
 
 try:
 	import os
-	if os.name:# != 'mac':
+	if os.name != 'mac':
 		import psyco
 		psyco.log(Blender.Get('tempdir')+"/blender.log-psyco")
 		#psyco.log()
@@ -320,7 +323,7 @@
 		psyco.profile(0.2)
 		#print 'psyco imported'
 except ImportError:
-	#print 'psyco not imported'
+	print 'psyco not imported'
 	pass
 
 #try: Curve.orderU
@@ -346,7 +349,7 @@
 MIN_THICK = MIN_DIST * 10.0  #minimal thickness by forced thickness
 MIN_WIDTH = MIN_DIST * 10.0  #minimal width by forced width
 TRIM_LIMIT = 3.0	 #limit for triming of polylines-wide-segments (values:0.0 - 5.0)
-ELEVATION = 0.0 #standard elevation = coordinate Z
+ELEVATION = 0.0 #standard elevation = coordinate Z value
 
 BYBLOCK = 0
 BYLAYER = 256
@@ -817,6 +820,7 @@
 			curve.append(BezTriple.New(points[1]))
 			for point in curve:
 				point.handleTypes = [VECT, VECT]
+				point.radius = 1.0
 			curve.flagU = 0 # 0 sets the curve not cyclic=open
 			c.setResolu(settings.var['curve_res'])
 			c.update() #important for handles calculation
@@ -1341,9 +1345,11 @@
 				nurbs_points.append(pkt)
 			firstpoint = nurbs_points[0]
 			curve = pline.appendNurb(firstpoint)
-			curve.setType(4) # set curvetype NURBS
+			curve.setType(4) # set curve_type NURBS
+			print 'deb: dir(curve):', dir(curve[-1]) #----------------
 			for point in nurbs_points[1:]:
 				curve.append(point)
+				#TODO: what is the trick for bevel radius? curve[-1].radius = 1.0
 			if self.closed:
 				curve.flagU = 1+0 # Set curve cyclic=close and uni
 			else:
@@ -1359,6 +1365,7 @@
 				curve.append(BezTriple.New(p))
 			for point in curve:
 				point.handleTypes = [AUTO, AUTO]
+				point.radius = 1.0
 			if self.closed:
 				curve.flagU = 1 # Set curve cyclic=close
 			else:
@@ -1380,6 +1387,7 @@
 				curve.append(BezTriple.New(p))
 			for point in curve:
 				point.handleTypes = [AUTO, AUTO]
+				point.radius = 1.0
 			#curve.setType(1) #Bezier curve
 			if self.closed:
 				curve.flagU = 5 #1 # Set curve cyclic=close
@@ -1392,6 +1400,7 @@
 					p0h1 = [p0h1[i]+begtangent[i] for i in range(3)]
 					curve.__setitem__(0,BezTriple.New(p0h1+p0+p0h2))
 				curve[0].handleTypes = [FREE, ALIGN]   #remi--todo-----
+				curve[0].radius = 1.0
 				if endtangent:
 					#print 'deb:polyline2dCurve.draw curve[-1].vec:', curve[-1].vec #-----
 					#print 'deb:polyline2dCurve.draw endtangent:', endtangent #-----
@@ -1401,6 +1410,7 @@
 					curve.__setitem__(-1,BezTriple.New(p0h1+p0+p0h2))
 					#print 'deb:polyline2dCurve.draw curve[-1].vec:', curve[-1].vec #-----
 				curve[-1].handleTypes = [ALIGN, FREE]   #remi--todo-----
+				curve[-1].radius = 1.0
 
 
 
@@ -1420,13 +1430,16 @@
 						if i == 0: curve = pline.appendNurb(BezTriple.New(verts[0]))
 						else: curve.append(BezTriple.New(verts[0]))
 						curve[-1].handleTypes = [VECT, VECT]  #--todo--calculation of bezier-tangents
+						curve[-1].radius = 1.0
 						for p in verts[1:]:
 							curve.append(BezTriple.New(p))
 							curve[-1].handleTypes = [AUTO, AUTO]
+							curve[-1].radius = 1.0
 					else:
 						if i == 0: curve = pline.appendNurb(BezTriple.New(point1.loc))
 						else: curve.append(BezTriple.New(point1.loc))
 						curve[-1].handleTypes = [VECT, VECT]   #--todo--calculation of bezier-tangents
+						curve[-1].radius = 1.0
 
 				elif True:   #----- optimised Bezier-Handles calculation --------------------------------
 					#print 'deb:drawPlineCurve: i:', i #---------
@@ -1446,10 +1459,12 @@
 						if i == 0: curve = pline.appendNurb(BezTriple.New(VectorTriples[0]))
 						else: curve.append(BezTriple.New(VectorTriples[0]))
 						curve[-1].handleTypes = [prevHandleType, FREE]
+						curve[-1].radius = 1.0
 
 						for p in VectorTriples[1:-1]:
 							curve.append(BezTriple.New(p))
 							curve[-1].handleTypes = [FREE, FREE]
+							curve[-1].radius = 1.0
 
 						prevHandleVect = VectorTriples[-1][:3]
 						prevHandleType = FREE
@@ -1462,13 +1477,15 @@
 							curve.append(BezTriple.New(VectorTriples))
 							curve[-1].handleTypes = [FREE, VECT]
 							prevHandleType = VECT
+							curve[-1].radius = 1.0
 						else:
 							if i == 0: curve = pline.appendNurb(BezTriple.New(point1.loc))
 							else: curve.append(BezTriple.New(point1.loc))
 							curve[-1].handleTypes = [VECT, VECT]
-							
+							curve[-1].radius = 1.0
 
 
+
 					#print 'deb:drawPlineCurve: curve[-1].vec[0]', curve[-1].vec[0] #----------
 
 			if self.closed:
@@ -1486,10 +1503,12 @@
 					curve.__setitem__(0,BezTriple.New(p0h1+p0+p0h2))
 
 					curve[0].handleTypes = [FREE,prevHandleType2]
+					curve[0].radius = 1.0
 					#print 'deb:drawPlineCurve:closed curve[0].vec:', curve[0].vec #----------
 					#print 'deb:drawPlineCurve:closed curve[0].handleTypes:', curve[0].handleTypes #----------
 				else: 
 					curve[0].handleTypes[0] = VECT
+					curve[0].radius = 1.0
 			else: 
 				curve.flagU = 0 # Set curve not cyclic=open
 
@@ -2177,9 +2196,10 @@
 		self.ctrlpk_len = getit(obj, 73, 0) # Number of control points
 		self.fit_pk_len = getit(obj, 74, 0) # Number of fit points (if any)
 
+		#TODO: import SPLINE as Bezier curve directly, possible?
 		#print 'deb:Spline self.fit_pk_len=', self.fit_pk_len #------------------------
 		#self.fit_pk_len = 0 # temp for debug
-		if self.fit_pk_len and 'spline_as'==5:
+		if self.fit_pk_len and settings.var['splines_as']==5:
 			self.spline = False
 			self.curved = True
 		else:
@@ -2675,6 +2695,7 @@
 					curve.append(BezTriple.New(p))
 				for point in curve:
 					point.handleTypes = [FREE, FREE]
+					point.radius = 1.0
 			else:	# standard version
 				c = Curve.New(obname)   # create new curve data
 				p1 = (0, -radius, 0)
@@ -2693,6 +2714,7 @@
 				curve.append(p4)
 				for point in curve:
 					point.handleTypes = [AUTO, AUTO]
+					point.radius = 1.0
 
 			curve.flagU = 1	 # 1 sets the curve cyclic=closed
 			if settings.var['fill_on']:
@@ -2893,6 +2915,7 @@
 				curve.append(BezTriple.New(p))
 			for point in curve:
 				point.handleTypes = [FREE, FREE]
+				point.radius = 1.0
 			curve.flagU = 0 # 0 sets the curve not cyclic=open
 			arc.setResolu(settings.var['curve_res'])
 
@@ -3449,6 +3472,7 @@
 					curve.append(BezTriple.New(p))
 				for point in curve:
 					point.handleTypes = [FREE, FREE]
+					point.radius = 1.0
 				curve.flagU = 1 # 0 sets the curve not cyclic=open
 				if settings.var['fill_on']:
 					arc.setFlag(6) # 2+4 set top and button caps
@@ -3459,6 +3483,7 @@
 					curve.append(BezTriple.New(p))
 				for point in curve:
 					point.handleTypes = [FREE, FREE]
+					point.radius = 1.0
 				curve.flagU = 0 # 0 sets the curve not cyclic=open
 
 			arc.setResolu(settings.var['curve_res'])
@@ -4397,8 +4422,7 @@
 		Draw.PupMenu('DXF importer: report saved in INF-file:%t|' + '\'%s\'' %infFile)
 	except:
 		Draw.PupMenu('DXF importer: ERROR by writing report in INF-file:%t|' + '\'%s\'' %infFile)
-	finally:
-		f.close()
+	#finally: f.close()
 
 
 
@@ -4417,7 +4441,8 @@
 	global cur_COUNTER  #counter for progress_bar
 	cur_COUNTER = 0
 
-	try:
+	#try:
+	if 1:
 		#print "Getting settings..."
 		global GUI_A, GUI_B, g_scale_as
 		if not GUI_A['g_scale_on'].val:
@@ -4500,7 +4525,7 @@
 		#settings.write(message)
 		if UI_MODE: Draw.PupMenu('DXF importer:	Done!|finished in %.4f sec.' % time_text)
 
-	finally:
+	#finally:
 		# restore state even if things didn't work
 		#print 'deb:drawEntities finally!' #-----------------------
 		Window.WaitCursor(False)
@@ -5190,6 +5215,7 @@
 	curve.append(p4)
 	for point in curve:
 		point.handleTypes = [AUTO, AUTO]
+		point.radius = 1.0
 	curve.flagU = 1 # Set curve cyclic
 	c.update()
 
@@ -5231,6 +5257,7 @@
 	curve.append(p4)
 	for point in curve:
 		point.handleTypes = [AUTO, AUTO]
+		point.radius = 1.0
 	curve.flagU = 1 # Set curve cyclic
 	a.update()
 
@@ -5270,12 +5297,12 @@
 # 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"
+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"
+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"
+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"
@@ -5456,11 +5483,9 @@
 		else:

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list