3
        selected = bpy.context.selected_pose_bones
        for bone in selected:
            bpy.ops.pose.constraint_add(type='COPY_ROTATION')

每次我运行它时,同一姿势骨骼上的约束而不是所有姿势骨骼上的约束。

有谁知道如何使它对每个选定的姿势骨骼添加约束。

4

1 回答 1

4

bpy.ops.pose.constraint_add()是仅影响活动项目的运算符,在本例中为姿势骨骼。当您在选择中循环遍历骨骼时,您不会在循环遍历时使用对每个骨骼的引用。

您可以手动在每个特定骨骼上创建约束并随时调整其他参数,而不是使用操作符。

for bone in bpy.context.selected_pose_bones:
    nc = bone.constraints.new(type='COPY_ROTATION')
    nc.target = bpy.data.objects['Armature']
    nc.subtarget = bone.parent
    nc.influence = 0.5
于 2015-06-26T11:35:42.640 回答