Skip to content

Commit

Permalink
Fix T58896: Addons with ob.vertex_groups.new without name keywork
Browse files Browse the repository at this point in the history
Original report: OBJ file import fails for objects with vertex groups defined when polygroups option is selected
  • Loading branch information
dfelinto committed Dec 7, 2018
1 parent 259f694 commit ec5d4c9
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion add_advanced_objects_menu/mesh_easylattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def createVertexGroup(obj):
if obj.mode == "EDIT":
bpy.ops.object.editmode_toggle()

group = obj.vertex_groups.new("easy_lattice_group")
group = obj.vertex_groups.new(name="easy_lattice_group")

for vert in vertices:
if vert.select is True:
Expand Down
2 changes: 1 addition & 1 deletion add_advanced_objects_panels/unfold_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def execute(self, context):
b.select = False
b.layers = vis
b.parent = root
vg = obj.vertex_groups.new(b.name)
vg = obj.vertex_groups.new(name=b.name)
vg.add(f.vertices, 1, "ADD")

bpy.ops.object.mode_set()
Expand Down
8 changes: 4 additions & 4 deletions add_curve_sapling/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,9 +821,9 @@ def create_armature(armAnim, leafP, cu, frameRate, leafMesh, leafObj, leafVertSi
# If there are leaves then we need a new vertex group so they will attach to the bone
if not leafAnim:
if (len(levelCount) > 1) and (i >= levelCount[-2]) and leafObj:
leafObj.vertex_groups.new(boneName)
leafObj.vertex_groups.new(name=boneName)
elif (len(levelCount) == 1) and leafObj:
leafObj.vertex_groups.new(boneName)
leafObj.vertex_groups.new(name=boneName)
"""
# If this is first point of the spline then it must be parented to the level above it
if n == 0:
Expand Down Expand Up @@ -997,7 +997,7 @@ def create_armature(armAnim, leafP, cu, frameRate, leafMesh, leafObj, leafVertSi
)

for group in vertexGroups:
leafObj.vertex_groups.new(group)
leafObj.vertex_groups.new(name=group)
leafObj.vertex_groups[group].add(vertexGroups[group], 1.0, 'ADD')

# Now we need the rotation mode to be 'XYZ' to ensure correct rotation
Expand Down Expand Up @@ -1988,7 +1988,7 @@ def addTree(props):
treeMesh.from_pydata(treeVerts, treeEdges, ())

for group in vertexGroups:
treeObj.vertex_groups.new(group)
treeObj.vertex_groups.new(name=group)
treeObj.vertex_groups[group].add(vertexGroups[group], 1.0, 'ADD')

# add armature
Expand Down
6 changes: 3 additions & 3 deletions add_mesh_extra_objects/add_mesh_gears.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,10 @@ def execute(self, context):
# XXX, supporting adding in editmode is move involved
if obj.mode != 'EDIT':
# Create vertex groups from stored vertices.
tipGroup = obj.vertex_groups.new('Tips')
tipGroup = obj.vertex_groups.new(name='Tips')
tipGroup.add(verts_tip, 1.0, 'ADD')

valleyGroup = obj.vertex_groups.new('Valleys')
valleyGroup = obj.vertex_groups.new(name='Valleys')
valleyGroup.add(verts_valley, 1.0, 'ADD')

return {'FINISHED'}
Expand Down Expand Up @@ -790,7 +790,7 @@ def execute(self, context):
# XXX, supporting adding in editmode is move involved
if obj.mode != 'EDIT':
# Create vertex groups from stored vertices.
tipGroup = obj.vertex_groups.new('Tips')
tipGroup = obj.vertex_groups.new(name='Tips')
tipGroup.add(verts_tip, 1.0, 'ADD')

valleyGroup = obj.vertex_groups.new('Valleys')
Expand Down
20 changes: 10 additions & 10 deletions ant_landscape/ant_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,43 +953,43 @@ def execute(self, context):
try:
vg=ob.vertex_groups["rainmap"]
except:
vg=ob.vertex_groups.new("rainmap")
vg=ob.vertex_groups.new(name="rainmap")
try:
vgscree=ob.vertex_groups["scree"]
except:
vgscree=ob.vertex_groups.new("scree")
vgscree=ob.vertex_groups.new(name="scree")
try:
vgavalanced=ob.vertex_groups["avalanced"]
except:
vgavalanced=ob.vertex_groups.new("avalanced")
vgavalanced=ob.vertex_groups.new(name="avalanced")
try:
vgw=ob.vertex_groups["water"]
except:
vgw=ob.vertex_groups.new("water")
vgw=ob.vertex_groups.new(name="water")
try:
vgscour=ob.vertex_groups["scour"]
except:
vgscour=ob.vertex_groups.new("scour")
vgscour=ob.vertex_groups.new(name="scour")
try:
vgdeposit=ob.vertex_groups["deposit"]
except:
vgdeposit=ob.vertex_groups.new("deposit")
vgdeposit=ob.vertex_groups.new(name="deposit")
try:
vgflowrate=ob.vertex_groups["flowrate"]
except:
vgflowrate=ob.vertex_groups.new("flowrate")
vgflowrate=ob.vertex_groups.new(name="flowrate")
try:
vgsediment=ob.vertex_groups["sediment"]
except:
vgsediment=ob.vertex_groups.new("sediment")
vgsediment=ob.vertex_groups.new(name="sediment")
try:
vgsedimentpct=ob.vertex_groups["sedimentpct"]
except:
vgsedimentpct=ob.vertex_groups.new("sedimentpct")
vgsedimentpct=ob.vertex_groups.new(name="sedimentpct")
try:
vgcapacity=ob.vertex_groups["capacity"]
except:
vgcapacity=ob.vertex_groups.new("capacity")
vgcapacity=ob.vertex_groups.new(name="capacity")

g = Grid.fromBlenderMesh(me, vg, self.Ef)

Expand Down
2 changes: 1 addition & 1 deletion io_export_unreal_psk_psa.py
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ def rebuildmesh(obj):

# vertices weight groups
for vgroup in vertGroups:
group = obmesh.vertex_groups.new(vgroup)
group = obmesh.vertex_groups.new(name=vgroup)
for v in vertGroups[vgroup]:
group.add([v[0]], v[1], 'ADD') # group.add(array[vertex id],weight,add)
bpy.context.scene.objects.link(obmesh)
Expand Down
2 changes: 1 addition & 1 deletion io_import_scene_unreal_psa_psk.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ def printlog(strdata):
for bone in ob_new.data.bones:
#print("names:", bone.name, ":", dir(bone))
#print("names:", bone.name)
group = obmesh.vertex_groups.new(bone.name)
group = obmesh.vertex_groups.new(name=bone.name)

for vgroup in obmesh.vertex_groups:
#print(vgroup.name, ":", vgroup.index)
Expand Down
2 changes: 1 addition & 1 deletion io_scene_ms3d/ms3d_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ def create_animation(self, blender_context, ms3d_model, blender_mesh_object):
in ms3d_to_blender_vertex_groups.items():
ms3d_name = ms3d_model.joints[ms3d_bone_id].name
blender_vertex_group = blender_mesh_object.vertex_groups.new(
ms3d_name)
name=ms3d_name)
for blender_vertex_id_weight in blender_vertex_index_weight_list:
blender_vertex_index = blender_vertex_id_weight[0]
blender_vertex_weight = blender_vertex_id_weight[1]
Expand Down
2 changes: 1 addition & 1 deletion io_scene_obj/import_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ def create_mesh(new_objects,
# content of the vertex_groups. If the user selects to NOT have vertex groups saved then
# the following test will never run
for group_name, group_indices in vertex_groups.items():
group = ob.vertex_groups.new(group_name.decode('utf-8', "replace"))
group = ob.vertex_groups.new(name=group_name.decode('utf-8', "replace"))
group.add(group_indices, 1.0, 'REPLACE')


Expand Down
2 changes: 1 addition & 1 deletion mesh_tissue/tessellate_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def tassellate(ob0, ob1, offset, zscale, gen_modifiers, com_modifiers, mode,

# vertex group
if bool_vertex_group:
new_ob.vertex_groups.new("generator_group")
new_ob.vertex_groups.new(name="generator_group")
for i in range(len(new_vertex_group_np)):
new_ob.vertex_groups["generator_group"].add([i],
new_vertex_group_np[i],
Expand Down
2 changes: 1 addition & 1 deletion mesh_tissue/uv_to_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def execute(self, context):
try:
for group in ob0.vertex_groups:
index = group.index
ob.vertex_groups.new(group.name)
ob.vertex_groups.new(name=group.name)
for p in me0.polygons:
for vert, loop in zip(p.vertices, p.loop_indices):
ob.vertex_groups[index].add([loop], group.weight(vert), "ADD")
Expand Down

0 comments on commit ec5d4c9

Please sign in to comment.