Mayaで末端のジョイントの方向修正スクリプト
ジョイントの方向修正でツールがデフォルトであるけど(Skelton/OrientJointOption)
末端が反映されないのでつくりました。
使い方は、末端のジョイントを選択してスクリプト実行するだけ。
Pythonで実行してください。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding : utf-8 | |
####################################### | |
## 末端のジョイントの方向をキレイにする | |
####################################### | |
# dekapoppoScript | |
# 2017.3.24 v0.1 | |
# | |
# USE: | |
# 1.Select End Joints | |
# 2.Run Script | |
# | |
# | |
import maya.cmds as mc | |
# 方向を修正したいジョイント選択、複数可(末端のみ)でリスト化 | |
selJoint = mc.ls(sl=True) | |
# 1つずつ方向修正作業 | |
for i in selJoint: | |
# 選択したジョイントのTranslate、Radiusを取得して格納 | |
jPos = [ mc.getAttr(i+".tx"),mc.getAttr(i+".ty"),mc.getAttr(i+".tz")] | |
jRadius = mc.getAttr(i+".radius") | |
# 親のジョイントからのインサートジョイント実行 | |
parentJoint = mc.listRelatives(i,p=True) | |
newJoint = mc.insertJoint(parentJoint) | |
mc.setAttr(newJoint+".tx",jPos[0]) | |
mc.setAttr(newJoint+".ty",jPos[1]) | |
mc.setAttr(newJoint+".tz",jPos[2]) | |
mc.setAttr(newJoint+".radius",jRadius) | |
mc.delete(i) | |
mc.rename(newJoint,i) | |
mc.select(selJoint) |
0 コメント:
コメントを投稿