pymel.core.general.ls

ls(*args, **kwargs)

The lscommand returns the names (and optionally the type names) of objects in the scene. The most common use of lsis to filter or match objects based on their name (using wildcards) or based on their type. By default lswill 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, typevalues. 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. When Maya is in relativeNames mode, the lscommand will return names relativeto the current namespace and ls *will list from the the current namespace. For more details, please refer to the -relativeNamesflag of the namespacecommand.

Modifications:
  • Added new keyword: ‘editable’ - this will return the inverse set of the readOnly flag. i.e. non-read-only nodes

  • Added new keyword: ‘regex’ - pass a valid regular expression string, compiled regex pattern, or list thereof.

    >>> group('top')
    nt.Transform(u'group1')
    >>> duplicate('group1')
    [nt.Transform(u'group2')]
    >>> group('group2')
    nt.Transform(u'group3')
    >>> ls(regex='group\d+\|top') # don't forget to escape pipes `|` 
    [nt.Transform(u'group1|top'), nt.Transform(u'group2|top')]
    >>> ls(regex='group\d+\|top.*')
    [nt.Transform(u'group1|top'), nt.Camera(u'group1|top|topShape'), nt.Transform(u'group2|top'), nt.Camera(u'group2|top|topShape')]
    >>> ls(regex='group\d+\|top.*', cameras=1)
    [nt.Camera(u'group2|top|topShape'), nt.Camera(u'group1|top|topShape')]
    >>> ls(regex='\|group\d+\|top.*', cameras=1) # add a leading pipe to search for full path
    [nt.Camera(u'group1|top|topShape')]
    

    The regular expression will be used to search the full DAG path, starting from the right, in a similar fashion to how globs currently work. Technically speaking, your regular expression string is used like this:

    re.search( '(\||^)' + yourRegexStr + '$', fullNodePath )
    
    rtype:PyNode list
Flags:
  • allPaths : ap (bool) [create]

    List all paths to nodes in DAG. This flag only works if -dagis also specified or if an object name is supplied.

  • assemblies : assemblies (bool) [create]

    List top level transform Dag objects

  • cameras : ca (bool) [create]

    List camera shapes.

  • containers : con (bool) [create]

    List containers. Includes both standard containers as well as other types of containers such as dagContainers. Flag can have multiple arguments, passed either as a tuple or a list.

  • dagObjects : dag (bool) [create]

    List Dag objects of any type. If object name arguments are passed to the command then this flag will list all Dag objects below the specified object(s).

  • dependencyNodes : dep (bool) [create]

    List dependency nodes. (including Dag objects)

  • exactType : et (unicode) [create]

    List all objects of the specified type, but notobjects that are descendents of that type. This flag can appear multiple times on the command line. Note: the type passed to this flag is the same type name returned from the -showType flag. This flag cannot be used in conjunction with the -type flag.

  • flatten : fl (bool) [create]

    Flattens the returned list of objects so that each component is identified individually.

  • geometry : g (bool) [create]

    List geometric Dag objects.

  • ghost : gh (bool) [create]

    List ghosting objects.

  • head : hd (int) [create]

    This flag specifies the maximum number of elements to be returned from the beginning of the list of items. Note: each type flag will return at most this many items so if multiple type flags are specified then the number of items returned can be greater than this amount.

  • hilite : hl (bool) [create]

    List objects that are currently hilited for component selection.

  • intermediateObjects : io (bool) [create]

    List only intermediate dag nodes.

  • invisible : iv (bool) [create]

    List only invisible dag nodes.

  • leaf : lf (bool) [create]

    List all leaf nodes in Dag. This flag is a modifier and must be used in conjunction with the -dag flag.

  • lights : lt (bool) [create]

    List light shapes.

  • live : lv (bool) [create]

    List objects that are currently live.

  • lockedNodes : ln (bool) [create]

    Returns locked nodes, which cannot be deleted or renamed. However, their status may change.

  • long : l (bool) [create]

    Return full path names for Dag objects. By default the shortest unique name is returned.

  • materials : mat (bool) [create]

    List materials or shading groups.

  • noIntermediate : ni (bool) [create]

    List only non intermediate dag nodes.

  • nodeTypes : nt (bool) [create]

    Lists all registered node types.

  • objectsOnly : o (bool) [create]

    When this flag is set only object names will be returned and components/attributes will be ignored.

  • partitions : pr (bool) [create]

    List partitions.

  • persistentNodes : pn (bool) [create]

    Returns persistent nodes, which are nodes that stay in the Maya session after a file new.

  • planes : pl (bool) [create]

    List construction plane shapes.

  • preSelectHilite : psh (bool) [create]

    List components that are currently hilited for pre-selection.

  • readOnly : ro (bool) [create]

    Returns referenced nodes. Referenced nodes are read only. NOTE: Obsolete. Please use -referencedNodes.

  • recursive : r (bool) [create]

    When set to true, this command will look for name matches in all namespaces. When set to false, this command will only look for matches in namespaces that are requested (e.g. by specifying a name containing the ‘:’... ns1:pSphere1).

  • referencedNodes : rn (bool) [create]

    Returns referenced nodes. Referenced nodes are read only.

  • references : rf (bool) [create]

    List references associated with files. Excludes special reference nodes such as the sharedReferenceNode and unknown reference nodes.

  • renderGlobals : rg (bool) [create]

    List render globals.

  • renderQualities : rq (bool) [create]

    List named render qualities.

  • renderResolutions : rr (bool) [create]

    List render resolutions.

  • renderSetups : rs (bool) [create]

    Alias for -renderGlobals.

  • selection : sl (bool) [create]

    List objects that are currently selected.

  • sets : set (bool) [create]

    List sets.

  • shapes : s (bool) [create]

    List shape objects.

  • shortNames : sn (bool) [create]

    Return short attribute names. By default long attribute names are returned.

  • showType : st (bool) [create]

    List the type of each object after its name.

  • tail : tl (int) [create]

    This flag specifies the maximum number of elements to be returned from the end of the list of items. Note: each type flag will return at most this many items so if multiple type flags are specified then the number of items returned can be greater than this amount

  • templated : tm (bool) [create]

    List only templated dag nodes.

  • textures : tex (bool) [create]

    List textures.

  • transforms : tr (bool) [create]

    List transform objects.

  • type : typ (unicode) [create]

    List all objects of the specified type. This flag can appear multiple times on the command line. Note: the type passed to this flag is the same type name returned from the -showType flag. Note: some selection items in Maya do not have a specific object/data type associated with them and will return untypedwhen listed with this flag. This flag cannot be used in conjunction with the -exactType flag.

  • undeletable : ud (bool) [create]

    Returns nodes that cannot be deleted (which includes locked nodes). These nodes also cannot be renamed.

  • untemplated : ut (bool) [create]

    List only un-templated dag nodes.

  • visible : v (bool) [create]

    List only visible dag nodes.

Derived from mel command maya.cmds.ls

Previous topic

pymel.core.general.lockNode

Next topic

pymel.core.general.makeIdentity

Core

Core Modules

Other Modules

This Page