paya.lib.names#
Node-naming utilities, usually called indirectly.
- legalise(name)#
Modifies a string so that Maya will accept it as a node name.
- shorten(name, stripNamespace=False, stripDagPath=False, stripTypeSuffix=False)#
Shortens a Maya name to various degrees. The name will be returned as-is unless one or more flags are set to
True
.- Parameters
- Returns
the modified name
- Return type
- class Name(*elems, suffix=<undefined>, padding=<undefined>, inherit=True, namespace=<undefined>, relativeNames=<undefined>, allowUnprefixedSuffixes=<undefined>)#
Inheritance
Context manager. Accumulates prefixes for default node names, and provides other useful overrides.
This context manager can also be used as a decorator:
@Name('build') def build(*args, **kwargs): pass
Inside list comprehensions, it would take this form:
locs = [Name('point', x+1, padding=3)(r.nodes.Locator.createNode)() for x in range(20)] # Produces point_001_LOCT, point_002_LOCT etc.
- Parameters
*elems (
str
,int
) – one or more name elements to combine into a prefixsuffix/suf (
str
,bool
) – if this is a string, it will be used a suffix for all nodes; if it’sTrue
, appropriate suffixes will be looked up; if it’sFalse
, no suffixes will be applied; defaults to enclosing overrides, or the namesake configuration flagpadding/pad (
int
) – the padding depth for any integer elements; defaults to enclosing overrides, or the namesake configuration flaginherit/i (bool) – inherit elements from enclosing
Name
blocks; defaults toTrue
namespace/ns (
str
) – set the namespace for the block; if omitted, no namespace will be setrelativeNames/rel (bool) – switches to relative name lookups for the block; defaults to enclosing overrides
allowUnprefixedSuffixes/aus (bool) – where no name elements have been accumulated, allows, for example, a transform to be named
XFRM
rather thantransform1
; defaults to enclosing overrides or the namesake configuration flag
- classmethod make(*elems, nodeType=None, transform=None, suffix=<undefined>, allowUnprefixedSuffixes=<undefined>, padding=<undefined>, inherit=True, control=False)#
Constructs Maya node names.
- Parameters
*elems (
str
,int
) – one or more name elements to combine into a prefixnodeType/nt (
str
,None
) – a hint for the node type suffix; defaults toNone
transform/xf (bool) – indicate that the name is intended for a transform; defaults to
None
suffix/suf (
str
,bool
) – if this is a string, it will be used a suffix for all nodes; if it’sTrue
, appropriate suffixes will be looked up; if it’sFalse
, no suffixes will be applied; defaults to enclosing overrides, or the namesake configuration flagallowUnprefixedSuffixes/aus (bool) – where no name elements have been accumulated, allows, for example, a transform to be named
XFRM
rather thantransform1
; defaults to enclosing overrides or the namesake configuration flagpadding/pad (
int
) – the padding depth for any integer elements; defaults to enclosing overrides, or the namesake configuration flaginherit/i (bool) – inherit name elements from
Name
blocks; defaults toTrue
control/ct (bool) – indicate that the name is for a control; defaults to
False
- Returns
The constructed node name.
- Return type