
Then define our function: def boundingBox():Ĭreate a couple of objects and store the names of each: # Create a couple of objects This is useful if you were creating a tool which handles alignment, scale or transforms based on surrounding objects.Īs always, as we will be using the Maya commands library we need to import it, we’ll also use the pretty print module to display our bounding box values in a readable way.
#Maya python ls how to
# List all dag nodes that are read-only (i.e.A quick guide on how to discover the bounding box of your Maya objects using Python. # List all paths to all leaf nodes in the DAG # List all geometry shapes and their typesĬmds.ls( type='geometryShape', showType=True ) # to list objects of a specific type as in:ĪllObjects = cmds.ls(type='surfaceShape') # To do this properly, the -typ/type flag should be used # is a base type for nurbsSurface so nothing will be printed. # The problem with this is that 'nodeType' returns the # use the nodeType command to then filter the list. # type, one approach might be to list all objects and then # When trying to find a list of all objects of a specific To select all objects, you need the following: # the object lookup can't resolve which "circle1" object is # to select all objects such as "select `ls`" will fail because # path name which uniquely identifies the object. Objects with the same name need a qualified 'ls' will list the names of all the objects # because there may be two nodes with the same name (in this # -l/long flag when listing nodes without any filter. # One thing to note is that it is better to always use the # List all geometry, lights and cameras in the DAG.Ĭmds.ls( geometry=True, lights=True, cameras=True ) # List all selected objects named "group*" # To list all instances of sphere1, use the -ap/allPaths flag. # instanced, the command below lists only the first instance. # Note that there are two objects named circle1 # create some objects to operate on and select them all. Nodes such as the sharedReferenceNode and unknown reference nodes.įlag can appear in Create mode of commandįlag can have multiple arguments, passed either as a tuple or a list. When set to false, this command will only lookįor matches in namespaces that are requested (e.g. When set to true, this command will look for name matches If -dag is also specified or if an object name isįlattens the returned list of objects so that each component This flag is a modifier and mustīe used in conjunction with the -dag flag. Passed to the command then this flag will list all Dag objects List components that are currently hilited for pre-selection. List objects that are currently hilited for component selection. List objects that are currently selected. When this flag is set only object names will be returned and List the type of each object after its name. This flag cannot be used in conjunction with the -type flag. List all objects of the specified type, but not objects that areĭescendents of that type. This flag cannot be used in conjunction with the -exactType flag. Object/data type associated with them and will return "untyped" Note: some selection items in Maya do not have a specific This flag is the same type name returned from the -showTypeįlag. Returned from the end of the list of items. Returned can be greater than this amount. If multiple type flags are specified then the number of items Note: each type flag will return at most this many items so Returned from the beginning of the list of items. This flag specifies the maximum number of elements to be Will be interleaved with object names so the result will beįlags allPaths, assemblies, cameras, dagObjects, dependencyNodes, exactType, flatten, geometry, ghost, head, hilite, intermediateObjects, invisible, leaf, lights, live, long, materials, noIntermediate, nodeTypes, objectsOnly, partitions, planes, preSelectHilite, readOnly, recursive, references, renderGlobals, renderQualities, renderResolutions, renderSetups, selection, sets, shapes, shortNames, showType, tail, templated, textures, transforms, type, untemplated, visible Long name (short name) If type names are requested, using the -showType flag, they Objects when used in conjunction with the -selection flag. Scene but it can also be used to filter or list the selected Match objects based on their name (using wildcards) or based on theirīy default ls will match any object in the The most common use of ls is to filter or Optionally the type names) of objects in the scene. Ls is undoable, NOT queryable, and NOT editable.
