I have made a script for adding VertexWeightMix modifers to a selected mesh. However, when I run the script, it adds tons of modifers, but only changes the first one it adds. How can I fix this? I don't want to apply them immediatly once a modifier is created.
for vertex_b in namelist:
vertex_a = "bone_01D2"
vertexA = bpy.context.object.vertex_groups.get(vertex_a)
vertexB = bpy.context.object.vertex_groups.get(vertex_b)
if vertexA is None:
print("Vertex " + vertex_a + " Does not Exist!")
continue
if vertexB is None:
print("Vertex " + vertex_b + " Does not Exist!")
continue
bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_MIX')
bpy.context.object.modifiers["VertexWeightMix"].vertex_group_a = vertex_a
bpy.context.object.modifiers["VertexWeightMix"].vertex_group_b = vertex_b
bpy.context.object.modifiers["VertexWeightMix"].mix_mode = 'ADD'
bpy.context.object.modifiers["VertexWeightMix"].mix_set = 'B'
Edit: I figured out that if you declare a variable i = 0, then you can convert it to a string, append it to the name, then increase it. However, if I ran it again, it would not work.
obwithm = ob.modifiers.new("name", 'TYPE')set properties on the newly added modifier viam.prop = foo. Please take a look at https://blender.stackexchange.com/a/132861/15543 for an example. Also the last item of a list can be indexed viafoo[-1]– batFINGER Nov 12 '19 at 12:51