Skip to content

Instantly share code, notes, and snippets.

@dzava
Created May 13, 2018 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dzava/ec38ed46a045728c6204a1d3e45ba55a to your computer and use it in GitHub Desktop.
Save dzava/ec38ed46a045728c6204a1d3e45ba55a to your computer and use it in GitHub Desktop.
import bpy
context = bpy.context
scene = context.scene
def bones():
active = context.active_pose_bone
if active is context.selected_pose_bones[0]:
return [active, context.selected_pose_bones[1]]
return [active, context.selected_pose_bones[0]]
def addRotationConstraint():
[target, subtarget] = bones()
crc = target.constraints.new('COPY_ROTATION')
crc.target = context.selected_objects[0]
crc.subtarget = subtarget.name
crc.use_y = False
crc.use_z = False
crc.use_offset = True
crc.owner_space = "LOCAL"
crc.target_space = "LOCAL"
def lockRotation():
for b in context.selected_pose_bones:
b.lock_rotation[1] = True
b.lock_rotation[2] = True
lockRotation()
#addRotationConstraint()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment