[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19913] trunk/blender/release/scripts/ bpymodules/paths_svg2obj.py: patch for paths_svg2obj.py by author J.M.Soler :

Remigiusz Fiedler migius at 4d-vectors.de
Fri Apr 24 01:44:43 CEST 2009


Revision: 19913
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19913
Author:   migius
Date:     2009-04-24 01:44:43 +0200 (Fri, 24 Apr 2009)

Log Message:
-----------
patch for paths_svg2obj.py by author J.M.Soler:
http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_import_svg_en.htm
This patch adds support for Patterns.

Modified Paths:
--------------
    trunk/blender/release/scripts/bpymodules/paths_svg2obj.py

Modified: trunk/blender/release/scripts/bpymodules/paths_svg2obj.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/paths_svg2obj.py	2009-04-23 21:57:41 UTC (rev 19912)
+++ trunk/blender/release/scripts/bpymodules/paths_svg2obj.py	2009-04-23 23:44:43 UTC (rev 19913)
@@ -1,7 +1,7 @@
 # -*- coding: latin-1 -*-
 """
-SVG 2 OBJ translater, 0.5.9n
-Copyright (c) jm soler juillet/novembre 2004-february 2009, 
+SVG 2 OBJ translater, 0.5.9o
+Copyright (c) jm soler juillet/novembre 2004-april 2009, 
 # ---------------------------------------------------------------
     released under GNU Licence 
     for the Blender 2.42 Python Scripts Bundle.
@@ -255,7 +255,7 @@
               - removed  all debug statements
               - correction of a zero division error in the calc_arc function.
 
-		  0.5.9f: - 2007/15/7 
+     0.5.9f: - 2007/15/7 
               - Correction de plusieurs bugs sur l'attributions des couleurs et le nommage 
                 des courbes
 
@@ -266,7 +266,9 @@
      0.5.9k : - 14/01/2009 
      0.5.9l : - 31/01/2009 
      0.5.9n : - 01/02/2009
+     0.5.9o : - 04/04/2009, remove pattern if it made with path.
 
+
 ==================================================================================   
 =================================================================================="""
 SHARP_IMPORT=0
@@ -280,6 +282,7 @@
 LAST_COLOR=[0.0,0.0,0.0,0.0]
 SEPARATE_CURVES=0
 USE_COLORS=0
+PATTERN=0
 
 SVGCOLORNAMELIST={ 'aliceblue':[240, 248, 255] ,'antiquewhite':[250, 235, 215]
 ,'aqua':[ 0, 255, 255], 'aquamarine':[127, 255, 212]
@@ -787,6 +790,7 @@
 		D.append('Z')
 	return D
 
+
 #--------------------
 # 0.5.8, to remove exec 
 #--------------------
@@ -1462,13 +1466,13 @@
 # --------------------------------------------
 def build_HIERARCHY(t):
 	global CP, curves, SCALE, DEBUG, BOUNDINGBOX, scale_, tagTRANSFORM
-	global LAST_ID
+	global LAST_ID, PATTERN
 	TRANSFORM=0
 	t=t.replace('\t',' ')
 	while t.find('  ')!=-1: t=t.replace('  ',' ')
 	n0=0      
 	t0=t1=0
-	baliste=[]
+	#baliste=[]
 	balisetype=['?','?','/','/','!','!']
 	BALISES=['D',  #DECL_TEXTE',
 						'D',  #DECL_TEXTE',
@@ -1490,26 +1494,37 @@
 		if t0>-1 and t1>-1:
 			if t[t0+1] in balisetype:
 				b=balisetype.index(t[t0+1])
+				
 				if t[t0+2]=='-': 
 					b=balisetype.index(t[t0+1])+1
+					
 				balise=BALISES[b]
+				
 				if b==2:
 					parent=STACK.pop(-1)
 					if parent!=None and TRANSFORM>0:
 						TRANSFORM-=1
+						
 			elif t[t1-1] in balisetype:
 				balise=BALISES[balisetype.index(t[t1-1])+1]
+				
 			else:
 				t2=t.find(' ',t0)  
 				if t2>t1: t2=t1
 				ouvrante=1
 				NOM=t[t0+1:t2]
+				
+					
 				if '</'+NOM in t: #.find('</'+NOM)>-1:
 					balise=BALISES[-1]
+					if NOM=='pattern' and not PATTERN:
+						t1=t.find('</'+NOM+'>',t0)+len('</'+NOM+'>')
+						balise=BALISES[-3]
 				else:
 					balise=BALISES[-2]
 					
 			if balise=='E' or balise=='O':
+					
 				proprietes=collect_ATTRIBUTS(t[t0:t1+ouvrante])
 				
 				if  'id' in proprietes:
@@ -1532,6 +1547,11 @@
 					# 0.5.8, to remove exec 
 					#--------------------
 					D=OTHERSSHAPES[proprietes['TYPE']](proprietes)
+					
+				#elif proprietes['TYPE'] in ['pattern']:
+				#	print 'pattern'	
+				#	D=''
+					
 				CP=[0.0,0.0]	
 				if len(D)>0:
 					cursor=0
@@ -1567,7 +1587,7 @@
 
 def scan_FILE(nom):
 	global CP, curves, SCALE, DEBUG, BOUNDINGBOX, scale_, tagTRANSFORM
-	global SEPARATE_CURVES, USE_COLORS
+	global SEPARATE_CURVES, USE_COLORS, PATTERN
 	
 	dir,name=split(nom)
 	name=name.split('.')
@@ -1583,13 +1603,14 @@
 			togAS = Blender.Draw.Create(0)
 			togSP = Blender.Draw.Create(0)
 			togCOL = Blender.Draw.Create(0)
+			Pattern= Blender.Draw.Create(0)
 			block=[\
 				("Clamp Width 1",	togW,  "Rescale the import with a Width of one unit"),\
 				("Clamp Height 1",	togH,  "Rescale the import with a Heightof one unit"),\
 				("No Rescaling",	togAS, "No rescaling, the result can be very large"),\
 				("Separate Curves", togSP, "Create an object for each curve, Slower. May manage colors"),\
-				("Import Colors",	togCOL, "try to import color if the path is set as 'fill'. Only With separate option")]
-
+				("Import Colors",	togCOL, "try to import color if the path is set as 'fill'. Only With separate option"),\
+ 				("Import Patterns",	Pattern, "import pattern content if it is made with paths.")]
 			retval = Blender.Draw.PupBlock("Import Options", block)
 			if  togW.val: scale_=1
 			elif togH.val: 	scale_=2
@@ -1598,6 +1619,8 @@
 			if  togSP.val: SEPARATE_CURVES=1	
 
 			if  togCOL.val and SEPARATE_CURVES : USE_COLORS=1	
+				
+			if	Pattern.val : PATTERN =1
 											
 		t1=Blender.sys.time()
 		# 0.4.1 : to avoid to use sax and the xml  
@@ -1625,4 +1648,4 @@
 
 
 if __name__=='__main__':
-	Blender.Window.FileSelector (functionSELECT, 'SELECT an .SVG FILE', '*.svg')
+	Blender.Window.FileSelector (functionSELECT, 'SELECT an .SVG FILE', '*.svg')
\ No newline at end of file





More information about the Bf-blender-cvs mailing list