This commit is contained in:
Yusarina
2024-12-03 17:40:31 +00:00
parent 7e584e3648
commit 7f9dc20564
2 changed files with 30 additions and 19 deletions
+7 -4
View File
@@ -469,7 +469,7 @@ def transfer_vertex_weights(context: Context, obj: bpy.types.Object, source_grou
modifier = obj.modifiers.new(name="merge_weights", type="VERTEX_WEIGHT_MIX")
modifier.show_viewport = True
modifier.show_render = True
modifier.mix_set = 'B' # Replace weights in A with weights from B
modifier.mix_set = 'B'
modifier.vertex_group_a = target_group
modifier.vertex_group_b = source_group
modifier.mask_constant = 1.0
@@ -482,12 +482,13 @@ def transfer_vertex_weights(context: Context, obj: bpy.types.Object, source_grou
obj.select_set(True)
context.view_layer.objects.active = obj
# Move modifier to the top of the stack if necessary
# Move modifier to the top of the stack
if len(obj.modifiers) > 1:
obj.modifiers.move(obj.modifiers.find(modifier.name), 0)
# Apply modifier
bpy.ops.object.modifier_apply(modifier=modifier.name)
# Apply modifier with correct syntax
with context.temp_override(active_object=obj):
bpy.ops.object.modifier_apply(modifier=modifier.name)
# Clean up
if delete_source_group and source_group in obj.vertex_groups:
@@ -495,3 +496,5 @@ def transfer_vertex_weights(context: Context, obj: bpy.types.Object, source_grou
return True