python-2.7 - Blender 3D python For Every pose bone add a constraint not working

标签 python-2.7 blender blender-2.61 blender-2.67

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

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

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

最佳答案

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

关于python-2.7 - Blender 3D python For Every pose bone add a constraint not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31026440/

相关文章:

python - 如何减去与Python中不同时间间隔相对应的pandas列?

animation - 是否可以在 WebGL 中导入/处理高级灯光属性 (IES)?

c++ - 在 Blender 中调整工具架和小部件的大小

python - Py2exe 添加包(例如 Carbon)到 exe

python - 在 Anaconda 环境中使用 pip 安装模块

javascript - Three.js 导入 Blender 模型。未捕获的类型错误 : Cannot read property 'x' of undefined

python - 在 blender 中快速添加大量网格图元

animation - blender 中的汽车装备并导入到 Unity

python - Python 打印语句中的语法错误