2017-09-11 11 views
0

MayaでMELスクリプトを作成しました。だから、ジョイントを選択してから、MELスクリプトを実行してジョイントとそのすべての子を選択します。私はMELがとても新しいので、コードを実行するとエラーが発生します。あなたは私がエラーを減らすのを助けることができますか、それらのすべてを取り除くために良い?Maya - Maya MELで文字のすべての節点を選択

スクリプト:

string $joints[]; 
string $current[] = 'ls -selection'; 

proc selectJoints(){ 
    if ('searchJoints($joints)' == 0){ 
     $joints['size($joints)'] = $current[0]; 
     pickWalk -d down; 
     $current[0] = 'ls -sl'; 
     selectJoints(); 
    } 
    else{ 
     pickWalk -d right; 
     $current[0] = 'ls -sl'; 
     if('searchJoints($joints)' == 0){ 
      selectJoints(); 
     } 
     else{ 
      pickWalk -d up; 
      $current[0] = 'ls -sl'; 
      if($current[0] == $joints[0]){ 
       selectJoints(); 
      } 
     } 
    } 
    return; 
} 

select ($Joints); 

proc int searchJoints (string $jns[]){ 
    int $result = 0; 
    for ($joint in $jns[]){ 
     if ($current[0] == $joint){ 
      return 1; 
     } 
    } 
    return 0; 
} 

ありがとう!

答えて

0

私はあなたの質問がMELについて知っていることを知っています。私はあなたにそれを手伝うことができないことを申し訳なく思っていますが、私はパイソンとピーメルでお手伝いできると思います。

は、スクリプトエディタでPythonのタブでこのコードを試してみてください。

import pymel.core as pm 

# get selected joint 
selectedJoint = pm.selected()[0] 

#get all children from the selected joint and puts it in a list 
joints = selectedJoint.listRelatives(allDescendents = True) 

#adds first selected joint to same list 
joints.append(selectedJoint) 

#clears selection 
pm.select(clear = True) 

#loop thru list of joints 
for item in joints: 
    #toggle selection on selected joint and all its descendents 
    pm.select(item, tgl = True) 

私はなぜMELを使用してわからない、私はpymelで直接起動し、それがより強力なようです。 MELの理由を教えてください... ...私は何かを逃しているかもしれないと思います。とにかく、私はこの短いコードがトリックだと思う。がんばろう!そこにはフェイルセーフがないことに注意してください。そのため、スクリプトを実行する前にジョイントを1つ選択するようにしてください。

関連する問題