Go to: Synopsis. Return value. Related. Flags. Python examples.

Synopsis

container( [string...] , [addNode=[string,...]], [asset=[string,...]], [assetMember=string], [bindAttr=[string, string]], [connectionList=boolean], [current=boolean], [fileName=[string,...]], [findContainer=[string,...]], [force=boolean], [includeHierarchyAbove=boolean], [includeHierarchyBelow=boolean], [includeNetwork=boolean], [includeNetworkDetails=string], [includeShaders=boolean], [includeShapes=boolean], [includeTransform=boolean], [isContainer=boolean], [name=string], [nodeList=boolean], [nodeNamePrefix=boolean], [parentContainer=boolean], [preview=boolean], [publishAndBind=[string, string]], [publishAsChild=[string, string]], [publishAsParent=[string, string]], [publishAsRoot=[string, boolean]], [publishAttr=string], [publishConnections=boolean], [publishName=string], [removeContainer=boolean], [removeNode=[string,...]], [type=string], [unbindAndUnpublish=string], [unbindAttr=[string, string]], [unbindChild=string], [unbindParent=string], [unpublishChild=string], [unpublishName=string], [unpublishParent=string], [unsortedOrder=boolean])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

container is undoable, queryable, and editable.

This command can be used to create and query container nodes. It is also used to perform operations on containers such as:

Return value

stringName of the node created.

In query mode, return type is based on queried flag.

Related

containerProxy, containerPublish, containerTemplate, containerView, copyAttr

Flags

addNode, asset, assetMember, bindAttr, connectionList, current, fileName, findContainer, force, includeHierarchyAbove, includeHierarchyBelow, includeNetwork, includeNetworkDetails, includeShaders, includeShapes, includeTransform, isContainer, name, nodeList, nodeNamePrefix, parentContainer, preview, publishAndBind, publishAsChild, publishAsParent, publishAsRoot, publishAttr, publishConnections, publishName, removeContainer, removeNode, type, unbindAndUnpublish, unbindAttr, unbindChild, unbindParent, unpublishChild, unpublishName, unpublishParent, unsortedOrder
Long name (short name) Argument types Properties
name(n) string create
Sets the name of the newly-created container.
addNode(an) [string,...] createedit
Specifies the list of nodes to add to container.
force(f) boolean createedit
This flag can be used in conjunction with -addNode and -removeNode flags only. If specified with -addNode, nodes will be disconnected from their current containers before they are added to new one. If specified with -removeNode, nodes will be removed from all containers, instead of remaining in the parent container if being removed from a nested container.
removeNode(rn) [string,...] edit
Specifies the list of nodes to remove from container. If node is a member of a nested container, it will be added to the parent container. To remove from all containers completely, use the -force flag.
nodeList(nl) boolean query
When queried, returns a list of nodes in container. The list will be sorted in the order they were added to the container. This will also display any reordering done with the reorderContainer command.
unsortedOrder(uso) boolean query
This flag has no effect on the operation of the container command (OBSOLETE).
findContainer(fc) [string,...] query
When queried, if all the nodes in nodeList belong to the same container, returns container's name. Otherwise returns empty string.

In query mode, this flag needs a value.

removeContainer(rc) boolean edit
Disconnects all the nodes from container and deletes container node.
connectionList(cl) boolean query
Returns a list of the exterior connections to the container node.
publishConnections(pc) boolean createedit
Publish all connections from nodes inside the container to nodes outside the container.
publishAttr(pa) string query
In query mode, can only be used with the -publishName(-pn) flag, and takes an attribute as an argument; returns the published name of the attribute, if any.

In query mode, this flag needs a value.

publishName(pn) string queryedit
Publish a name to the interface of the container, and returns the actual name published to the interface. In query mode, returns the published names for the container. If the -bindAttr flag is specified, returns only the names that are bound; if the -unbindAttr flag is specified, returns only the names that are not bound; if the -publishAsParent/-publishAsChild flags are specified, returns only names of published parents/children. if the -publishAttr is specified with an attribute argument in the "node.attr" format, returns the published name for that attribute, if any.
unpublishName(un) string edit
Unpublish an unbound name from the interface of the container.
bindAttr(ba) [string, string] queryedit
Bind a contained attribute to an unbound published name on the interface of the container; returns a list of bound published names. The first string specifies the node and attribute name to be bound in "node.attr" format. The second string specifies the name of the unbound published name. In query mode, returns a string array of the published names and their corresponding attributes. The flag can also be used in query mode in conjunction with the -publishName, -publishAsParent, and -publishAsChild flags.
unbindAttr(ua) [string, string] queryedit
Unbind a published attribute from its published name on the interface of the container, leaving an unbound published name on the interface of the container; returns a list of unbound published names. The first string specifies the node and attribute name to be unbound in "node.attr" format, and the second string specifies the name of the bound published name. In query mode, can only be used with the -publishName, -publishAsParent and -publishAsChild flags.
publishAndBind(pb) [string, string] edit
Publish the given name and bind the attribute to the given name. First string specifies the node and attribute name in "node.attr" format. Second string specifies the name it should be published with.
unbindAndUnpublish(ubp) string edit
Unbind the given attribute (in "node.attr" format) and unpublish its associated name. Unbinding a compound may trigger unbinds of its compound parents/children. So the advantage of using this one flag is that it will automatically unpublish the names associated with these automatic unbinds.
publishAsParent(pap) [string, string] queryedit
Publish contained node to the interface of the container to indicate it can be a parent to external nodes. The second string is the name of the published node. In query mode, returns a string of array of the published names and the corresponding nodes. If -publishName flag is used in query mode, only returns the published names; if -bindAttr flag is used in query mode, only returns the name of the published nodes.
publishAsChild(pac) [string, string] queryedit
Publish contained node to the interface of the container to indicate it can be a child of external nodes. The second string is the name of the published node. In query mode, returns a string of the published names and the corresponding nodes. If -publishName flag is used in query mode, only returns the published names; if -bindAttr flag is used in query mode, only returns the name of the published nodes.
publishAsRoot(pro) [string, boolean] queryedit
Publish or unpublish a node as a root. The significance of root transform node is twofold. When container-centric selection is enabled, the root transform will be selected if a container node in the hierarchy below it is selected in the main scene view. Also, when exporting a container proxy, any published root transformation attributes such as translate, rotate or scale will be hooked up to attributes on a stand-in node. In query mode, returns the node that has been published as root.
unpublishParent(upp) string edit
Unpublish node published as parent from the interface of the container
unpublishChild(upc) string edit
Unpublish node published as child from the interface of the container
unbindParent(unp) string edit
Unbind the node published as parent, but do not remove its published name from the interface of the container.
unbindChild(unc) string edit
Unbind the node published as child, but do not remove its published name from the interface of the container.
nodeNamePrefix(nnp) boolean createedit
Specifies that the name of published attributes should be of the form "node_attr". Must be used with the -publishConnections/-pc flag.
includeNetwork(inc) boolean createedit
Used to specify that the node network connected to supplied node list should also be included in the container. Network traversal will stop at default nodes and nodes which are members of other containers.
includeNetworkDetails(ind) string createeditmultiuse
Used to specify specific parts of the network that should be included. Valid arguments to this flag are: "channels", "sdk", "constraints", "history" and "expressions", "inputs", "outputs". The difference between this flag and the includeNetwork flag, is that it will include all connected nodes regardless of their type. Note that dag containers include their children, so they will always include constraint nodes that are parented beneath the selected objects, even when constraints are not specified as an input.
includeHierarchyAbove(iha) boolean createedit
Used to specify that the parent hierarchy of the supplied node list should also be included in the container (or deleted from the container). Hierarchy inclusion will stop at nodes which are members of other containers.
includeHierarchyBelow(ihb) boolean createedit
Used to specify that the hierarchy below the supplied node list should also be included in the container (or delete from the container). Hierarchy inclusion will stop at nodes which are members of other containers.
includeTransform(it) boolean createedit
Used to specify that for any shapes selected, their parent transform will be included in the container (or deleted from the container). This flag is not necessary when includeHierarchyAbove is used since the parent transform and all of its parents will automatically be included.
includeShapes(ish) boolean createedit
Used to specify that for any transforms selected, their direct child shapes will be included in the container (or deleted from the container). This flag is not necessary when includeHierarchyBelow is used since the child shapes and all other descendents will automatically be included.
includeShaders(isd) boolean createedit
Used to specify that for any shapes included, their shaders will also be included in the container.
fileName(fn) [string,...] query
Used to query for the assets associated with a given file name.

In query mode, this flag needs a value.

current(c) boolean createqueryedit
In create mode, specify that the newly created asset should be current. In edit mode, set the selected asset as current. In query, return the current asset.
parentContainer(par) boolean query
Flag to query the parent container of a specified container.
assetMember(am) string query
Can be used during query in conjunction with the bindAttr flag to query for the only published attributes related to the specified node within the container.

In query mode, this flag needs a value.

asset(a) [string,...] query
When queried, if all the nodes in nodeList belong to the same container, returns container's name. Otherwise returns empty string. This flag is functionally equivalent to the findContainer flag.
preview(p) boolean create
This flag is valid in create mode only. It indicates that you do not want the container to be created, instead you want to preview its contents. When this flag is used, Maya will select the nodes that would be put in the container if you did create the container. For example you can see what would go into the container with -includeNetwork, then modify your selection as desired, and do a create container with the selected objects only.
type(typ) string createquery
By default, a container node will be created. Alternatively, the type flag can be used to indicate that a different type of container should be created. At the present time, the only other valid type of container node is "dagContainer".
isContainer(isc) boolean query
Return true if the selected or specified node is a container node. If multiple containers are queried, only the state of the first will be returned.

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 have multiple arguments, passed either as a tuple or a list.

Python examples

import maya.cmds as cmds

# Create a container holding a locator transform only (not its shape)
#
loc = cmds.spaceLocator()
con1 = cmds.container(addNode=[loc[0]])

# Select the nodes that would be in the container, but don't create it
#
cmds.container(preview=True,addNode=[cone[0]],includeNetwork=True,includeHierarchyBelow=True)


# Create a container holding a polygon shape, its transform and its
# history node. Publish its tx attr.
#
cone = cmds.polyCone()
con2 = cmds.container(addNode=[cone[0]],includeNetwork=True,includeHierarchyBelow=True)

# Publish the cone's tx and the locator's tx with the same name
#
cmds.container(con1,edit=True,publishName='main_tx')
cmds.container(con1,edit=True,bindAttr=['%s.tx' % loc[0],'main_tx'])
cmds.container(con2,edit=True,publishName='main_tx')
cmds.container(con2,edit=True,bindAttr=['%s.tx' % cone[0],'main_tx'])

# Publish the name "sam", but don't bind it to anything
#
cmds.container(con1,edit=True,publishName='sam')

# Query the bound publications
#
cmds.container(con1,query=True,bindAttr=1)
# Result: [u'locator1.translateX', u'main_tx'] #

# Query all the published names:
#
cmds.container(con1,query=True,publishName=1)
# Result: [u'main_tx' u'sam'] #

# Query just the bound published names:
#
cmds.container(con1,query=True,publishName=1,bindAttr=1)
# Result: [u'main_tx'] #

# Query just the unbound published names:
#
cmds.container(con1,query=True,publishName=1,unbindAttr=1)
# Result: [u'sam'] #

# Query just the published name for the published attribute locator1.translateX
#
cmds.container(con1,query=True,publishName=1,publishAttr='locator1.translateX')
# Result: [u'main_tx'] #

# keyframe the cone's tx
#
cmds.currentTime(0)
coneTx = '%s.tx' % cone[0]
cmds.setKeyframe(coneTx)
cmds.currentTime(4)
cmds.setAttr(coneTx,10.0)
cmds.setKeyframe(coneTx)

# Query the nodes in the container
#
nodes = cmds.container(con2,query=True,nodeList=True)

# Remove a node from the container
#
cmds.container(con2,edit=True,removeNode=nodes[2])

# Remove the container without deleting the nodes within it
#
cmds.container(con2,edit=True,removeContainer=True)

# query a referenced scenes for its assets
#
cmds.container(q=True,fileName='C:/My Documents/maya/projects/default/scenes/refFile.mb')