コードのおさらい
from maya import cmds
joints = cmds.ls(selection=True)
for joint in joints:
cmds.rename(joint, "{}_baseJoint".format(joint))
cmds.duplicate(rc=True)
joints = cmds.ls(selection=True)
for joint in joints:
target_joint = joint.replace("baseJoint1", "targetJoint")
cmds.rename(joint, target_joint)
joints = cmds.ls(selection=True)
for joint in joints:
circle = cmds.circle(normal=[1,0,0], constructionHistory=False)[0]
circle_shape = cmds.listRelatives(circle, shapes=True)[0]
cmds.parent(circle_shape, joint, relative=True, shape=True)
cmds.delete(circle)
cmds.rename(circle_shape, "{}Shape".format(joint))
joints = cmds.ls(selection=True, dagObjects=True, type="joint")
for joint in joints:
cmds.setAttr("{}.drawStyle".format(joint), 2)
joints = cmds.ls(selection=True, dagObjects=True, type="joint")
for joint in joints:
target_joint = joint.replace("baseJoint", "targetJoint")
for i in "XYZ":
cmds.connectAttr(
"{}.translate{}".format(joint, i),
"{}.translate{}".format(target_joint, i)
)
cmds.connectAttr(
"{}.rotate{}".format(joint, i),
"{}.rotate{}".format(target_joint, i)
)
cmds.connectAttr(
"{}.scale{}".format(joint, i),
"{}.scale{}".format(target_joint, i)
)
Pythonのおすすめ書籍
コメント