paya.lib.names#

Node-naming utilities, usually called indirectly.

legalise(name)#

Modifies a string so that Maya will accept it as a node name.

Parameters

name (str) – the string to conform

Returns

The Maya name.

Return type

str

conformElems(*elems, padding=<undefined>)#

Cleans up user name elements wrangled by Name.

Parameters
  • *elems (int, str) – one or more name elements, packed or unpacked

  • padding/pad – padding for any integer elements; defaults to config['padding']

Returns

The conformed elements.

Return type

list

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
  • name (str) – the name to process

  • stripNamespace/sns (bool) – remove namespace information; defaults to False

  • stripDagPath/sdp (bool) – remove DAG path information; defaults to False

  • stripTypeSuffix/sts (bool) – removes anything that looks like a type suffix; defaults to False

Returns

the modified name

Return type

str

class Name(*elems, suffix=<undefined>, padding=<undefined>, inherit=True, namespace=<undefined>, relativeNames=<undefined>, allowUnprefixedSuffixes=<undefined>)#

Inheritance

ContextDecorator

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 prefix

  • suffix/suf (str, bool) – if this is a string, it will be used a suffix for all nodes; if it’s True, appropriate suffixes will be looked up; if it’s False, no suffixes will be applied; defaults to enclosing overrides, or the namesake configuration flag

  • padding/pad (int) – the padding depth for any integer elements; defaults to enclosing overrides, or the namesake configuration flag

  • inherit/i (bool) – inherit elements from enclosing Name blocks; defaults to True

  • namespace/ns (str) – set the namespace for the block; if omitted, no namespace will be set

  • relativeNames/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 than transform1; 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 prefix

  • nodeType/nt (str, None) – a hint for the node type suffix; defaults to None

  • 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’s True, appropriate suffixes will be looked up; if it’s False, no suffixes will be applied; defaults to enclosing overrides, or the namesake configuration flag

  • allowUnprefixedSuffixes/aus (bool) – where no name elements have been accumulated, allows, for example, a transform to be named XFRM rather than transform1; defaults to enclosing overrides or the namesake configuration flag

  • padding/pad (int) – the padding depth for any integer elements; defaults to enclosing overrides, or the namesake configuration flag

  • inherit/i (bool) – inherit name elements from Name blocks; defaults to True

  • control/ct (bool) – indicate that the name is for a control; defaults to False

Returns

The constructed node name.

Return type

str