pymel.core.general.containerTemplate

containerTemplate(*args, **kwargs)

A container template is a description of a container’s published interface. This command provides the ability to create and save a template file for a container or load an existing template file. Once a template exists, the user can query the template information. In query mode, return type is based on queried flag.

Flags:
Long name (short name) Argument Types Properties
addBindingSet (abs) unicode ../../../_images/create.gif ../../../_images/edit.gif
 

This argument is used to add a new binding set with the given name to a template. A default binding set will be created. If the binding set already exists, the force flag must be used to replace the existing binding set. When used with the fromContainer option, default bindings will be entered based on the current bindings of the designated container. When used without a reference container, the binding set will be made with placeholder entries. The template must be saved before the new binding set is permanently stored with the template file.

addNames (an) bool ../../../_images/edit.gif
 

In edit mode, when used with the fromContainer flag, any published name on the container not present as an attribute on the template will be added to the template.

addView (av) unicode ../../../_images/create.gif ../../../_images/edit.gif
 

This argument is used to add a new view with the given name to a template. By default a view containing a flat list of all template attributes will be created. The layoutMode flag provides more layout options. The template must be saved before the new view is permanently stored with the template file.

allKeyable (ak) bool ../../../_images/create.gif ../../../_images/edit.gif
 

Used when the fromSelection flag is true and fromContainer is false. If true we will use all keyable attributes to define the template or the view, if false we use the attributes passed in with the attribute flag.

attribute (at) unicode ../../../_images/create.gif ../../../_images/edit.gif
 
If fromSelection is true and allKeyable is false, this attribute name will be used to create an attribute item in the template file.
attributeList (al) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Used in query mode, returns a list of attributes contained in the template definition.
baseName (bn) unicode ../../../_images/create.gif ../../../_images/query.gif
 
Used in query mode, returns the base name of the template. The basename is the template name with any package qualifiers stripped off.
bindingSetList (bsl) unicode ../../../_images/create.gif ../../../_images/query.gif
 
Used in query mode, returns a list of all binding sets defined on the template.
childAnchor (can) bool ../../../_images/create.gif ../../../_images/query.gif
 
This flag can be optionally specified when querying the publishedNodeList. The resulting list will contain only childAnchor published nodes.
delete (d) bool ../../../_images/create.gif
 

Delete the specified template and its file. All objects that are associated with this template or contained in the same template file will be deleted. To simply unload a template without permanently deleting its file, use unload instead.

exists (ex) bool ../../../_images/query.gif
 

Returns true or false depending upon whether the specified template exists. When used with the matchFile argument, the query will return true if the template exists and the filename it was loaded from matches the filename given.

expandCompounds (ec) bool ../../../_images/create.gif ../../../_images/edit.gif
 

This argument is used to determine how compound parent attributes and their children will be added to generated views when both are published to the container. When true, the compound parent and all compound child attributes published to the container will be included in the view. When false, only the parent attribute is included in the view. Note: if only the child attributes are published and not the parent, the children will be included in the view, this flag is only used in the situation where both parent and child attributes are published to the container. The default value is false.

fileName (fn) unicode ../../../_images/create.gif ../../../_images/query.gif
 

Specifies the filename associated with the template. This argument can be used in conjunction with load, save or query modes. If no filename is associated with a template, a default file name based on the template name will be used. It is recommended but not required that the filename and template name correspond.

force (f) bool ../../../_images/create.gif
 

This flag is used with some actions to allow them to proceed with an overwrite or destructive operation. When used with load, it will allow an existing template to be reloaded from a file. When used in create mode, it will allow an existing template to be recreated (for example when using fromContainer argument to regenerate a template).

fromContainer (fc) unicode ../../../_images/create.gif
 

This argument is used in create or edit mode to specify a container node to be used for generating the template contents. In template creation mode, the template definition will be created based on the list of published attributes in the specified container. In edit mode, when used with the addNames flag or with no other flag, any published name on the container not present as an attribute on the template will be added to the template. This flag is also used in conjunction with flags such as addView.

fromSelection (fs) bool ../../../_images/create.gif ../../../_images/edit.gif
 

If true, we will use the active selection list to create the template or the view. If allKeyable is also true then we will create the template from all keyable attributes in the selection, otherwise we will create the template using the attributes specified with the attribute flag.

layoutMode (lm) int ../../../_images/create.gif
 

This argument is used to specify the layout mode when creating a view. Values correspond as follows: 0: layout in flat list (default when not creating view from container) 1: layout grouped by node (default if creating view from container) The fromContainer or fromSelection argument is required to provide the reference container or selection for layout modes that require node information. Note that views can only refer to defined template attributes. This means that when using the fromContainer or from Selection flag to add a view to an existing template, only attributes that are defined on both the template and the container or the current selection will be included in the view (i.e. published attributes on the container that are not defined in the template will be ignored).

load (l) bool  
 

Load an existing template from a file. If a filename is specified for the template, the entire file (and all templates in it) will be loaded. If no file is specified, a default filename will be assumed, based on the template name.

matchFile (mf) unicode ../../../_images/query.gif
 
Used in query mode in conjunction with other flags this flag specifies an optional file name that is to be matched as part of the query operation.
matchName (mn) unicode ../../../_images/query.gif
 

Used in query mode in conjunction with other flags this flag specifies an optional template name that is to be matched as part of the query operation. The base template name is used for matching, any template with the same basename will be matched even across different packages.

parentAnchor (pan) bool ../../../_images/create.gif ../../../_images/query.gif
 
This flag can be optionally specified when querying the publishedNodeList. The resulting list will contain only parentAnchor published nodes.
publishedNodeList (pnl) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

Used in query mode, returns a list of published nodes contained in the template definition. By default all published nodes on the template will be returned. The list of published nodes can be limited to only include certain types of published nodes using one of the childAnchor, parentAnchor or rootTransform flags. If an optional flag is are specified, only nodes of the specified type will be returned.

removeBindingSet (rbs) unicode ../../../_images/create.gif ../../../_images/edit.gif
 

This argument is used to remove the named binding set from the template. The template must be saved before the binding set is permanently removed from the template file.

removeView (rv) unicode ../../../_images/create.gif ../../../_images/edit.gif
 
This argument is used to remove the named view from the template. The template must be saved before the view is permanently removed from the template file.
rootTransform (rtn) bool ../../../_images/create.gif ../../../_images/query.gif
 
This flag can be optionally specified when querying the publishedNodeList. The resulting list will contain only rootTransform published nodes.
save (s) bool ../../../_images/create.gif
 

Save the specified template to a file. If a filename is specified for the template, the entire file (and all templates associated with it) will be saved. If no file name is specified, a default filename will be assumed, based on the template name.

searchPath (sp) unicode ../../../_images/query.gif ../../../_images/edit.gif
 

The template searchPath is an ordered list of all locations that are being searched to locate template files (first location searched to last location searched). The template search path setting is stored in the current workspace and can also be set and queried as the file rule entry for ‘templates’ (see the workspace command for more information). In edit mode, this flag allows the search path setting to be customized. When setting the search path value, the list should conform to a path list format expected on the current platform. This means that paths should be separated by a semicolon (;) on Windows and a colon (:) on Linux and MacOSX. Environment variables can also be used. Additional built-in paths may be added automatically by maya to the customized settings. In query mode, this flag returns the current contents of the search path; all paths, both customized and built-in, will be included in the query return value.

silent (si) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Silent mode will suppress any error or warning messages that would normally be reported from the command execution. The return values are unaffected.
templateList (tl) unicode ../../../_images/query.gif
 

Used in query mode, returns a list of all loaded templates. This query can be used with optional matchFile and matchName flags. When used with the matchFile flag, the list of templates will be restricted to those associated with the specified file. When used with the matchName flag, the list of templates will be restricted to those matching the specified template name.

unload (u) bool ../../../_images/create.gif
 

Unload the specified template. This action will not delete the associated template file if one exists, it merely removes the template definition from the current session.

updateBindingSet (ubs) unicode ../../../_images/create.gif ../../../_images/edit.gif
 

This argument is used to update an existing binding set with new bindings. When used with the fromContainer argument binding set entries with be replaced or merged in the binding set based on the bindings of the designated container. If the force flag is used, existing entries in the binding set are replaced with new values. When force is not used, only new entries are merged into the binding set, any existing entries will be left as-is. When used without a reference container, the binding set will be updated with placeholder entries. The template must be saved before the new binding set is permanently stored with the template file.

useHierarchy (uh) bool ../../../_images/create.gif ../../../_images/edit.gif
 
If true, and the fromSelection flag is set, the selection list will expand to include it’s hierarchy also.
viewList (vl) unicode ../../../_images/create.gif ../../../_images/query.gif
 

Used in query mode, returns a list of all views defined on the template.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.containerTemplate

Example:

import pymel.core as pm

import maya.cmds as cmds

#    Create a container template.
#
pm.containerTemplate( 'characterRig' )
# Create a container template using the published attribute information from
# container1.
pm.containerTemplate ('characterRig', fromContainer='container1')
#
# Save the template to a template file in the default template location.
pm.containerTemplate ('characterRig', save=True)
# Load a template (the template is located along the template search path)
pm.containerTemplate ('characterRig', load=True)
# Re-load a template that has already been loaded
# This is useful if you have made edits to the template outside of maya
pm.containerTemplate ('characterRig', force=True, load=True)
# Determine the file that a template was loaded from
pm.containerTemplate ('characterRig', query=True, fileName=True)
C:/myTemplates/characterRig.template
#
# Add a view to a container template. This view will be generated from the
# given container, and will use a group-by-node hierarchical layout.
# The view can be subesequently customized if desired.
#
pm.containerTemplate ('characterRig', edit=True, addView='newView', fromContainer='container1', layoutMode=1)
pm.containerTemplate ('characterRig', save=True)
#
# Add another view to a container template.
# This view will be generated with a default layout and can be
# subsequently customized.
#
pm.containerTemplate ('characterRig', edit=True, addView="newView2")
pm.containerTemplate ('characterRig', save=True)
#
# Get the list of attributes in the template.  This will return
# a flat list of attribute names in the order in which they appear
# in the template definition.
#
pm.containerTemplate ('characterRig', query=True, attributeList=True)
[u'attribute1', u'attribute2', u'attribute3']
#
# List all loaded templates
list = pm.containerTemplate(query=True, templateList=True)
[u'Object', u'characterRig']
#
# List all templates matching a a given template name
# Note that all templates with matching base name (in any package) will
# be returned.
pm.containerTemplate (query=True, templateList=True, matchName='characterRig')
[u'characterRig']
#

Previous topic

pymel.core.general.containerPublish

Next topic

pymel.core.general.containerView

Core

Core Modules

Other Modules

This Page