
はじめまして、クリーク・アンド・リバー社 COYOTE CG STUDIO テクニカルチームの好きな武将は斎藤義龍、戦国大好き人間の中林です。
僕自身がMayaのMelから入ってテクニカルアーティストになったので、僕のブログでは主にMelの便利な裏技を紹介します。
設定のリセット
ことの始まりは頼まれたツールで実行すると、僕のMayaでは上手く動くけど、頼んだアーティストのMayaで実行すると処理の結果がずれるとありました。
原因は単純で僕はめったに使わない機能なのでツールの設定はリセット状態だったけど、バリバリ使うアーティストは設定パラメータを変更してました。

単純に考えれば上図の感じでアーティストに「設定のリセット」をしてからツールを使ってもらえば良いのですが、毎回、変えたかも覚えていないツールをリセットするのは非効率でした。
Melでの設定のリセット方法
Mayaのツールでリセットするのはメニューを選ぶだけなので単純ですけど、Melではそもそもどの状態がリセット状態なのか判断が付きません。
そこでペアレントコンストレイントの設定のリセットを例に調べたいと思います。
①ペアレントコンストレイントのMelを探す

設定のリセットをするとスクリプトエディタに
parentConstraintSetup ~
と表示されるので「whatIs parentConstraintSetup」コマンドで辿るとperformParentConstraint.melに行き着きます。
②『setOptionVars』で検索
performParentConstraint.melを適当なテキストツールに読み込んで『setOptionVars』で検索をします。
すると下記の記述でペアレントコンストレイントのパラメータ設定が「optionVar」のみで設定されていることが分かります。
また、これでリセットをしたときのパラメータの状態が分かります。
proc setOptionVars(int $forceFactorySettings)
{
// weight
//
if ($forceFactorySettings || !optionVar -exists parentConstraintWeight
) {
optionVar -floatValue parentConstraintWeight 1.0;
}
// maintain existing offset
//
if ($forceFactorySettings ||
!optionVar -exists parConstMaintainOffset
) {
optionVar -intValue parConstMaintainOffset 1;
}
// rotation decomposition target to maintain existing rotation offset
//
if ($forceFactorySettings ||
!optionVar -exists parConstRotationDecompTarget
) {
optionVar -intValue parConstRotationDecompTarget 0;
}
// constraint axes
//
// ConstraintAxisTranslate
if ($forceFactorySettings ||
!optionVar -exists parentConstraintAxisTranslateX
) {
optionVar -intValue parentConstraintAxisTranslateX true;
}
if ($forceFactorySettings ||
!optionVar -exists parentConstraintAxisTranslateY
) {
optionVar -intValue parentConstraintAxisTranslateY true;
}
if ($forceFactorySettings ||
!optionVar -exists parentConstraintAxisTranslateZ
) {
optionVar -intValue parentConstraintAxisTranslateZ true;
}
// ConstraintAxisRotate
if ($forceFactorySettings ||
!optionVar -exists parentConstraintAxisRotateX
) {
optionVar -intValue parentConstraintAxisRotateX true;
}
if ($forceFactorySettings ||
!optionVar -exists parentConstraintAxisRotateY
) {
optionVar -intValue parentConstraintAxisRotateY true;
}
if ($forceFactorySettings ||
!optionVar -exists parentConstraintAxisRotateZ
) {
optionVar -intValue parentConstraintAxisRotateZ true;
}
// AnimLayer
if ($forceFactorySettings ||
!optionVar -exists constraintAnimLayer
) {
optionVar -stringValue constraintAnimLayer "";
}
if ($forceFactorySettings ||
!optionVar -exists parentConstraintAnimLayerToOverride
) {
optionVar -intValue parentConstraintAnimLayerToOverride true;
}
}
③全ての「optionVar」でリセット
ここから「optionVar」で始まる部分を全てコピペすればペアレントコンストレイントの「設定のリセット」をしたのと同じ状態になります。
設定している「optionVar」は全て分かるので作業に合った設定にすることも可能です。
多くの設定のリセットは『setOptionVars』
ここで重要なのは多くのツールの「設定のリセット」は『setOptionVars』プロシージャでおこなっていることです。
グラフエディタでも、アレンビックのインポートでも、ターゲットシェイプのミラーでも全ての「設定のリセット」で同じです。
そして、リセットをしているということは、そのツールで使っている全パラメータの「optionVar」プロシージャ内で知ることができることです。
『setOptionVars』とテキストエディタのgrep検索などを活用すれば、様々なツールのパラメータ情報を簡単に見つけることもできます。
ツールの設定を調べるには『setOptionVars』は便利な裏技なので試してみてください。