とあるゲームプログラマの挑戦と敗北の歴史

UE4とプログラミングとmayaとpythonとhtmlとマラソンを中心に情報を発信する元「技術ブログを目指すブログ」から再始動した毎日の日々を発信するブログです。

maya:ls listRelatives を利用した選択中メッシュのリスト

選択中のメッシュをリストする手順を明記しておく

(親グループにはいていても使用可能)

 

1.メッシュを選択(親グループを選択してしまっていたも おけ)

f:id:toncrimentan_w:20200304235259j:plain

 

2.選択中メッシュのリストを表示

  ※グループを選択しているときのためにlistRelativesを利用し子メッシュを取得

  ※処理が終わったら選択リストを復帰してあげる処理付き

import maya.cmds as cmds

#選択リストの取得
selections = cmds.ls( selection=1 )

#選択リストのメッシュを表示
for select in selections:
    childs = cmds.listRelatives( select, children=TrueallDescendents=Truetype='mesh' )
    for child in childs:
        print( child )

#選択リストの復帰
cmds.select( selections, replace=1 )

 

3.選択中のメッシュがリストされる。

f:id:toncrimentan_w:20200304235714j:plain