[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18358] trunk/blender/release/scripts/ import_web3d.py: string extraction wasnt working + minor changes

Campbell Barton ideasman42 at gmail.com
Tue Jan 6 09:59:12 CET 2009


Revision: 18358
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18358
Author:   campbellbarton
Date:     2009-01-06 09:58:45 +0100 (Tue, 06 Jan 2009)

Log Message:
-----------
string extraction wasnt working + minor changes

Modified Paths:
--------------
    trunk/blender/release/scripts/import_web3d.py

Modified: trunk/blender/release/scripts/import_web3d.py
===================================================================
--- trunk/blender/release/scripts/import_web3d.py	2009-01-06 07:01:41 UTC (rev 18357)
+++ trunk/blender/release/scripts/import_web3d.py	2009-01-06 08:58:45 UTC (rev 18358)
@@ -52,11 +52,11 @@
 
 def imageConvertCompat(path):
 	
-	try:	import os
-	except:
-		return path
+	try:             import os
+	except:          return path
+	if os.sep=='\\': return path # assime win32 has quicktime, dont convert
 	
-	if path.endswith('.gif'):
+	if path.lower().endswith('.gif'):
 		path_to = path[:-3] + 'png'
 		
 		'''
@@ -147,13 +147,12 @@
 					data = data[:start] + data[end:]
 					ok = True # keep looking
 					
-					last_i = end - len(item) + 1
+					last_i = (end - len(item)) + 1
 					# print last_i, item, '|' + data[last_i] + '|'
 		
 	# done with messy extracting strings part
 	
 	
-	
 	# Bad, dont take strings into account
 	'''
 	data = data.replace('#', '\n#')
@@ -175,13 +174,14 @@
 		while ok:
 			ok = False
 			i = data.find(search + '"', last_i)
-			
+			# print i
 			if i != -1:
 				start = i + len(search) # first char after end of search
 				item = string_ls.pop(0)
+				# print item
 				data = data[:start] + item + data[start:]
 				
-				last_i = start + len(item)
+				last_i = start + len(item) + 1
 				
 				ok = True
 	
@@ -918,7 +918,7 @@
 							lines.insert(0, 'root_node____')
 							lines.append('}')
 							'''
-							ff = open('/tmp/test.txt', 'w')
+							ff = open('/root/test.txt', 'w')
 							ff.writelines([l+'\n' for l in lines])
 							'''
 							
@@ -1167,12 +1167,12 @@
 	lines.append('}')
 	# Use for testing our parsed output, so we can check on line numbers.
 	
-	"""
+	
 	ff = open('/tmp/test.txt', 'w')
 	ff.writelines([l+'\n' for l in lines])
 	ff.close()
-	"""
 	
+	
 	# Now evaluate it
 	node_type, new_i = is_nodeline(0, [])
 	if not node_type:
@@ -1908,7 +1908,7 @@
 				ima_url =			ima.getFieldAsString('url', None, ancestry)
 				
 				if ima_url==None:
-					try:		ima_url = ima.getFieldAsStringArray('url', None, ancestry)[0] # in some cases we get a list of images.
+					try:		ima_url = ima.getFieldAsStringArray('url', ancestry)[0] # in some cases we get a list of images.
 					except:		ima_url = None
 				
 				if ima_url==None:
@@ -2137,6 +2137,10 @@
 	bpyob = node.blendObject = bpy.data.scenes.active.objects.new('Empty', name) # , name)
 	bpyob.setMatrix( getFinalMatrix(node, None, ancestry) )
 
+	# so they are not too annoying
+	bpyob.emptyShape= Blender.Object.EmptyShapes.AXES
+	bpyob.drawSize= 0.2
+
 	
 #def importTimeSensor(node):
 
@@ -2332,8 +2336,12 @@
 		prefix = node.getPrefix()
 		if prefix=='PROTO':
 			pass
-		el
+		else
 		'''
+		if HELPER_FUNC and HELPER_FUNC(node, ancestry):
+			# Note, include this function so the VRML/X3D importer can be extended
+			# by an external script. - gets first pick 
+			pass
 		if spec=='Shape':
 			importShape(node, ancestry)
 		elif spec in ('PointLight', 'DirectionalLight', 'SpotLight'):
@@ -2350,15 +2358,9 @@
 			ipo = bpy.data.ipos.new('web3d_ipo', 'Object')
 			translatePositionInterpolator(node, ipo)
 			'''
-			
-		else:
-			# Note, include this function so the VRML/X3D importer can be extended
-			# by an external script.
-			if HELPER_FUNC:
-				HELPER_FUNC(node, ancestry)
-
-
-
+	
+	
+	
 	# After we import all nodes, route events - anim paths
 	for node, ancestry in all_nodes:
 		importRoute(node, ancestry)
@@ -2503,4 +2505,5 @@
 		bpy.data.scenes.active = sce
 		# Window.
 		load_web3d(f, PREF_FLAT=True)
-	
\ No newline at end of file
+	
+





More information about the Bf-blender-cvs mailing list