Go to: Synopsis. Return value. Flags. MEL examples.
ls [-absoluteName] [-allPaths] [-assemblies] [-cameras] [-containerType string] [-containers] [-dagObjects] [-defaultNodes] [-dependencyNodes] [-exactType string] [-excludeType string] [-flatten] [-geometry] [-ghost] [-head int] [-hilite] [-intermediateObjects] [-invisible] [-leaf] [-lights] [-live] [-lockedNodes] [-long] [-materials] [-modified] [-noIntermediate] [-nodeTypes] [-objectsOnly] [-orderedSelection] [-partitions] [-persistentNodes] [-planes] [-preSelectHilite] [-readOnly] [-recursive boolean] [-referencedNodes] [-references] [-renderGlobals] [-renderQualities] [-renderResolutions] [-renderSetups] [-selection] [-sets] [-shapes] [-shortNames] [-showNamespace] [-showType] [-tail int] [-templated] [-textures] [-transforms] [-type string] [-ufeObjects] [-undeletable] [-untemplated] [-uuid] [-visible]
[object [object...]]
ls is undoable, NOT queryable, and NOT editable.
Thels
command returns the names (and
optionally the type names) of objects in the scene.
The most common use of ls
is to filter or
match objects based on their name (using wildcards) or based on their
type.
By default ls
will match any object in the
scene but it can also be used to filter or list the selected
objects when used in conjunction with the -selection flag.
If type names are requested, using the showType flag, they
will be interleaved with object names so the result will be
pairs of <object, type> values.
Internal nodes (for example itemFilter nodes) are typically filtered
so that only scene objects are returned. However, using a wildcard
will cause all the nodes matching the wild card to show up, including
internal nodes. For example, ls *
will list all
nodes whether internal or not.
Use the syntax "::" to denote a recursive namespace search when listing nodes.
For example, ls "::pSphere1"
would match objects named
"pSphere1" in any namespace, at any depth. ls "ns::*"
would match any node in namespace "ns" or children namespaces.
When Maya is in relativeNames mode, the ls
command
will return names relative to the current namespace and
ls *
will list from the the current namespace.
For more details, please refer to the -relativeNames
flag of the namespace
command.
The command may also be passed node UUIDs instead of names/paths, and
can return UUIDs instead of names via the -uuid flag.
string[] | Command result |
Long name (short name) | Argument types | Properties | ||
---|---|---|---|---|
-absoluteName(-an)
|
|
|||
|
||||
-allPaths(-ap)
|
|
|||
|
||||
-assemblies(-as)
|
|
|||
|
||||
-cameras(-ca)
|
|
|||
|
||||
-containerType(-ct)
|
string
|
|||
|
||||
-containers(-con)
|
|
|||
|
||||
-dagObjects(-dag)
|
|
|||
|
||||
-defaultNodes(-dn)
|
|
|||
|
||||
-dependencyNodes(-dep)
|
|
|||
|
||||
-exactType(-et)
|
string
|
|||
|
||||
-excludeType(-ext)
|
string
|
|||
|
||||
-flatten(-fl)
|
|
|||
|
||||
-geometry(-g)
|
|
|||
|
||||
-ghost(-gh)
|
|
|||
|
||||
-head(-hd)
|
int
|
|||
|
||||
-hilite(-hl)
|
|
|||
|
||||
-intermediateObjects(-io)
|
|
|||
|
||||
-invisible(-iv)
|
|
|||
|
||||
-leaf(-lf)
|
|
|||
|
||||
-lights(-lt)
|
|
|||
|
||||
-live(-lv)
|
|
|||
|
||||
-lockedNodes(-ln)
|
|
|||
|
||||
-long(-l)
|
|
|||
|
||||
-materials(-mat)
|
|
|||
|
||||
-modified(-mod)
|
|
|||
|
||||
-noIntermediate(-ni)
|
|
|||
|
||||
-nodeTypes(-nt)
|
|
|||
|
||||
-objectsOnly(-o)
|
|
|||
|
||||
-orderedSelection(-os)
|
|
|||
|
||||
-partitions(-pr)
|
|
|||
|
||||
-persistentNodes(-pn)
|
|
|||
|
||||
-planes(-pl)
|
|
|||
|
||||
-preSelectHilite(-psh)
|
|
|||
|
||||
-readOnly(-ro)
|
|
|||
|
||||
-recursive(-r)
|
boolean
|
|||
|
||||
-referencedNodes(-rn)
|
|
|||
|
||||
-references(-rf)
|
|
|||
|
||||
-renderGlobals(-rg)
|
|
|||
|
||||
-renderQualities(-rq)
|
|
|||
|
||||
-renderResolutions(-rr)
|
|
|||
|
||||
-renderSetups(-rs)
|
|
|||
|
||||
-selection(-sl)
|
|
|||
|
||||
-sets(-set)
|
|
|||
|
||||
-shapes(-s)
|
|
|||
|
||||
-shortNames(-sn)
|
|
|||
|
||||
-showNamespace(-sns)
|
|
|||
|
||||
-showType(-st)
|
|
|||
|
||||
-tail(-tl)
|
int
|
|||
|
||||
-templated(-tm)
|
|
|||
|
||||
-textures(-tex)
|
|
|||
|
||||
-transforms(-tr)
|
|
|||
|
||||
-type(-typ)
|
string
|
|||
|
||||
-ufeObjects(-ufe)
|
|
|||
|
||||
-undeletable(-ud)
|
|
|||
|
||||
-untemplated(-ut)
|
|
|||
|
||||
-uuid(-uid)
|
|
|||
|
||||
-visible(-v)
|
|
|||
|
Flag can appear in Create mode of command | Flag can appear in Edit mode of command |
Flag can appear in Query mode of command | Flag can be used more than once in a command. |
// create some objects to operate on and select them all. // Note that there are two objects named circle1; circle -n circle1; group; circle -n circle1; sphere -n sphere1; group; instance; select -ado; // list all objects ls; // List all selected objects ls -selection; // List all hilited objects ls -hilite; // List last selected object ls -selection -tail 1; // List all objects named "sphere1". Note that since sphere1 is // instanced, the command below lists only the first instance. ls sphere1; // To list all instances of sphere1, use the -ap/allPaths flag. ls -ap sphere1; // List all selected objects named "group*" ls -sl "group*"; // List all geometry, lights and cameras in the DAG. ls -geometry -lights -cameras; // List all shapes in the dag. ls -shapes; // 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: // select `ls -l`; // 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: // string $allObjects[]; // string $obj; // $allObjects = `ls -l`; // for ( $obj in $allObjects ) { // if ( `nodeType $obj` == "surfaceShape" ) { // print ($obj + "\n"); // } // } // // 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 = `ls -type surfaceShape`; // for ( $obj in $allObjects ) { // print ($obj + "\n"); // } // List all geometry shapes and their types ls -type geometryShape -showType; // List all paths to all leaf nodes in the DAG ls -dag -lf -ap; // List all nodes below the selected node ls -dag -ap -sl; // List all ghosting objects ls -ghost; // List all dag nodes that are read-only (i.e. referenced nodes) ls -dag -ro; // List reference nodes associated with specific files ls -references; // List all reference nodes, including unknown and shared reference // nodes ls -type reference; // Select some components and then get the list in both selected and numeric order string $obj1[] = `polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1`; select -clear; selectPref -trackSelectionOrder 1; select ($obj1[0]+".f[100]"); select -add ($obj1[0]+".f[50:55]"); select -add ($obj1[0]+".f[0]"); select -add ($obj1[0]+".f[56:60]"); // regular -selection flag returns the components in compacted numeric order. ls -selection; // Result: pSphere1.f[0] pSphere1.f[50:60] pSphere1.f[100] // // -orderedSelection flag returns the components in the order that we selected them. ls -orderedSelection; // Result: pSphere1.f[100] pSphere1.f[50:55] pSphere1.f[0] pSphere1.f[56:60] // // turn off tracking when we are done selectPref -trackSelectionOrder 0; // init some namespace namespace -add "A:B:C"; // add object into namespace namespace -set ":A:B"; polySphere -name "obj1"; namespace -set ":A:B:C"; polySphere -name "obj1"; polySphere -name "obj2"; // The current Namespace is ":A:B:C" and relative mode is off // List all objects and their namespace in the scene // If the object is in the root namespace, then return root ":" // Note that the results shown below have been elided (...) for documentation purposes. ls -showNamespace; // Result: time1 : sequenceManager1 : renderPartition : (...) A:B:obj1 A:B A:B:C:obj1 A:B:C A:B:C:obj2 A:B:C // select -r ":A:B:obj1"; select -add ":A:B:C:obj2"; // List both name and namespace of each selected object ls -showNamespace -selection; // Result: A:B:obj1 A:B A:B:C:obj2 A:B:C // // List name and namespace of all objects named "obj1" ls -showNamespace -recursive true "obj1"; // Result: A:B:obj1 A:B A:B:C:obj1 A:B:C // // Set current namespace namespace -set ":A:B"; // Enable relative mode namespace -relativeNames true; // Now the current namespace is ":A:B" and relative mode is on // Note that the name of the current namespace is "" in relative mode // List both name and namespace of each selected objects ls -showNamespace -selection; // Result: obj1 C:obj1 C // // Make a new scene, modify the transform of the camera perspective, play with the timeline and modify the camera's shape file -new -force setAttr "persp.translateX" 10; currentTime 8 ; setAttr "perspShape.horizontalFilmAperture" 16; // List all modified objects of type camera and type time ls -modified -type time -type camera; // Result: perspShape time1 // ls -modified; // Result: persp perspShape time1 // ls -excludeType camera -modified // Result: persp time1 // // Return a node's UUID ls -uuid sphere1; // Result: ECE85CCC-438D-8113-0236-39A6917DE484 // // Find a node by UUID ls "ECE85CCC-438D-8113-0236-39A6917DE484"; // Result: group2|sphere1 //