

# create an object and an instance for queries List all relatives of the specified type.įlag can appear in Create mode of commandįlag can have multiple arguments, passed either as a tuple or a list. We do this by calling, as shown in the following code: > import maya.standalone > () > import re as pmc > xform, shape pmc.polySphere () The import of.
Maya python ls u full#
Return full pathnames instead of object names. import maya.cmds as cmds def getTopParents (transforms): ''' Returns a list of the top most parents for the given transforms ''' parents for t in transforms: p cmds.listRelatives (t, parentTrue, type'transform') while p: p cmds.listRelatives (p 0, parentTrue, type'transform') if p: parents.append (p 0) else: parents.append (t. Let's begin by initializing Maya in the mayapy interpreter so we can use more than just standard Python functionality. Return a proper object name that can be passed to other commands. Normally, thisĬommand only returns the parent corresponding to the first 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. The most common use of ls is to filter or match objects based on their name (using wildcards) or based on their type.

Returns all the parents of this dag node. The ls command returns the names (and optionally the type names) of objects in the scene. List all the children of this dag node that are Note that it lists grand-children before children. It will appear only once on the list returned. Getting started with maya Basic Maya Commands Explained Creating Maya UI Creating PyQt GUI With Maya Finding scene objects Dealing with ls() results Find objects by name Finding objects by type Safely getting a single object from ls Using ls() to see if an object exists Working with component selections Maya Online Video. Returns all the children, grand-children etc. List all the children of this dag node (default). It causes any intermediate shapes among the descendents to be ignored.įlags allDescendents, allParents, children, fullPath, noIntermediate, parent, path, shapes, type Long name (short name) The -ni/noIntermediate flag works with the -s/shapes flag. When listing children, shape nodes will return their underworld Under a shape (underworld objects) will return their containing shape When listing parents of objects directly under the world, the command c/children, -ad/allDescendents, -s/shapes, -p/parent and -ap/allParentsĪre mutually exclusive. This command lists parents and children of DAG objects. That is, all of the built-in Maya commands, such as sphere, ls, and so on, are accessible through Python. The implementation of Python scripting in Maya provides the same access to native Maya commands as is provided through MEL. ListRelatives is undoable, NOT queryable, and NOT editable. Autodesk Maya supports the use of Python-style scripting wherever you used to use MEL commands. ,, ,, ,, ,, , ) Note: Strings representing object names and arguments must be separated by commas.
