Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-08-27 03:31:22 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-08-27 03:31:22 +0400
commitd7752e1b50740a81f1196063ee3466be0f2b5150 (patch)
treef4ded7c5c3f80d5878745ae4881b59b630e8153b
parent8d941d5a9d675a9a4ef7700f69a2b59efd6bf7b2 (diff)
update for rna api changes
-rw-r--r--add_mesh_BoltFactory/createMesh.py4
-rw-r--r--add_mesh_pipe_joint.py2
-rw-r--r--io_import_images_as_planes.py4
-rw-r--r--io_import_scene_mhx.py13
-rw-r--r--io_import_scene_unreal_psk.py6
-rw-r--r--io_mesh_raw/import_raw.py19
-rw-r--r--mesh_surface_sketch.py6
7 files changed, 31 insertions, 23 deletions
diff --git a/add_mesh_BoltFactory/createMesh.py b/add_mesh_BoltFactory/createMesh.py
index 3fd892e3..f6562072 100644
--- a/add_mesh_BoltFactory/createMesh.py
+++ b/add_mesh_BoltFactory/createMesh.py
@@ -2085,7 +2085,9 @@ def Create_New_Mesh(props, context, align_matrix):
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))
diff --git a/add_mesh_pipe_joint.py b/add_mesh_pipe_joint.py
index 129acb2b..96c351ad 100644
--- a/add_mesh_pipe_joint.py
+++ b/add_mesh_pipe_joint.py
@@ -68,7 +68,7 @@ v0.9.4 - Creating of the pipe now works in mesh edit mode too.
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.
diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py
index ea652842..e1aa672b 100644
--- a/io_import_images_as_planes.py
+++ b/io_import_images_as_planes.py
@@ -324,7 +324,7 @@ def main(filePath, options, mapping, dimension):
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 @@ def main(filePath, options, mapping, dimension):
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
diff --git a/io_import_scene_mhx.py b/io_import_scene_mhx.py
index b8e54e9b..09ef1fb3 100644
--- a/io_import_scene_mhx.py
+++ b/io_import_scene_mhx.py
@@ -1094,12 +1094,14 @@ def parseMesh (args, tokens):
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 @@ def parseMesh (args, tokens):
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 @@ def parseMesh (args, tokens):
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:
diff --git a/io_import_scene_unreal_psk.py b/io_import_scene_unreal_psk.py
index 7e3a035d..6a04955a 100644
--- a/io_import_scene_unreal_psk.py
+++ b/io_import_scene_unreal_psk.py
@@ -485,7 +485,9 @@ def pskimport(infile):
#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 @@ def pskimport(infile):
#= 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)
#===================================================================================================
#
#===================================================================================================
diff --git a/io_mesh_raw/import_raw.py b/io_mesh_raw/import_raw.py
index e8a7a4a7..850f7002 100644
--- a/io_mesh_raw/import_raw.py
+++ b/io_mesh_raw/import_raw.py
@@ -78,19 +78,22 @@ def readMesh(filename, objName):
# 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))
diff --git a/mesh_surface_sketch.py b/mesh_surface_sketch.py
index 47445743..a7ea84e9 100644
--- a/mesh_surface_sketch.py
+++ b/mesh_surface_sketch.py
@@ -562,19 +562,19 @@ class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator):
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