ジャンプ先: 概要. 戻り値. フラグ. Python 例.

概要

ls( [object [object...]] , [allPaths=boolean], [assemblies=boolean], [cameras=boolean], [containerType=string], [containers=boolean], [dagObjects=boolean], [dependencyNodes=boolean], [exactType=string], [flatten=boolean], [geometry=boolean], [ghost=boolean], [head=int], [hilite=boolean], [intermediateObjects=boolean], [invisible=boolean], [leaf=boolean], [lights=boolean], [live=boolean], [lockedNodes=boolean], [long=boolean], [materials=boolean], [noIntermediate=boolean], [nodeTypes=boolean], [objectsOnly=boolean], [orderedSelection=boolean], [partitions=boolean], [persistentNodes=boolean], [planes=boolean], [preSelectHilite=boolean], [readOnly=boolean], [recursive=boolean], [referencedNodes=boolean], [references=boolean], [renderGlobals=boolean], [renderQualities=boolean], [renderResolutions=boolean], [renderSetups=boolean], [selection=boolean], [sets=boolean], [shapes=boolean], [shortNames=boolean], [showType=boolean], [tail=int], [templated=boolean], [textures=boolean], [transforms=boolean], [type=string], [undeletable=boolean], [untemplated=boolean], [visible=boolean])

注意: オブジェクト名や引数を表す文字列はカンマで区切ります。これは概要には示されていません。

ls は 「元に戻す」が可能、「照会」が不可能「編集」が不可能 です。

ls コマンドでは、シーン内のオブジェクトの名前(およびオプションでタイプ名)が返されます。 ls は一般的に、名前(ワイルドカードを含む)またはタイプに基づいて、オブジェクトのフィルタ処理または突き合せを行うのに使用します。 デフォルトでは ls コマンドはシーン内のすべてのオブジェクトと突き合せを行いますが、-selection フラグを一緒に使用すると、選択したオブジェクトをフィルタリングまたはリスト表示することができます。-showType フラグを使用してタイプ名を要求すると、結果はオブジェクト名を挟んだ <オブジェクト, タイプ> の組み合わせで返されます。 内部ノード(例: itemFilter ノード)は、通常、シーン オブジェクトのみを返すようにフィルタリングされます。 ただし、ワイルドカードを使用すると、ワイルドカードに一致するすべてのノードが内部ノードも含めて表示されてしまいます。 たとえば、ls * の場合、内部ノードかどうかに関係なくすべてのノードがリスト表示されます。 Maya が relativeNames モードにある場合、ls コマンドはカレントのネームスペースに関連する名前を返し、ls * はカレントのネームスペースからリスト表示します。 詳細については、namespace コマンドの -relativeNames フラグを参照してください。

戻り値

string[]

フラグ

allPaths, assemblies, cameras, containerType, containers, dagObjects, dependencyNodes, exactType, flatten, geometry, ghost, head, hilite, intermediateObjects, invisible, leaf, lights, live, lockedNodes, long, materials, noIntermediate, nodeTypes, objectsOnly, orderedSelection, partitions, persistentNodes, planes, preSelectHilite, readOnly, recursive, referencedNodes, references, renderGlobals, renderQualities, renderResolutions, renderSetups, selection, sets, shapes, shortNames, showType, tail, templated, textures, transforms, type, undeletable, untemplated, visible
ロング ネーム(ショート ネーム) 引数型 プロパティ
long(l) boolean create
DAG オブジェクトのフル パス名が返されます。デフォルトでは、最も短い固有の名前を返します。
shortNames(sn) boolean create
アトリビュートのショート ネームが返されます。デフォルトでは、アトリビュートのロング ネームが返されます。
head(hd) int create
項目のリストの先頭から返されるエレメントの最大数を指定します。 注: それぞれの type フラグでは、最大でこの数の項目が返されます。複数の type フラグを指定すると、返される項目の数は、指定した値より多くなります。
tail(tl) int create
項目のリストの末尾から返されるエレメントの最大数を指定します。 注: それぞれの type フラグでは、最大でこの数の項目が返されます。複数の type フラグを指定すると、返される項目の数は、指定した値より多くなります。
type(typ) string createmultiuse
指定したタイプのすべてのオブジェクトがリストされます。このフラグは、コマンド ラインで複数回使用できます。注: このフラグに渡すタイプは、-showType フラグで返されるタイプ名と同じになります。注: Maya での一部の選択項目は、特定オブジェクト/データ タイプが関連しないので、このフラグでリストすると「untyped」が返されます。
このフラグは、-exactType フラグと一緒に使用できません。
exactType(et) string createmultiuse
指定したタイプのオブジェクトをすべてリストします。ただし、そのタイプの下層にあるオブジェクトはリストしません。このフラグは、コマンド ラインで複数回使用できます。注: このフラグに渡すタイプは、-showType フラグで返されるタイプ名と同じになります。
このフラグは、-type フラグと一緒に使用できません。
containerType(ct) string createmultiuse
指定のユーザ定義タイプを伴うリスト コンテナです。
このフラグは、-type または -exactType フラグと一緒に使用できません。
showType(st) boolean create
オブジェクト名の後にタイプがリストされます。
objectsOnly(o) boolean create
設定すると、オブジェクト名のみが返され、コンポーネントやアトリビュートは無視されます。
selection(sl) boolean create
現在選択しているオブジェクトがリストされます。
orderedSelection(os) boolean create
オブジェクトとコンポーネントを現在の選択順でリスト表示します。このフラグは、selectPref コマンドの -tso/trackSelectionOrder フラグの値に依存します。そのフラグが有効になっていなければ、このフラグは -sl/selection フラグと同じものを返します。
live(lv) boolean create
現在ライブにしているオブジェクトがリストされます。
hilite(hl) boolean create
コンポーネント選択で現在ハイライトされているオブジェクトがリストされます。
preSelectHilite(psh) boolean create
プリ選択で現在ハイライトされているコンポーネントがリストされます。
geometry(g) boolean create
ジオメトリ DAG オブジェクトがリストされます。
dependencyNodes(dep) boolean create
ディペンデンシー ノードがリストされます(DAG オブジェクトを含む)。
dagObjects(dag) boolean create
すべてのタイプの DAG オブジェクトがリストされます。オブジェクト名引数をコマンドに渡した場合、このフラグでは、指定したオブジェクトの下にすべての DAG オブジェクトがリストされます。
leaf(lf) boolean create
DAG のすべてのリーフ ノードがリストされます。このフラグはモディファイアなので、-dag フラグと一緒に使用する必要があります。
assemblies(assemblies) boolean create
最上位レベルのトランスフォーム DAG オブジェクトがリストされます。
allPaths(ap) boolean create
DAG 内にあるノードのすべてのパスがリストされます。このフラグは、-dag も指定した場合、またはオブジェクト名を指定した場合に限って動作します。
transforms(tr) boolean create
トランスフォーム オブジェクトがリストされます。
shapes(s) boolean create
シェイプ オブジェクトがリストされます。
lights(lt) boolean create
ライトのシェイプがリストされます。
cameras(ca) boolean create
カメラのシェイプがリストされます。
planes(pl) boolean create
コンストラクション プレーンのシェイプがリストされます。
partitions(pr) boolean create
パーティションがリストされます。
sets(set) boolean create
セットがリストされます。
textures(tex) boolean create
テクスチャがリストされます。
materials(mat) boolean create
マテリアルまたはシェーディング グループがリストされます。
renderQualities(rq) boolean create
指定したレンダー画質がリストされます。
renderResolutions(rr) boolean create
レンダー解像度がリストされます。
renderGlobals(rg) boolean create
レンダー グローバルがリストされます。
renderSetups(rs) boolean create
-renderGlobals のエイリアス。
nodeTypes(nt) boolean create
登録されているすべてのノード タイプがリストされます。
readOnly(ro) boolean create
参照されたノードを返します。参照されたノードは読み取り専用です。 注: 廃止されました。「-referencedNodes」を使用してください。
referencedNodes(rn) boolean create
参照されたノードを返します。参照されたノードは読み取り専用です。
undeletable(ud) boolean create
削除できないノード(ロックされたノードを含む)を返します。削除できないノードは名前の変更もできません。
lockedNodes(ln) boolean create
ロックされたノードを返します。これらのノードは削除も名前の変更もできません。ただし、ステータスは変更できます。
persistentNodes(pn) boolean create
永続ノードを返します。これは「file」 > 「new」の後の Maya セッションでも存続するノードです。
flatten(fl) boolean create
返されるオブジェクトのリストを平らにし、それぞれのコンポーネントを個別に識別できるようにします。
visible(v) boolean create
可視 DAG ノードのみがリストされます。
invisible(iv) boolean create
表示されない DAG ノードのみがリストされます。
intermediateObjects(io) boolean create
中間 DAG ノードのみがリストされます。
noIntermediate(ni) boolean create
中間以外の DAG ノードのみがリストされます。
templated(tm) boolean create
テンプレート化 DAG ノードのみがリストされます。
untemplated(ut) boolean create
テンプレート化が解除された DAG ノードのみがリストされます。
ghost(gh) boolean create
ゴースト化オブジェクトがリストされます。
recursive(r) boolean create
true に設定すると、このコマンドはすべてのネームスペースから合致する名前を探します。false に設定すると、要求されたネームスペースだけから探します(たとえば「:」を含む名前を指定すると 、「ns1:pSphere1」) 。
references(rf) boolean create
ファイルに関連するリファレンスをリストします。sharedReferenceNode や不明リファレンス ノードなどの特別なリファレンス ノードは除外します。
containers(con) boolean create
コンテナをリストします。標準コンテナと dagContainers などの別のコンテナ タイプの 両方を含みます。

: コマンドの作成モードで使用可能なフラグ : コマンドの編集モードで使用可能なフラグ
: コマンドの照会モードで使用可能なフラグ : タプルまたはリストとして渡された複数の引数を持てるフラグ

Python 例

import maya.cmds as cmds

# create some objects to operate on and select them all.
# Note that there are two objects named circle1;
cmds.circle( n='circle1' )
cmds.group()
cmds.circle( n='circle1' )
cmds.sphere( n='sphere1' )
cmds.group()
cmds.instance()
cmds.select( ado=True )

# list all objects
cmds.ls()

# List all selected objects
cmds.ls( selection=True )

# List all hilited objects
cmds.ls( hilite=True )

# List last selected object
cmds.ls( selection=True, tail=1 )

# List all objects named "sphere1". Note that since sphere1 is
# instanced, the command below lists only the first instance.
cmds.ls( 'sphere1' )

# To list all instances of sphere1, use the -ap/allPaths flag.
cmds.ls( 'sphere1', ap=True )

# List all selected objects named "group*"
cmds.ls( 'group*', sl=True )

# List all geometry, lights and cameras in the DAG.
cmds.ls( geometry=True, lights=True, cameras=True )

# List all shapes in the dag.
cmds.ls( shapes=True )

# One thing to note is that it is better to always use the
# -l/long flag when listing nodes without any filter. This is
# because there may be two nodes with the same name (in this
# example, circle1). 'ls' will list the names of all the objects
# in the scene. Objects with the same name need a qualified
# path name which uniquely identifies the object. A command
# to select all objects such as "select `ls`" will fail because
# the object lookup can't resolve which "circle1" object is
# intended. To select all objects, you need the following:
cmds.select(cmds.ls(sl=True))

# When trying to find a list of all objects of a specific
# type, one approach might be to list all objects and then
# use the nodeType command to then filter the list. As in:
allObjects = cmds.ls(l=True)
for obj in allObjects:
   if cmds.nodeType(obj) == 'surfaceShape':
     print obj

# The problem with this is that 'nodeType' returns the
# most derived type of the node. In this example, "surfaceShape"
# is a base type for nurbsSurface so nothing will be printed.
# To do this properly, the -typ/type flag should be used
# to list objects of a specific type as in:
allObjects = cmds.ls(type='surfaceShape')
for obj in allObjects:
    print obj

# List all geometry shapes and their types
cmds.ls( type='geometryShape', showType=True )

# List all paths to all leaf nodes in the DAG
cmds.ls( dag=True, lf=True, ap=True )

# List all nodes below the selected node
cmds.ls( dag=True, ap=True, sl=True )

# List all dag nodes that are read-only (i.e. referenced nodes)
cmds.ls( dag=True, ro=True )

# List all ghosting objects
cmds.ls( ghost=True )

# List reference nodes associated with specific files
cmds.ls( references=True )

# List all reference nodes, including unknown and shared reference nodes
cmds.ls( type='reference' )


# Select some components and then get the list in both selected and numeric order
obj1 = cmds.polySphere( sx=20, sy=20 )
cmds.select( clear=True )

cmds.selectPref( trackSelectionOrder=1 )

cmds.select( obj1[0]+".f[100]" )
cmds.select( (obj1[0]+".f[50:55]"), add=True )
cmds.select( (obj1[0]+".f[0]"), add=True )
cmds.select( (obj1[0]+".f[56:60]"), add=True )

# regular -selection flag returns the components in compacted numeric order.
cmds.ls( selection=True )
# Result:_ [u'pSphere1.f[0]', u'pSphere1.f[50:60]', u'pSphere1.f[100]'] #

# -orderedSelection flag returns the components in the order that we selected them.
cmds.ls( orderedSelection=True )
# Result:_ [u'pSphere1.f[100]', u'pSphere1.f[50:55]', u'pSphere1.f[0]', u'pSphere1.f[56:60]'] #

# turn off tracking when we are done
cmds.selectPref( trackSelectionOrder=0 )