Python Module Reference

This Python module contains useful tools to work with the seUVBlendShape deformer plugin. The plugin already an associated built in MEL command which this module uses.

Not only does this module provide functions you can use in your own tools, but it also comes with a user interface. (See ui module) This can be opened by calling the launchEditor() function.:

import seUVBlendShape
seUVBlendShape.launchEditor()

Upon importing this module, an attempt to load the plug-in will be peformed. No special Python libary requirements are needed. Maya provides all neccessary modules.

Note

Undo operations are limited to only creating a new deformer node. It is not currently supported to undo any editing (adding, removing, rebinding, etc) operations.

seUVBlendShape.addTarget(deformer, targetMesh, baseUVSet=None, targetUVSet=None, tolerance=0.01)

Add a target mesh to an existing seUVBlendShape deformer.

Parameters:
  • deformer (str) – name of the existing deformer node
  • targetMesh (str) – name of the target polygon mesh
  • baseUVSet (str) – base mesh UV set. Default is the first found
  • targetUVSet (str) – target mesh UV set. Default is the first found
  • tolerance (float) – bind tolerance for outside border UVs
Returns:

None

seUVBlendShape.changeUVSet(deformer, target=None, baseUVSet=None, targetUVSet=None, tolerance=0.01)

Change the UV sets used for binding an existing target to the base geometry. A rebind will be automatically be triggered after changing the UV sets.

Parameters:
  • deformer (str) – name of the seUVBlendShape deformer
  • target (str or list of str) – name(s) of the targest to change UV sets on. If None, all targets will be used
  • baseUVSet (str) – change the base geometry UV set. If None, no change will be performed
  • targetUVSet (str) – change the target geometry UV set. If None, no change will be performed
  • tolerance (float) – bind tolerance for outside border UVs
Returns:

None

seUVBlendShape.create(baseMesh, targetMesh, baseUVSet=None, targetUVSet=None, name=None, keepOffset=False, tolerance=0.01)

Create a new seUVBlendShape deformer on the given base mesh with the given target mesh(s). See documentation for more information.

Parameters:
  • baseMesh (str) – name of the base polyon mesh
  • targetMesh (str or list of str) – name of target polygon mesh(s)
  • baseUVSet (str) – base mesh UV set. Default is the first found
  • targetUVSet (str) – target mesh UV set. Default is the first found
  • name (str) – name to give the deformer. Default is seUVBlendShape#
  • keepOffset (bool) – keep offsets on base mesh (can be set after later)
  • tolerance (float) – bind tolerance for outside border UVs
Returns:

name of created deformer

Return type:

str

seUVBlendShape.getBaseUVSet(deformer, target)

Return the name of the base uv set used to associate with a target.

Parameters:
  • deformer (str) – name of the seUVBlendShape deformer
  • target (str) – name of target
Return type:

str

seUVBlendShape.getBoundVertices(deformer, target)

Return a list of vertex indexes that are bound on the deformer.

Parameters:
  • deformer (str) – name of the seUVBlendShape deformer
  • target (str) – name of target
Return type:

list of int

seUVBlendShape.getTargetCount(deformer)

Return the number of targets on the deformer.

Parameters:deformer (str) – name of the seUVBlendShape deformer
Return type:int
seUVBlendShape.getTargetIndexFromMesh(deformer, targetMesh)

Returns the target index on the deformer for the given target mesh. If the target mesh is not connected to the deformer, a ValueError is raised.

Parameters:
  • deformer (str) – name of the seUVBlendShape deformer
  • targetMesh (str) – name of target mesh
Returns:

index of target or list of indexes if multiple connections

Return type:

int or list of int

Raises:

ValueError

seUVBlendShape.getTargetIndexFromName(deformer, target)

Returns the target index on the defomer that matches the given target name. If the target name does not exist on the deformer, a ValueError is raised.

Parameters:
  • deformer (str) – name of the seUVBlendShape deformer
  • target (str) – name of target to get index for
Return type:

int

Raises:

ValueError

seUVBlendShape.getTargetIndexes(deformer)

Return a list of target indexes on the deformer.

Parameters:deformer (str) – name of the seUVBlendShape deformer
Return type:list of int
seUVBlendShape.getTargetMesh(deformer, target)

Returns the mesh shape that is connected to the deformer for the given target.

Parameters:
  • deformer (str) – name of the seUVBlendShape deformer
  • target (str or int) – name of target or target index
Returns:

name of connected shape node or None if no mesh is connected

Return type:

str

seUVBlendShape.getTargetNames(deformer)

Return a list of target names on the deformer.

Parameters:deformer (str) – name of the seUVBlendShape deformer
Return type:list of str
seUVBlendShape.getTargetUVSet(deformer, target)

Return the name of the target uv set used to associate with a target.

Parameters:
  • deformer (str) – name of the seUVBlendShape deformer
  • target (str) – name of target
Return type:

str

seUVBlendShape.launchEditor()

Launch the seUVBlendShape editor. Only available if called from an interactive Maya session.

seUVBlendShape.loadPlugin()

Load the seUVBlendShape plugin

Returns:None
seUVBlendShape.paintDeformerWeights(deformer)

Activates weight painting for the overall deformer influence.

..note:

In Maya 2016, the GPU override will be disabled as changing weights
is not supported in this mode. After painting, you may re-enable it.
Parameters:deformer (str) – name of the seUVBlendShape deformer
Returns:None
seUVBlendShape.paintDeltaWeights(deformer)

Activates weight painting for all target deltas.

..note:

In Maya 2016, the GPU override will be disabled as changing weights
is not supported in this mode. After painting, you may re-enable it.
Parameters:deformer (str) – name of the seUVBlendShape deformer
Returns:None
seUVBlendShape.paintTargetWeights(deformer, target)

Activates weight painting for the given target on the deformer.

..note:

In Maya 2016, the GPU override will be disabled as changing weights
is not supported in this mode. After painting, you may re-enable it.
Parameters:
  • deformer (str) – name of the seUVBlendShape deformer
  • target (str) – name of the target to paint weights on
Returns:

None

seUVBlendShape.pruneDeformerVertices(deformer)

Optimizes the deformer by pruning vertices from the deformer set. This is done by turning all targets on and any vertices that do not move are removed from the deformation set. This should only be called after all targets are added. Adding or removing targets may affect vertices that are pruned out. See the unpruneDeformerVertices() to restore all vertices.

Note

If any target weight attributes are locked or connected and are set to 0, it may prune out vertices affected by those targets. If this is the case, then you should activate these targets first before calling this function.

Parameters:deformer (str) – name of the seUVBlendShape deformer
Returns:None
seUVBlendShape.rebind(deformer, target=None, tolerance=0.01)

Rebinds the base mesh to specific targets. If targets is None, all targets will be rebound. Rebinding is used when you have moved the uvs or want to set the bind pose of the target.

Parameters:
  • deformer (str) – name of the seUVBlendShape deformer
  • target (str or list of str) – name(s) of targets to rebind. If None, all targets
  • tolerance (float) – bind tolerance for outside border UVs
Returns:

None

seUVBlendShape.removeTarget(deformer, target)

Remove a target from the deformer.

Parameters:
  • deformer (str) – name of the seUVBlendShape deformer
  • target (str) – name of target
Return type:

None

seUVBlendShape.unloadPlugin(force=False)

Unload the seUVBlendShape plugin

Parameters:force (bool) – Force the plugin to unload even if it’s in use. Default False
Returns:None
seUVBlendShape.unpruneDeformerVertices(deformer, baseMesh=None)

Restores the deformer set to affect all vertices on the deformed mesh. This will undo what the pruneDeformerVertices() function does. This is needed if you are adding or removing new targets to the deformer.

Note

If the base mesh has all vertices pruned out, you must pass the name of the base mesh to this function. Otherwise the base mesh may not be determined automatically.

Parameters:
  • deformer (str) – name of the seUVBlendShape deformer
  • baseMesh (str) – name of the base mesh. If None, an attempt will be made to determine the name.
Returns:

None

Raises:

RuntimeError

Examples

from maya import cmds

# import the seUVBlendShape Python Module
import seUVBlendShape

# create a base and two target poly spheres
baseMesh = cmds.polySphere(n='base', ch=False)[0]
targetAMesh = cmds.polySphere(n='targetA', ch=False)[0]
targetBMesh = cmds.polySphere(n='targetB', ch=False)[0]

# create a new deformer with both targetA/B driving the base mesh
# using the first UV sets found.
deformer = seUVBlendShape.create(baseMesh, [targetAMesh, targetBMesh])

# add a new target to the deformer
targetCMesh = cmds.polySphere(n='targetC', ch=False)[0]
seUVBlendShape.addTarget(deformer, targetCMesh)

# remove target B from the deformer
seUVBlendShape.removeTarget(deformer, targetBMesh)