[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [951] trunk/py/scripts/addons: update for rna api changes

Campbell Barton ideasman42 at gmail.com
Fri Aug 27 01:31:22 CEST 2010


Revision: 951
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=951
Author:   campbellbarton
Date:     2010-08-27 01:31:22 +0200 (Fri, 27 Aug 2010)

Log Message:
-----------
update for rna api changes

Modified Paths:
--------------
    trunk/py/scripts/addons/add_mesh_BoltFactory/createMesh.py
    trunk/py/scripts/addons/add_mesh_BoltFactory/original_script_add_mesh_bolt.py
    trunk/py/scripts/addons/add_mesh_pipe_joint.py
    trunk/py/scripts/addons/io_import_images_as_planes.py
    trunk/py/scripts/addons/io_import_scene_mhx.py
    trunk/py/scripts/addons/io_import_scene_unreal_psk.py
    trunk/py/scripts/addons/io_mesh_raw/import_raw.py
    trunk/py/scripts/addons/mesh_surface_sketch.py

Modified: trunk/py/scripts/addons/add_mesh_BoltFactory/createMesh.py
===================================================================
--- trunk/py/scripts/addons/add_mesh_BoltFactory/createMesh.py	2010-08-26 23:16:54 UTC (rev 950)
+++ trunk/py/scripts/addons/add_mesh_BoltFactory/createMesh.py	2010-08-26 23:31:22 UTC (rev 951)
@@ -2085,7 +2085,9 @@
     
     mesh = bpy.data.meshes.new(sMeshName)
     
-    mesh.add_geometry((len(verts)), 0, int(len(faces)))
+    mesh.vertices.add(len(verts))
+    mesh.faces.add(len(faces))
+
     mesh.vertices.foreach_set("co", unpack_list(verts))
     mesh.faces.foreach_set("vertices_raw", unpack_face_list(faces))
 

Modified: trunk/py/scripts/addons/add_mesh_BoltFactory/original_script_add_mesh_bolt.py
===================================================================
--- trunk/py/scripts/addons/add_mesh_BoltFactory/original_script_add_mesh_bolt.py	2010-08-26 23:16:54 UTC (rev 950)
+++ trunk/py/scripts/addons/add_mesh_BoltFactory/original_script_add_mesh_bolt.py	2010-08-26 23:31:22 UTC (rev 951)
@@ -2485,7 +2485,9 @@
     
     mesh = bpy.data.meshes.new(sMeshName)
     
-    mesh.add_geometry((len(verts)), 0, int(len(faces)))
+    mesh.vertices.add(len(verts))
+    mesh.faces.add(len(faces))
+
     mesh.vertices.foreach_set("co", unpack_list(verts))
     mesh.faces.foreach_set("vertices_raw", unpack_face_list(faces))
 

Modified: trunk/py/scripts/addons/add_mesh_pipe_joint.py
===================================================================
--- trunk/py/scripts/addons/add_mesh_pipe_joint.py	2010-08-26 23:16:54 UTC (rev 950)
+++ trunk/py/scripts/addons/add_mesh_pipe_joint.py	2010-08-26 23:31:22 UTC (rev 951)
@@ -68,7 +68,7 @@
     Thanks to ideasman42 (Campbell Barton) for his nice work
     on the torus script code :-).
 v0.9.3 - Changed to a saner vertex/polygon creation process (previously
-    my usage of add_geometry could only do quads)
+    my usage of mesh.faces.add could only do quads)
     For this I've copied the functions unpack_list and unpack_face_list
     from import_scene_obj.py.
     Elbow joint actually supports 3 vertices per circle.

Modified: trunk/py/scripts/addons/io_import_images_as_planes.py
===================================================================
--- trunk/py/scripts/addons/io_import_images_as_planes.py	2010-08-26 23:16:54 UTC (rev 950)
+++ trunk/py/scripts/addons/io_import_images_as_planes.py	2010-08-26 23:31:22 UTC (rev 951)
@@ -324,7 +324,7 @@
             plane = createPlaneObj(img, dimension)
 
             # Assign Material
-            plane.data.add_material(mat)
+            plane.data.materials.link(mat)
 
             # Put Image into  UVTextureLayer
             plane.data.uv_textures[0].data[0].image = img
@@ -353,7 +353,7 @@
         plane = createPlaneObj(img, dimension)
 
         # Assign Material
-        plane.data.add_material(mat)
+        plane.data.materials.link(mat)
 
         # Put image into UVTextureLayer
         plane.data.uv_textures[0].data[0].image = img

Modified: trunk/py/scripts/addons/io_import_scene_mhx.py
===================================================================
--- trunk/py/scripts/addons/io_import_scene_mhx.py	2010-08-26 23:16:54 UTC (rev 950)
+++ trunk/py/scripts/addons/io_import_scene_mhx.py	2010-08-26 23:31:22 UTC (rev 951)
@@ -1094,12 +1094,14 @@
 
 	if faces:
 		#x = me.from_pydata(verts, [], faces)
-		me.add_geometry(len(verts), 0, len(faces))
+		me.vertices.add(len(verts))
+		me.faces.add(len(faces))
 		me.vertices.foreach_set("co", unpackList(verts))
 		me.faces.foreach_set("vertices_raw", unpackList(faces))
 	else:
 		#x = me.from_pydata(verts, edges, [])
-		me.add_geometry(len(verts), len(edges), 0)
+		me.vertices.add(len(verts))
+		me.edges.add(len(edges))
 		me.vertices.foreach_set("co", unpackList(verts))
 		me.edges.foreach_set("vertices", unpackList(edges))
 	#print(x)
@@ -1109,9 +1111,8 @@
 		
 	mats = []
 	for (key, val, sub) in tokens:
-		if key == 'Verts' or \
-		   key == 'Edges':
-				pass
+		if key in ('Verts', 'Edges'):
+			pass
 		elif key == 'Faces':
 			parseFaces2(sub, me)
 		elif key == 'MeshTextureFaceLayer':
@@ -1124,7 +1125,7 @@
 			parseShapeKeys(ob, me, val, sub)
 		elif key == 'Material':
 			try:
-				me.add_material(loadedData['Material'][val[0]])
+				me.materials.link(loadedData['Material'][val[0]])
 			except:
 				print("Could not add material", val[0])
 		else:

Modified: trunk/py/scripts/addons/io_import_scene_unreal_psk.py
===================================================================
--- trunk/py/scripts/addons/io_import_scene_unreal_psk.py	2010-08-26 23:16:54 UTC (rev 950)
+++ trunk/py/scripts/addons/io_import_scene_unreal_psk.py	2010-08-26 23:31:22 UTC (rev 951)
@@ -485,7 +485,9 @@
 	#Building Mesh
 	#================================================================================================== 
 	print("vertex:",len(verts),"faces:",len(faces))
-	me_ob.add_geometry(len(verts), 0, int(len(faces)/4))
+	me_ob.vertices.add(len(verts))
+	me_ob.faces.add(len(faces)//4)
+
 	me_ob.vertices.foreach_set("co", unpack_list(verts))
 	
 	me_ob.faces.foreach_set("vertices_raw", faces)
@@ -535,7 +537,7 @@
 	#= make sure the list isnt too big
 	for material in materials:
 		#add material to the mesh list of materials
-		me_ob.add_material(material)
+		me_ob.materials.link(material)
 	#===================================================================================================
 	#
 	#===================================================================================================

Modified: trunk/py/scripts/addons/io_mesh_raw/import_raw.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_raw/import_raw.py	2010-08-26 23:16:54 UTC (rev 950)
+++ trunk/py/scripts/addons/io_mesh_raw/import_raw.py	2010-08-26 23:31:22 UTC (rev 951)
@@ -78,19 +78,22 @@
     # Generate verts and faces lists, without duplicates
     verts = []
     coords = {}
-    index = 0
-
+    index_tot = 0
+    
     for f in faces:
         for i, v in enumerate(f):
-            try:
-                f[i] = coords[v]
-            except:
-                f[i] = coords[v] = index
-                index += 1
+            index = coords.get(v)
+
+            if index is None:
+                index = coords[v] = index_tot
+                index_tot += 1
                 verts.append(v)
 
+            fi[i] = index
+
     mesh = bpy.data.meshes.new(objName)
-    mesh.add_geometry(int(len(verts)), 0, int(len(faces)))
+    mesh.vertices.add(len(verts))
+    mesh.faces.add(len(faces))
     mesh.vertices.foreach_set("co", unpack_list(verts))
     mesh.faces.foreach_set("vertices_raw", unpack_face_list(faces))
 

Modified: trunk/py/scripts/addons/mesh_surface_sketch.py
===================================================================
--- trunk/py/scripts/addons/mesh_surface_sketch.py	2010-08-26 23:16:54 UTC (rev 950)
+++ trunk/py/scripts/addons/mesh_surface_sketch.py	2010-08-26 23:31:22 UTC (rev 951)
@@ -562,19 +562,19 @@
             vert_num_in_spline = 1
             
             if selection_U_exists:
-                ob_ctrl_pts.data.add_geometry(1,0,0)
+                ob_ctrl_pts.data.vertices.add(1)
                 last_v = ob_ctrl_pts.data.vertices[len(ob_ctrl_pts.data.vertices) - 1]
                 last_v.co = verts_ordered_U[i].co
                 
                 vert_num_in_spline += 1
                 
             for sp in sketched_splines_parsed:
-                ob_ctrl_pts.data.add_geometry(1,0,0)
+                ob_ctrl_pts.data.vertices.add(1)
                 v = ob_ctrl_pts.data.vertices[len(ob_ctrl_pts.data.vertices) - 1]
                 v.co = sp[i]
                 
                 if vert_num_in_spline > 1:
-                    ob_ctrl_pts.data.add_geometry(0,1,0)
+                    ob_ctrl_pts.data.edges.add(1)
                     ob_ctrl_pts.data.edges[len(ob_ctrl_pts.data.edges) - 1].vertices[0] = len(ob_ctrl_pts.data.vertices) - 2
                     ob_ctrl_pts.data.edges[len(ob_ctrl_pts.data.edges) - 1].vertices[1] = len(ob_ctrl_pts.data.vertices) - 1
 




More information about the Bf-extensions-cvs mailing list