OpenMaya.MGlobal

bnIsValidName Check if a name is strictly well-formed.
bnIsValidFullName Check if a full name is strictly well-formed.
bnIsValidPath Check if a path is strictly well-formed.
bnIsValidFullPath Check if a full path is strictly well-formed.
bnMakeMatchNameFunction Create a function to match names to a pattern.
bnMakeMatchFullNameFunction Create a function to match full names to a pattern.
bnMakeMatchPathFunction Create a function to match paths to a pattern.
bnMakeMatchFullPathFunction Create a function to match full paths to a pattern.
bnMatchName Check if a name matches a given pattern.
bnMatchFullName Check if a full name matches a given pattern.
bnMatchPath Check if a path matches a given pattern.
bnMatchFullPath Check if a full path matches a given pattern.

classmethod MGlobal.bnIsValidName(name, allowWildcards=False)[source]

Check if a name is strictly well-formed.

Names can identify DG nodes, excluding the ones carrying any namespace or hierarchy information. They are made of character elements, that is alphanumeric characters, underscores, and wildcards.

Categories: explicit.

Parameters:
  • path (str) – Name to check.
  • allowWildcards (bool) – True to consider the wildcards as valid characters.
Returns:

True if the name is strictly well-formed.

Return type:

bool

See also

Pattern Matching


classmethod MGlobal.bnIsValidFullName(name, allowWildcards=False, matchRelative=False)[source]

Check if a full name is strictly well-formed.

Full names can fully identify any DG node. They are composed by one or more name elements, each separated by the namespace delimiter :.

Categories: explicit.

Parameters:
  • path (str) – Full name to check.
  • allowWildcards (bool) – True to consider the wildcards as valid characters.
  • matchRelative (bool) – True to allow matching relatively to a parent namespace. That is, full names starting with the namespace delimiter : are allowed.
Returns:

True if the full name is strictly well-formed.

Return type:

bool

See also

Pattern Matching


classmethod MGlobal.bnIsValidPath(path, allowWildcards=False)[source]

Check if a path is strictly well-formed.

Paths can identify DAG nodes, excluding the ones carrying any underworld information. They are composed by one or more full name elements, each starting with the hierarchy delimiter |.

Categories: explicit.

Parameters:
  • path (str) – Path to check.
  • allowWildcards (bool) – True to consider the wildcards as valid characters.
Returns:

True if the path is strictly well-formed.

Return type:

bool

See also

Pattern Matching


classmethod MGlobal.bnIsValidFullPath(path, allowWildcards=False, matchRelative=False)[source]

Check if a full path is strictly well-formed.

Full paths can fully identify any DAG node. They are composed by one or more path elements, each separated by the underworld delimiter ->.

Categories: explicit.

Parameters:
  • path (str) – Full path to check.
  • allowWildcards (bool) – True to consider the wildcards as valid characters.
  • matchRelative (bool) – True to allow matching relatively to a parent path. That is, full paths starting with the underworld delimiter -> are allowed.
Returns:

True if the full path is strictly well-formed.

Return type:

bool

See also

Pattern Matching


classmethod MGlobal.bnMakeMatchNameFunction(pattern)[source]

Create a function to match names to a pattern.

Categories: explicit.

Parameters:pattern (str) – Name pattern to build. Wildcards are allowed.
Returns:A function expecting a single parameter, that is the name to check the pattern against. The return value of this function is a value that evaluates to True or False in a boolean operation. The value passed to the parameter of this function must be a strictly well-formed name. No check is done to ensure the validity of the input but this can be done manually using MGlobal.bnIsValidName().
Return type:function
Raises:ValueError – The pattern is not well-formed.

Examples

>>> import bana
>>> bana.initialize()
>>> from maya import OpenMaya
>>> iterator = OpenMaya.MItDependencyNodes()
>>> match = OpenMaya.MGlobal.bnMakeMatchNameFunction('*Shape*')
>>> while not iterator.isDone():
...     obj = iterator.thisNode()
...     name = OpenMaya.MFnDependencyNode(obj).name()
...     if match(name):
...         print(name)
...     iterator.next()

classmethod MGlobal.bnMakeMatchFullNameFunction(pattern, matchRelative=False)[source]

Create a function to match full names to a pattern.

Categories: explicit.

Parameters:
  • pattern (str) – Full name pattern to build. Wildcards are allowed.
  • matchRelative (bool) – True to allow matching relatively to a parent namespace. That is, full names starting with the namespace delimiter : are allowed.
Returns:

A function expecting a single parameter, that is the full name to check the pattern against. The return value of this function is a value that evaluates to True or False in a boolean operation. The value passed to the parameter of this function must be a strictly well-formed full name. No check is done to ensure the validity of the input but this can be done manually using MGlobal.bnIsValidFullName().

Return type:

function

Raises:

ValueError – The pattern is not well-formed.


classmethod MGlobal.bnMakeMatchPathFunction(pattern)[source]

Create a function to match paths to a pattern.

Categories: explicit.

Parameters:pattern (str) – Path pattern to build. Wildcards are allowed.
Returns:A function expecting a single parameter, that is the path to check the pattern against. The return value of this function is a value that evaluates to True or False in a boolean operation. The value passed to the parameter of this function must be a strictly well-formed path. No check is done to ensure the validity of the input but this can be done manually using MGlobal.bnIsValidPath().
Return type:function
Raises:ValueError – The pattern is not well-formed.

Examples

>>> import bana
>>> bana.initialize()
>>> from maya import OpenMaya
>>> iterator = OpenMaya.MItDag()
>>> match = OpenMaya.MGlobal.bnMakeMatchPathFunction('*|*Shape*')
>>> dagPath = OpenMaya.MDagPath()
>>> while not iterator.isDone():
...     iterator.getPath(dagPath)
...     path = dagPath.fullPathName()
...     if match(path):
...         print(path)
...     iterator.next()

classmethod MGlobal.bnMakeMatchFullPathFunction(pattern, matchRelative=False)[source]

Create a function to match full paths to a pattern.

Categories: explicit.

Parameters:
  • pattern (str) – Full path pattern to build. Wildcards are allowed.
  • matchRelative (bool) – True to allow matching relatively to a parent path. That is, full paths starting with the underworld delimiter -> are allowed.
Returns:

A function expecting a single parameter, that is the full path to check the pattern against. The return value of this function is a value that evaluates to True or False in a boolean operation. The value passed to the parameter of this function must be a strictly well-formed full path. No check is done to ensure the validity of the input but this can be done manually using MGlobal.bnIsValidFullPath().

Return type:

function

Raises:

ValueError – The pattern is not well-formed.


classmethod MGlobal.bnMatchName(pattern, name)[source]

Check if a name matches a given pattern.

Both pattern and name must be strictly well-formed.

If the same pattern is to be matched several times, consider using MGlobal.bnMakeMatchNameFunction() instead.

Categories: explicit.

Parameters:
  • pattern (str) – Pattern to match to. Wildcards are allowed.
  • path (str) – Name to check.
Returns:

True if the name matches the given pattern.

Return type:

bool


classmethod MGlobal.bnMatchFullName(pattern, name, matchRelative=False)[source]

Check if a full name matches a given pattern.

Both pattern and full name must be strictly well-formed.

If the same pattern is to be matched several times, consider using MGlobal.bnMakeMatchFullNameFunction() instead.

Categories: explicit.

Parameters:
  • pattern (str) – Pattern to match to. Wildcards are allowed.
  • path (str) – Full name to check.
  • matchRelative (bool) – True to allow matching relatively to a parent namespace. That is, full names starting with the namespace delimiter : are allowed.
Returns:

True if the full name matches the given pattern.

Return type:

bool


classmethod MGlobal.bnMatchPath(pattern, path)[source]

Check if a path matches a given pattern.

Both pattern and path must be strictly well-formed.

If the same pattern is to be matched several times, consider using MGlobal.bnMakeMatchPathFunction() instead.

Categories: explicit.

Parameters:
  • pattern (str) – Pattern to match to. Wildcards are allowed.
  • path (str) – Path to check.
Returns:

True if the path matches the given pattern.

Return type:

bool


classmethod MGlobal.bnMatchFullPath(pattern, path, matchRelative=False)[source]

Check if a full path matches a given pattern.

Both pattern and full path must be strictly well-formed.

If the same pattern is to be matched several times, consider using MGlobal.bnMakeMatchFullPathFunction() instead.

Categories: explicit.

Parameters:
  • pattern (str) – Pattern to match to. Wildcards are allowed.
  • path (str) – Full path to check.
  • matchRelative (bool) – True to allow matching relatively to a parent path. That is, full paths starting with the underworld delimiter -> are allowed.
Returns:

True if the full path matches the given pattern.

Return type:

bool