Rig¶
Additivefk¶
- class AdditiveFk(jointList, rigName='additive', controlSpacing=1, lockHideJoints=True)¶
Bases:
object
Builds two extra joint chains with controls for additive FK. this is a setup that layers an fk chain ontop of another, useful for spline ik etc.
Note: Best to build additive fk with the metaNode, see zoo.libs.maya.cmds.meta.metaadditivefk
Example:
from zoo.libs.maya.cmds.meta import metaadditivefk jointList = [“joint1”, “joint2”, “joint3”, “joint4”] additiveFkInstance = metaadditivefk.ZooMetaAdditiveFk() additiveFkInstance.createAdditiveFk(jointList, rigName=”additive”, controlSpacing=1, lockHideJoints=True)
- expressionPosSpaced(exprLines)¶
This method affects translation of the blend joints, driven by controls Assumes controls are spaced
Axis¶
- clampSmallValues(val, clampAmount=0.001)¶
Clamps stupidly small values such as 4.072996551253769e-15 and returns 0.0
- rangeDifferenceFloat(floatList)¶
Returns the range between the max and min values of a float list
Example:
[1.0, -1.0, 2.0] Returns 3.0
- Parameters:
floatList (list(float)) – A list of floats
- Return rangeValue:
The difference between the highest and lowest numbers
- Rtype rangeValue:
float
- rangeDifferenceXYZ(XYZList)¶
Gets the range values, distance between high and low) for an XYZ float list, could be RGB
Example:
[1.0, -10.0, 2.0], [-1.0, -1.0, 2.0], [2.0, 20.0, 2.0] Returns [3.0, 20.0, 0.0]
- Parameters:
XYZList (list(list(float)))) – list of XYZ floats
- Return rangeList:
the XYZ list now with range difference values
- Rtype rangeList:
list(float)
- getAxisFromBoundingBox(rangeXYZ, secondaryAxis=False)¶
Tries to guess a good axis orientation for an object list.
If Up Axis (secondaryAxis=False):
The shortest edge of a bounding box is the up axis
If Secondary Axis (secondaryAxis=True):
If the longest edge is “y”, then will be “+z”, else will return “+y
Up axis is always positive.
- Parameters:
rangeXYZ (list(float)) – bounding box height width and length in Maya units [x, y, z] position values
- Return cogUpAxis:
“+x”, “+y”, or “+z” the preferred up axis based on the shortest edge of the bounding box
- Rtype cogUpAxis:
str
- autoAxisBBoxObjList(objList, secondaryAxis=False)¶
Tries to guess a good axis orientation for an object list based on pivot world positions
If Up Axis (secondaryAxis=False):
The shortest edge of a bounding box is the up axis
If Secondary Axis (secondaryAxis=True):
If the longest edge is “y”, then will be “+z”, else will return “+y
Up axis is always positive.
- Parameters:
objList (list(str)) – A list of Maya objects
- Return cogUpAxis:
“+x”, “+y”, or “+z” the preferred up axis based on the shortest edge of the bounding box
- Rtype cogUpAxis:
str
- autoAxisBBoxObj(obj, secondaryAxis=False)¶
Tries to guess a good axis orientation for an object list based on an object’s bounding box, usually a curve
If Up Axis (secondaryAxis=False):
The shortest edge of a bounding box is the up axis
If Secondary Axis (secondaryAxis=True):
If the longest edge is “y”, then will be “+z”, else will return “+y
Up axis is always positive.
Up axis is always positive. :param obj: A Maya object :type obj: str :return cogUpAxis: “+x”, “+y”, or “+z” the preferred up axis based on the shortest edge of the bounding box :rtype cogUpAxis: str
Connections¶
- getConnections(node, attributeName)¶
- createMessageConnection(sourceObj, destinationObj, attrName)¶
creates and connects the sourceObj.message to the destinationObj.attributeName
- createMessageConnectionList(sourceNode, attrName, destinationList)¶
creates and connects the sourceObj.attrName to the list of objects with destinationObj.message
- Parameters:
- Return attributeNameList:
the list of names of the attributes created eg [obj.attr, obj2.attr]
Controlconstants¶
Controls¶
Code for creating and adjusting controls used by Control Creator and Edit Controls UIs.
Example use:
# Create a control
from zoo.libs.maya.cmds.rig import controls
controls.constrainControlsOnSelected(folderpath=r"c:/controlShapesLibrary/",
curveScale=(1.0, 1.0, 1.0),
rotateOffset=(0.0, 90.0, 0.0),
constrainControls=False,
float=True,
designName="circle",
children=False,
rgbColor=(0.0, 1.0, 1.0),
postSelectControls=True,
trackScale=True,
lineWidth=-1.0,
addToUndo=False))
# Delete Zoo Tracker Attrs from selected controls
from zoo.libs.maya.cmds.rig import controls
controls.deleteTrackAttrsSel()
Author: Andrew Silke
- convertMObjsHandlesToStringList(mObjectList)¶
Converts MObjects Handles to a list of strings
- Return selection:
object names as strings
- Rtype selection:
list(str)
- mObjectFromString(objName)¶
Returns an mObject from a Maya string object name, preferably a long name.
- Parameters:
objName (str) – the string name of a Maya object or node
- Returns:
The maya node as an MObject
- Return type:
MObject
- renameMobject(MObjectNode, newname)¶
Renames an MObject dependency node
- Parameters:
MObjectNode (MObject) – A maya dependency node as an MObject
- class ControlClipboard¶
Bases:
object
- pasteControl()¶
Pastes controls from the function pasteControl(), handles error checking and restoring the copied data
- Return self.copyCtrl:
The copied control object
- Rtype self.copyCtrl:
str
- Return pasteObjs:
The objects that have been pasted, if none will be an empty list
- Rtype pasteObjs:
list(str)
- copyControl()¶
Copies the selected controls from the function copyControl(), stores the data inside the class
- curveLinethickness(curveTransform)¶
Returns the line thickness (attribute lineWidth) of the first curve shape found under the obj curveTransform
- Parameters:
curveTransform (str) – A transform object with a nurbsCurve shape node
- Return lineWidth:
The width of the curve’s line
- Rtype lineWidth:
int
- setCurveLineThickness(nodeList, lineWidth=-1)¶
Changes the lineWidth attribute of a curve (control) making the lines thicker or thinner.
-1 is the default line width and used the global lineWidth setting in Maya’s preferences, other values override.
- saveControlSelected(controlNewName, directory, dependenciesFolder=True, message=True)¶
Saves the first selected curve (transform node) with shapelib.saveToDirectory()
Creates an empty dependencies folder if dependenciesFolder=True
- Parameters:
- Returns:
The file path to the newly created shape file
- Return type:
- createControlCurve(folderpath='', ctrlName='control', curveScale=(1.0, 1.0, 1.0), designName='circle', addSuffix=True, shapeParent='', rotateOffset=(0.0, 0.0, 0.0), trackScale=True, lineWidth=-1, rgbColor=None, addToUndo=True)¶
Creates the control curve, using a curve shape/design from the shape library shapelib.loadAndCreateFromLib()
Also sizes and rotates 90 degrees down X+ if rotateOffset is True
- Parameters:
ctrlName (str) – The name of the control to create (or shapeNodes shapeParent), if addSuffix also adds _ctrl
curveScale (list(float)) – The scale of each control in Maya units. Is measured in radius, not width.
designName (str) – The shape/look/design of the control, for list see shapelib.shapeNames() from the shapes dir
addSuffix (bool) – Adds an underscore and suffix from filterTypes.CONTROLLER_SX usually “ctrl”
shapeParent (str) – If specified will shape parent the new curve to an existing object, long Name required.
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
trackScale (bool) – Add tracking attributes for tracking the scale of the control, will not appear in channel box
lineWidth (int) – The width of the curve’s lines in pixels, -1 is default and will use global pref settings
rgbColor (list(float)) – rgb color as a linear float [0.1, 0.3, 1.0] If None the color setting will be ignored
- Return curveLongNameList:
If shapeParent returns a list of shape nodes, otherwise returns a list of one transform
- Rtype curveLongNameList:
list(str)
- createControlCurveList(jointList, folderpath='', curveScale=(1.0, 1.0, 1.0), rotateOffset=(0.0, 0.0, 0.0), designName='circle', trackScale=True, lineWidth=-1, rgbColor=None, addToUndo=True)¶
Creates multiple control curves from a joint list, will shape parent the curves
- Parameters:
jointList (str) – the joints to build controls on
curveScale (float) – The size of the curve in Maya units
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
trackScale (bool) – Add tracking attributes for tracking the scale of the control, will not appear in channel box
lineWidth (int) – The width of the curve’s lines in pixels, -1 is default and will use global pref settings
rgbColor (list(float)) – rgb color as a linear float [0.1, 0.3, 1.0] If None the color setting will be ignored
- Return controlCrv:
Each control returns a list of shape nodes, so will be a list(list(shape nodes))
- Rtype controlCrv:
list(list(str))
- groupInPlace(objName, objUuid=None, grpSwapSuffix=False, includeScale=False)¶
Groups an object, with the grp matching the object’s pivot
- Parameters:
objName (str) – Object name to be grouped, usually a joint, should be a unique or longname
objUuid (str) – Optional uuid of the object to be grouped, usually a joints uuid. Will ignore the name.
grpSwapSuffix (bool) – Will swap the suffix, ie jnt “joint1_jnt” grp is named “joint1_grp” not “joint1_jnt_grp”
- Return grp:
The new group name
- Rtype grp:
str
- Return objName:
The object name, now modified if a long name
- Rtype objName:
list
- Return grpUuid:
Optional grp uuid, useful if multiple re-parenting withing a single hierarchy, can return as None
- Rtype grpUuid:
list
- Return objUuid:
Optional obj uuid, useful if multiple re-parenting withing a single hierarchy, can return as None
- Rtype objUuid:
list
- groupInPlaceList(objList, grpSwapSuffix=False)¶
Groups each object from an object list, with each new group matching the object’s pivot and rotation.
Objects will be automatically zeroed in most cases. Handles longnames with uuids. Returns new longnames.
- Parameters:
objList (list) – A list of object list to group individually
grpSwapSuffix (str) – Will remove the suffix, ie jnt “joint1_jnt” grp is named “joint1_grp” not “joint1_jnt_grp”
- Return grpList:
The new groups listed as their long names
- Rtype grpList:
list(str)
- Return objList:
The object list of long names, if long have now probably been modified
- Rtype objList:
list(str)
- createControlsOnJoints(jntList, folderpath='', curveScale=(1.0, 1.0, 1.0), rotateOffset=(0, -90, 90), grpJnts=True, designName='circle', freezeJnts=True, children=False, message=True, rgbColor=(0, 0, 1), suffixControls=True, trackScale=True, lineWidth=-1, addToUndo=True)¶
Creates controls from a given list of joints.
Can group each joint and can freeze transform them too
Control styles can be selected and sized, uses control shape/designs from the shapelib module.
- Parameters:
jntList (list) – The list of joints to be grouped
folderpath (str) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
curveScale (list(float)) – The scale of each control in Maya units. Is measured in radius, not width.
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
grpJnts (bool) – Group the joints, if frozen will cause each joint to be zeroed.
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
freezeJnts (bool) – Freeze the joints to be sure they’re good?
children (bool) – Will create controls for all child joints
message (bool) – Report the messages to the user?
rgbColor (bool) – The color of the control in rgb color (color values should be in linear color)
suffixControls (bool) – Suffix the controls with an underscore and filterTypes.CONTROLLER_SX, usually “ctrl”
trackScale (bool) – Add tracking attributes for tracking the scale of the control, will not appear in channel box
lineWidth (int) – The width of the curve’s lines in pixels, -1 is default and will use global pref settings
- Return controlShapeList:
The control list of shape names
- Rtype controlShapeList:
list(str)
- Return controlList:
The control list of names
- Rtype controlList:
list(str)
- Return grpList:
The group list of names
- Rtype grpList:
list(str)
- createControlsOnSelected(curveScale=(1.0, 1.0, 1.0), folderpath='', rotateOffset=(0, -90, 90), designName='circle', grpJnts=True, children=False, rgbColor=(0, 0, 1), freezeJnts=True, postSelectControls=True, suffixControls=True, trackScale=True, lineWidth=-1, addToUndo=True)¶
Creates curve controls from selected joint/s. Will shape node parent the nurbsCurve shapes to the joints.
Control styles can be selected and sized, uses control shape/designs from the shapelib module. Can auto affect all children so all joints in the chain below the selected joint.
- Parameters:
curveScale (list(float)) – The scale of each control in Maya units. Is measured in radius, not width.
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
children (bool) – Will create controls for all child joints
rgbColor (bool) – The color of the control in rgb color (color values should be in linear color)
freezeJnts (bool) – Freeze the joints to be sure they’re good?
postSelectControls (bool) – If True will select the controls at the end of the function
suffixControls (bool) – Suffix the controls with an underscore and filterTypes.CONTROLLER_SX, usually “ctrl”
trackScale (bool) – Suffix the controls with an underscore and filterTypes.CONTROLLER_SX, usually “ctrl”
lineWidth (int) – The width of the curve’s lines in pixels, -1 is default and will use global pref settings
- Return jntList:
The list of joints that the controls have been added, if longNames and grps, now with new names.
- Rtype jntList:
list(str)
- Return controlShapeList:
A list of list(curve shape nodes), not the transforms as they are the joints
- Rtype controlShapeList:
list(list(str))
- Return grpList:
If grpJnts is a list of all the new groups
- Rtype grpList:
list(str)
- constrainControlsObjList(objList, folderpath='', curveScale=(1.0, 1.0, 1.0), rotateOffset=(0, -90, 90), designName='circle', rgbColor=(0, 0, 1), constrainControls=False, createMasterGrp=True, postSelectControls=True, suffixControls=True, trackScale=True, lineWidth=-1, scaleConstraint=True, float=False, message=True)¶
Creates curve controls from an object list. Will be created in order. Only one chain can be created and no forks.
Uses parent constrain to link the curves into a hierarchy, with many options.
Control styles can be selected and sized, uses control shape/designs uses the shapelib module.
- Parameters:
objList (list(str)) – The object list to create the controls on
folderpath (str) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
curveScale (list(float)) – The scale of each control in Maya units. Is measured in radius, not width.
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
rgbColor (bool) – The color of the control in rgb color (color values should be in linear color)
constrainControls (bool) – Controls can either be constrained (True) to each other or parented (False)
createMasterGrp (bool) – Will create a master root ground to tidy up the controls
postSelectControls (bool) – If True will select the controls at the end of the function
suffixControls (bool) – Suffix the controls with an underscore and filterTypes.CONTROLLER_SX, usually “ctrl”
trackScale (bool) – Suffix the controls with an underscore and filterTypes.CONTROLLER_SX, usually “ctrl”
lineWidth (int) – The width of the curve’s lines in pixels, -1 is default and will use global pref settings
float (bool) – Override where the controls will not be parented to one another, they will be floating
message (bool) – report messages to the user?
- Return objList:
The list of the objects now constrained
- Rtype objList:
list(str)
- Return controlList:
A list of newly created control transform nodes
- Rtype controlList:
list(str)
- Return groupList:
A list of all the new groups for each control
- Rtype groupList:
list(str)
- Return objConstraintList:
A list of the constraints created in order for the selected objects
- Rtype objConstraintList:
list(str)
- Return cntrlConstraintList:
An optional list of the constraints for the control groups. Empty if not used
- Rtype cntrlConstraintList:
list(str)
- Return objScaleConstraintList:
An optional list of scale constraints for the objects. Empty if not used
- Rtype objScaleConstraintList:
list(str)
- Return cntrlScaleConstraintList:
An optional list of scale constraints for the control groups. Empty if not used
- Rtype cntrlScaleConstraintList:
list(str)
- Return masterGrpName:
An optional name of the main group root that all controls are parented into
- Rtype masterGrpName:
str
- constrainControlsHierarchyList(rootObjList, objList, folderpath='', curveScale=(1.0, 1.0, 1.0), rotateOffset=(0, -90, 90), designName='circle', rgbColor=(0, 0, 1), constrainControls=False, createMasterGrp=True, children=False, postSelectControls=True, suffixControls=True, trackScale=True, lineWidth=-1, scaleConstraint=True, float=False, message=True)¶
Creates curve controls from a rootObjList list and objList. Will be created as per the object hierarchy.
Uses parent constrain to link the curves into a hierarchy, with many options.
Control styles can be selected and sized, uses control shape/designs uses the shapelib module.
- Parameters:
objList (list(str)) – The object list to create the controls on
curveScale (list(float)) – The scale of each control in Maya units. Is measured in radius, not width.
folderpath (str) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
rgbColor (list(float)) – The color of the control in rgb color (color values should be in linear color)
constrainControls (bool) – Controls can either be constrained (True) to each other or parented (False)
createMasterGrp (bool) – Will create a master root ground to tidy up the controls
children (bool) – Parent constrains as per the original hierarchy, all objects must be passed in
postSelectControls (bool) – If True will select the controls at the end of the function
suffixControls (bool) – Suffix the controls with an underscore and filterTypes.CONTROLLER_SX, usually “ctrl”
trackScale (bool) – Suffix the controls with an underscore and filterTypes.CONTROLLER_SX, usually “ctrl”
lineWidth (int) – The width of the curve’s lines in pixels, -1 is default and will use global pref settings
float (bool) – Override where the controls will not be parented to one another, they will be floating
message (bool) – report messages to the user?
- Return objList:
The list of the objects now constrained
- Rtype objList:
list(str)
- Return controlList:
A list of newly created control transform nodes
- Rtype controlList:
list(str)
- Return groupList:
A list of all the new groups for each control
- Rtype groupList:
list(str)
- Return objConstraintList:
A list of the constraints created in order for the selected objects
- Rtype objConstraintList:
list(str)
- Return cntrlConstraintList:
An optional list of the constraints for the control groups. Empty if not used
- Rtype cntrlConstraintList:
list(str)
- Return objScaleConstraintList:
An optional list of scale constraints for the objects. Empty if not used
- Rtype objScaleConstraintList:
list(str)
- Return cntrlScaleConstraintList:
An optional list of scale constraints for the control groups. Empty if not used
- Rtype cntrlScaleConstraintList:
list(str)
- Return masterGrpName:
An optional name of the main group root that all controls are parented into
- Rtype masterGrpName:
str
- constrainControlsOnSelected(folderpath='', curveScale=(1.0, 1.0, 1.0), rotateOffset=(0, -90, 90), designName='circle', children=False, rgbColor=(0, 0, 1), constrainControls=False, createMasterGrp=True, postSelectControls=True, suffixControls=True, trackScale=True, lineWidth=-1, scaleConstraint=True, float=False, message=True, addToUndo=True)¶
Creates curve controls from selected objects. Uses parent constrain to link the curves into a hierarchy. Currently only builds one straight chain, no forking.
If children is False will build a parent constrain in the order of selection as per FK If children is True will build a parent constrain in order of the hierarchy as per FK
Control styles can be selected and sized, uses control shape/designs from the shapelib module.
TODO: Support hierarchy TODO: Support multiple chains in hierarchy mode
- Parameters:
folderpath – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
curveScale (list(float)) – The scale of each control in Maya units. Is measured in radius, not width.
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
children (bool) – Will create controls for all child joints
rgbColor (bool) – The color of the control in rgb color (color values should be in linear color)
constrainControls (bool) – Controls can either be constrained (True) to each other or parented (False)
postSelectControls (bool) – If True will select the controls at the end of the function
suffixControls (bool) – Suffix the controls with an underscore and filterTypes.CONTROLLER_SX, usually “ctrl”
trackScale (bool) – Suffix the controls with an underscore and filterTypes.CONTROLLER_SX, usually “ctrl”
lineWidth (int) – The width of the curve’s lines in pixels, -1 is default and will use global pref settings
float (bool) – Override where the controls will not be parented to one another, they will be floating
message (bool) – report messages to the user?
- Return objList:
The list of the objects now constrained
- Rtype objList:
list(str)
- Return controlList:
A list of newly created control transform nodes
- Rtype controlList:
list(str)
- Return groupList:
A list of all the new groups for each control
- Rtype groupList:
list(str)
- Return objConstraintList:
A list of the constraints created in order for the selected objects
- Rtype objConstraintList:
list(str)
- Return cntrlConstraintList:
An optional list of the constraints for the control groups. Empty if not used
- Rtype cntrlConstraintList:
list(str)
- Return objScaleConstraintList:
An optional list of scale constraints for the objects. Empty if not used
- Rtype objScaleConstraintList:
list(str)
- Return cntrlScaleConstraintList:
An optional list of scale constraints for the control groups. Empty if not used
- Rtype cntrlScaleConstraintList:
list(str)
- Return masterGrpName:
An optional name of the main group root that all controls are parented into
- Rtype masterGrpName:
str
- createControlsMatch(folderpath='', matchObj='', newName='newControl', curveScale=(1.0, 1.0, 1.0), rotateOffset=(0, 0, 0), designName='circle', grp=True, rgbColor=(0, 0, 1), lineWidth=-1, addToUndo=True)¶
Creates a control matching the rot and pos of an object does not parent.
If the matchObj is an empty str will create the control at the world center and the new name will be “newControl”
- Parameters:
folderpath (str) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
matchObj (str) – The object to match the control/group to. If empty string will remain at the center of the world
newName (str) – The new name of the control and group if grp=True
curveScale (list(float)) – The scale of each control in Maya units. Is measured in radius, not width.
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
grp (str) – Will group the curve transforms cause the curve transforms to be zeroed
rgbColor (bool) – The color of the control in rgb color (color values should be in linear color)
lineWidth (int) – The width of the curve’s lines in pixels, -1 is default and will use global pref settings
- Return newControl:
the curve transform name
- Rtype newControl:
str
- Return grpList:
the grp if it exists
- Rtype grpList:
str
- createControlsMatchZapi(folderpath='', matchObj='', newName='newControl', curveScale=(1.0, 1.0, 1.0), rotateOffset=(0, 0, 0), designName='circle', grp=True, rgbColor=(0, 0, 1), lineWidth=-1, addToUndo=True)¶
See createControlsMatch, returns zapi objects, not strings
- Return newControl:
The new control created
- Rtype newControl:
zapi.DagNode
- Return newGroup:
The new group created
- Rtype newGroup:
zapi.DagNode
- createControlsMatchList(objList, overrideName='', folderpath='', curveScale=(1.0, 1.0, 1.0), rotateOffset=(0, 0, 0), designName='circle', grp=True, rgbColor=(0, 0, 1), lineWidth=-1, addToUndo=True)¶
Creates control/s from an object list, will match pos and orient but does not parent.
- Parameters:
objList (float) – The scale of each control
folderpath (str) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
curveScale (list(float)) – The scale of each control in Maya units. Is measured in radius, not width.
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
rotateOffset – rotate offset of the control, is a CV rotation offset not object
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
grp (bool) – Will group the curve transforms cause the curve transforms to be zeroed
rgbColor (tuple) – The color of the control in rgb color (color values should be in linear color)
lineWidth (int) – The width of the curve’s lines in pixels, -1 is default and will use global pref settings
- Return controlList:
A list of all the curve transforms
- Rtype controlList:
list(str)
- Return grpList:
a list of all the grps if they exist
- Rtype grpList:
list(str)
- createControlsMatchListZapi(objList, overrideName='', folderpath='', curveScale=(1.0, 1.0, 1.0), rotateOffset=(0, 0, 0), designName='circle', grp=True, rgbColor=(0, 0, 1), lineWidth=-1, addToUndo=True)¶
See createControlsMatch, returns a list of zapi objects, not strings
- Return newControl:
The new controls created
- Rtype newControl:
list[zapi.DagNode]
- Return newGroup:
The new groups created, if no groups created will be list of None
- Rtype newGroup:
list[zapi.DagNode]
- createControlsMatchSelected(folderpath='', curveScale=(1.0, 1.0, 1.0), rotateOffset=(0, 0, 0), designName='circle', grp=True, children=False, rgbColor=(0, 0, 1), lineWidth=-1, addToUndo=True)¶
Creates control/s, if nothing is selected will build the control at world zero. Does not parent.
If an object is selected will build at that objects pivot position. Multiple objects are supported as are children which will build a control on every object in the hierarchy.
- Parameters:
folderpath (str) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
curveScale (list(float)) – The scale of each control in Maya units. Is measured in radius, not width.
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
grp (bool) – Will group the curve transforms cause the curve transforms to be zeroed
children (bool) – Will create controls for all child joints
rgbColor (tuple) – The color of the control in rgb color (color values should be in linear color)
lineWidth (int) – The width of the curve’s lines in pixels, -1 is default and will use global pref settings
- Return controlList:
A list of all the curve transforms
- Rtype controlList:
list(str)
- Return grpList:
a list of all the grps if they exist
- Rtype grpList:
list(str)
- addTrackAttrs(transformName, scale=(1.0, 1.0, 1.0), color=None, rotate=(0.0, 0.0, 0.0), translate=(0.0, 0.0, 0.0), designName='circle')¶
Adds a tracker attributes and sets the scale/color value that can tracked/changed ZOO_SCALE_DEFAULT_ATTR “zooScaleDefault” sets the default scale that generally will not change unless frozen (reset)
- Parameters:
transformName (str) – The name of the transform/joint node, this transform is a control ie has curve shapes
scale (list(float)) – The initial scale size [scaleX, scaleY, scaleZ]
color (list(float)) – The initial color as a linear float [colorR, colorG, colorB]
rotate (list(float)) – The initial rotation values [rotateX, rotateY, rotateZ]
translate (list(float)) – The initial translation values [translateX, translateY, translateZ]
designName (str) – A str Maya attribute value which records the text name eg “circle”
- freezeScaleTracker(controlCurve)¶
Freezes the scale tracker attributes setting them to a scale of 1.0 no matter the current scale
- Parameters:
controlCurve (str) – A control curve with the tracker attributes
- Return success:
True if successful
- Rtype success:
bool
- freezeScaleTrackerList(controlCurveList, message=True)¶
Freezes the scale tracker attributes on a curve list setting them to a scale of 1.0 no matter the current scale
- Parameters:
controlCurveList (list(str)) – A list of control curves with the tracker attributes
- deleteTrackAttrs(controlTransform)¶
Removes the tracking custom attributes on a single control
Attributes are found in:
ZOO_CONTROLTRACK_VECTOR_LIST ZOO_CONTROLTRACK_RGB_LIST ZOO_CONTROLTRACK_STRING_LIST
- Parameters:
controlTransform (str) – The transform node that may contain the tracking attributes
- deleteTrackAttrsList(controlTransformList)¶
Removes the tracking custom attributes on a control list
Attributes are found in:
ZOO_CONTROLTRACK_VECTOR_LIST ZOO_CONTROLTRACK_RGB_LIST ZOO_CONTROLTRACK_STRING_LIST
- Parameters:
controlTransformList (list(str)) – List of control transforms that may contain the tracking attributes
- deleteTrackAttrsSel(message=True)¶
Removes the tracking custom attributes on selection of controls
Attributes are found in:
ZOO_CONTROLTRACK_VECTOR_LIST ZOO_CONTROLTRACK_RGB_LIST ZOO_CONTROLTRACK_STRING_LIST
- Parameters:
controlTransformList (list(str)) – List of control transforms that may contain the tracking attributes
- colorUpdateTracker(cntrl, color)¶
Sets the color tracker attributes for a ctrl, if the tracker doesn’t exist then it doesn’t set anything
- colorUpdateTrackerList(cntrlList, color)¶
Sets the color tracker attributes for a control list, if the tracker doesn’t exist then it doesn’t set anything
- colorControl(cntrl, color, linear=True)¶
Changes the color of a control. Takes linear float color by default. [0.1, 1.0, 0.33]
- colorControlsList(cntrlList, color, linear=True)¶
Changes the color of a list of controls. Takes linear float color by default. [0.1, 1.0, 0.33]
- offsetHSVControl(cntrl, offset, hsvType='hue', linear=True)¶
Colors a control curve transform node name with HSV offsets.
If hue the offset amount (0-360) Can go past 360 or less than 0 Else if saturation or value (brightness) the range is 0-1
- Parameters:
cntrl (str) – The Maya transform name of the selected control
offset (float) – the offset value to offset the color, 0-1 or if hue is 0-360
hsvType (str) – the type to offset, “hue”, “saturation” or “value”
linear (bool) – If linear the color passed in should also be linear (default). If False the color will be SRGB
- offsetHSVControlList(cntrlList, offset, hsvType='hue', linear=True)¶
Colors a control curve list of transform node names with HSV offsets.
If hue the offset amount (0-360) Can go past 360 or less than 0 Else if saturation or value (brightness) the range is 0-1
- Parameters:
cntrlList (list(str)) – The list of Maya control names, joints or transform nodes.
offset (float) – the offset value to offset the color, 0-1 or if hue is 0-360
hsvType (str) – the type to offset, “hue”, “saturation” or “value”
linear (bool) – If linear the color passed in should also be linear (default). If False the color will be SRGB
- getColorControlTransform(controlName)¶
Returns the color of the current control, looks for the color of the first shape node
- Parameters:
controlName (str) – The name of the control
- Return rgbColor:
color in float linear values (1.0, 0.5, 0.1)
- Rtype rgbColor:
list(float)
- scaleValuesFromCurrent(currentScaleXYZ, newScaleXYZ)¶
1 / (current scale / new scale) returns the value that the current scale must be multiplied by
Note: These functions are CV scales, for break-off functions see see scaleBreakConnectCtrl()
- resetScale(controlCurve)¶
Will reset the control scale back to it’s initial value/s, only if the scale tracking attributes have been added
Note: These functions are CV scales, for break-off functions see see scaleResetBrkCnctCtrl()
- Parameters:
controlCurve (str) – the name of the control curve to affect
- resetScaleList(controlList)¶
For a objList resets ctrl scale back to initial value/s, if the scale tracking attributes have been added
Note: These functions are CV scales, for break-off functions see scaleResetBrkCnctCtrlList()
- Parameters:
controlList (list(str)) – list of control curve objects
- resetScaleSelection()¶
From selection resets the ctrl scale back to initial value/s, if the scale tracking attributes have been added
Note: These functions are CV scales, for break-off functions see scaleResetBrkCnctCtrlList()
- setTrackerScaleAbs(controlCurve, scaleXYZ)¶
While absolute scaling controls through the GUI, this function updates the scale track attr ZOO_SCALE_TRACK_ATTR
This is an absolute scale and not an offset
Note: These functions are CV scales, for break-off functions see see scaleBreakConnectCtrl()
- setTrackerScaleOffset(controlCurve, scaleXYZ)¶
While offset scaling controls through the UI, this function updates the scale track attr ZOO_SCALE_TRACK_ATTR
This is a relative scale, not absolute
Note: These functions are CV scales, for break-off functions see see scaleBreakConnectCtrl()
- scaleAndTrackControlList(controlList, scaleXYZ)¶
While offset scaling controls through the UI, this function updates the scale track attr ZOO_SCALE_TRACK_ATTR
This function works on an object list
Note: These functions are CV scales, for break-off functions see see scaleBreakConnectCtrl() etc
- scaleAndTrackControlSelected(scaleXYZ)¶
While CV scaling control curves through the UI, this function updates the scale track attr ZOO_SCALE_TRACK_ATTR
This function works on selected objects
Note: These functions are CV scales, for break-off functions see see scaleBreakConnectCtrl() etc
- Parameters:
scaleXYZ (list(float)) – The amount the control curve has been CV scaled
- scaleControlAbsoluteList(newScaleXYZ, controlList, message=False)¶
Scales the controls to be exactly a certain value. A little tricky due to the vert scale being tracked
Note: These functions are CV scales, for break-off functions see see scaleBreakConnectCtrl() etc
- getCreateControlScale(controlCurve)¶
Returns the ZOO_SCALE_TRACK_ATTR attribute scale if it exists otherwise returns the size of the control measured from the longest edge / 2. Will also create all tracker attrs with defaults if they do not exist.
Control scale is measured in radius not width.
Note: Used while creating controls and setting up the tracker info see getAllTrackerInfo() and addTrackAttrs()
- Parameters:
controlCurve (str) – the name of the control curve to retrieve the scale tracker values
- getControlScaleList(controlCurveList)¶
Returns the ZOO_SCALE_TRACK_ATTR attribute scale if it exists for objList otherwise returns the size of the control measured from the longest edge / 2. Will also create all tracker attrs with defaults if they do not exist.
Control scale is measured in radius not width.
- Parameters:
controlCurveList (list(str)) – list of control names
- getAllTrackerInfo(controlCurve)¶
Returns the zoo tracker attributes, if they don’t exist it will create them with default values.
Scale: Will be automatically created if it doesn’t exist by measuring the bounding box as radius, longest edge / 2 Shape: Will be “circle” if it doesn’t already exist Rotate, Translate: Will be [0.0, 0.0, 0.0] if they don’t exist Color: Will be automatically found from the first shape node’s color
- Parameters:
controlCurve (str) – the name of the control curve to retrieve the attr tracker values
- getControlDefaultScale(controlCurve)¶
Returns the ZOO_SCALE_DEFAULT_ATTR attribute scale if it exists otherwise returns [1.0, 1.0, 1.0]
- Parameters:
controlCurve (str) – The name of the control curve to retrieve the scale tracker values
- replaceWithShapeDesign(controlName, folderpath='', designName='circle', autoScale=True, rotateOffset=(0, 0, 0), message=True, maintainLineWidth=True, addToUndo=True)¶
Replaces the controlName with a new shape design as per designName. Will delete the existing curve shape nodes.
- Parameters:
controlName (str) – The control shape design transform to replace it’s curve
folderpath (str) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
autoScale (bool) – Try to automatically scale the size of the designName replacing the current control?
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
message (bool) – Report the messages to the user?
maintainLineWidth (bool) – If True will keep the line thickness of the previous control (default)
- replaceWithShapeDesignList(controlList, folderpath='', designName='circle', rotateOffset=(0, 0, 0), autoScale=True, message=True)¶
Replaces the controlList with a new shape design as per “designName”. Will delete existing curve shape nodes.
- Parameters:
controlList (list(str)) – The control shape design transform, will replace it’s curve.
folderpath (str) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
autoScale (bool) – Try to automatically scale the size of the designName replacing the current control?
message (bool) – Report the messages to the user?
- replaceWithShapeDesignSelection(folderpath='', designName='circle', rotateOffset=(0, 0, 0), autoScale=True, message=True, keepSelection=True)¶
Replaces the selection with a new shape design as per “designName”. Will delete existing curve shape nodes.
- Parameters:
folderpath (str) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
autoScale (bool) – Try to automatically scale the size of the designName replacing the current control?
message (bool) – Report the messages to the user?
keepSelection (bool) – Maintain the current selection? True is recommended
- replaceDesignBrkCnctCtrl(cntrl, folderpath='', designName='circle', autoScale=True, rotateOffset=(0, 0, 0), maintainLineWidth=True, message=True, addToUndo=True)¶
Replaces a control with a new shape design as per “designName” with break-off functionality. Deletes existing curve shape nodes.
Break-off functionality maintains the ctrl’s offset picot and scale information by using the zoo tracker attrs. For example the replace will maintain any offsets of the control.
- Parameters:
cntrl (str) – The control shape design transform, will replace it’s curve.
folderpath (str) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
autoScale (bool) – Try to automatically scale the size of the designName replacing the current control?
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
message (bool) – Report the messages to the user?
maintainLineWidth (bool) – If True will keep the line thickness of the previous control (default)
- replaceDesignBrkCnctCtrlList(cntrlList, folderpath='', designName='circle', autoScale=True, rotateOffset=(0, 0, 0), message=True, maintainLineWidth=True, addToUndo=True)¶
Replaces a list of controls with a new shape design as per “designName” with break-off functionality. Deletes existing curve shape nodes.
Break-off functionality maintains the ctrl’s offset picot and scale information by using the zoo tracker attrs. For example the replace will maintain any offsets of the control.
- Parameters:
cntrlList (list(str)) – A control transform list of names, will replace their curves.
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
autoScale (bool) – Try to automatically scale the size of the designName replacing the current control?
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
message (bool) – Report the messages to the user?
maintainLineWidth (bool) – If True will keep the line thickness of the previous control (default)
- duplicateControl(controlName, useSelectedName=False, copyScaleTracker=True, deleteNodeShapes=False)¶
Duplicates the object (usually a curve) to it’s own new transform parented to the world, joints become transforms
Useful for breaking off control curves
- Parameters:
- Return duplicatedCtrl:
The new duplicated transform node name
- Rtype duplicatedCtrl:
str
- duplicateControlList(controlList, selectNewCtrls=True, useSelectedName=True, copyScaleTracker=True)¶
Duplicates an obj list with shape nodes to it’s own new transform parented to the world, joints become transforms
- Parameters:
controlList (list(str)) – The control names to break off
selectNewCtrls (bool) – after duplicating select the new controls?
useSelectedName (bool) – Use the name of the control with a suffix to name the new control?
copyScaleTracker (bool) – Copies the scaleTrackerAttributes if they exist on the controlName?
- Return duplicatedCtrlList:
The new duplicated transform node list of names
- Rtype duplicatedCtrlList:
list(str)
- breakoffControlSelected(selectNewCtrls=True, children=False, useSelectedName=True, copyScaleTracker=True, message=True)¶
Duplicates a curve selection to it’s own new list of transforms, parented to the world, joints become transforms
- Parameters:
selectNewCtrls (bool) – after duplicating select the new controls?
children (bool) – Include all children in the hierarchy?
useSelectedName (bool) – Use the name of the control with a suffix to name the new control?
copyScaleTracker (bool) – Copies the scaleTrackerAttributes if they exist on the controlName?
message (bool) – Return the message to the user?
- Return duplicatedCtrlList:
The new duplicated transform node list of names
- Rtype duplicatedCtrlList:
list(str)
- breakTrackControl(ctrlName, applyTempColor=True, tempColor=(1.0, 0.0, 1.0), createNetwork=True)¶
Breaks off a control turning it pink (optional) with a group. Transformations/pivot use the tracker info. A network node (optional) tracks the nodes so they can be easily reconnected back to the original transform or joint.
- Parameters:
ctrlName (str) – The control transform name to break off.
applyTempColor (bool) – If True turns the control pink or the given tempColor
tempColor (bool) – The color of the break off control’s color if applyTempColor is on. Linear float color.
createNetwork (bool) – Create a network node to track the reconnect. Not needed if only using temporarily.
- Return newControlTransform:
The name of the broken off control, empty string if already a broken off control
- Rtype newControlTransform:
str
- Return grp:
The name of the broken off control’s group, empty string if already a broken off control
- Rtype grp:
str
- Return networkName:
The name of the network node used for reconnecting the control back to it’s original node
- Rtype networkName:
str
- breakTrackControlList(ctrlNameList, applyTempColor=True, tempColor=(1.0, 0.0, 1.0), createNetwork=True)¶
Breaks off a list of controls turning them pink (optional) and grouped. Transformations/pivot use the tracker info. A network node (optional) tracks the nodes so they can be easily reconnected back to the original transform or joint.
- Parameters:
ctrlNameList (list(str)) – The list of control transform names to break off.
applyTempColor (bool) – If True turns the control pink or the given tempColor
tempColor (bool) – The color of the break off control’s color if applyTempColor is on. Linear float color.
createNetwork (bool) – Create a network node to track the reconnect. Not needed if only using temporarily.
- Return newControlList:
The names of the broken off controls, empty strings if already broken off
- Rtype newControlList:
list(str)
- Return newGrpList:
The names of the broken off control groups, empty string/s if already a broken off
- Rtype newGrpList:
list(str)
- breakOffControlSelected(applyTempColor=True, tempColor=(1.0, 0.0, 1.0), createNetwork=True, selectControls=True)¶
Breaks off selected of controls turning them pink (optional) and grouped. Transformations/pivot use the tracker info. A network node (optional) tracks the nodes so they can be easily reconnected back to the original transform or joint.
- Parameters:
- Return newControlList:
The names of the broken off controls, empty strings if already broken off
- Rtype newControlList:
list(str)
- Return newGrpList:
The names of the broken off control groups, empty string/s if already a broken off
- Rtype newGrpList:
list(str)
- reconnectBreakControl(breakCntrl, masterCntrl, replaceGrp, ignoreScale=False)¶
Reconnects a break-off control back to it’s master transform or joint node. Will return the control to it’s original color now with the new scale, rot, translation info.
- Parameters:
breakCntrl (str) – The break-off control transform name.
masterCntrl (str) – Master control that will remain, this is the joint or transform node used in scene
replaceGrp (str) – The group of the breakCntrl, will be deleted once finished
ignoreScale (bool) – Can ignore the scale while reconnecting which is only used while flip-mirroring
- reconnectBreakControlList(breakCntrlList, masterCntrlList, replaceGrpList)¶
Reconnects a list of break-off controls back to their master transforms or joint nodes. Will return the controls to their original color now with the new scale, rot, translation info.
- reconnectBreakTempControlNetwork(breakCntrlList)¶
Reconnects a list of break-off controls back to their master transform/joint nodes. Uses network nodes to find the masters. Will return the controls to their original colors with the new scale, rot, translation info. Removes the left over nodes.
- Parameters:
breakCntrlList (list(str)) – A list of break-off control transform names.
- reconnectAllBreakCtrls(message=True)¶
Reconnects all break-off controls in the scene back to their master transform/joint nodes. Uses network nodes to find all the controls to reconnect. Returns the controls to their original colors with the new scale, rot, translation information. Removes the left over nodes.
- Parameters:
message (bool) – Report the message to the user?
- Return masterCtrlList:
A list of master controls that were reconnected
- Rtype masterCtrlList:
list(str)
- scaleBreakConnectCtrl(cntrl, scaleXYZ, relative=True)¶
Scales a control by breakTrackControl(); does the scale in the shapes object space and then reconnects. Break-off uses the zoo tracker information to build the object space.
Use relative=True for offsets and relative=False for setting the absolute scale.
- scaleBreakConnectCtrlList(cntrlList, scaleXYZ, relative=True)¶
Scales a control by breakTrackControl(); does the scale in the shapes object space and then reconnects. Break-off uses the zoo tracker information to build the object space.
Use relative=True for offsets and relative=False for setting the absolute scale.
- Parameters:
- flipBreakConnectCtrl(cntrl, flipAxis='X')¶
Flip-mirrors (mirror for a single control) with breakTrackControl(); does the flip in the shape’s object space and then reconnects. Break-off uses the zoo tracker information to build the object space.
The flipAxis can be “X”, “Y”, or “Z”. Will flip relative to the local space of the break control not the master control.
- flipBreakConnectCtrlList(cntrlList, flipAxis='X')¶
Flip-mirrors (mirror for a single control) a list of controls with breakTrackControl(); does the flip then reconnects. Break-off uses the zoo tracker information to build the object space.
The flipAxis can be “X”, “Y”, or “Z”. Will flip relative to the local space of the break control not the master control.
- rotateBreakConnectCtrl(cntrl, rotateXYZ, relative=True)¶
Rotates a control by breakTrackControl(); does the rotate in the shape’s object space and then reconnects. Break-off uses the zoo tracker information to build the object space.
Use relative=True for offsets and relative=False for setting the absolute rotation. Relative is object space.
- Parameters:
- rotateBreakConnectCtrlList(cntrlList, rotateXYZ, relative=True)¶
Rotates a list of controls with breakTrackControl(); does the rotate in the shape’s object space and then reconnects. Break-off uses the zoo tracker information to build the object space.
Use relative=True for offsets and relative=False for setting the absolute rotation. Relative is object space.
- Parameters:
cntrlList (list(str)) – The list of control transform names to scale.
rotateXYZ (list(float)) – The rotate in [rotateX, rotateY, rotateZ], use relative True to offset or False to set absolutely.
relative (bool) – True for offsetting the current rotation and relative=False for setting the absolute rotation.
- scaleResetBrkCnctCtrl(cntrl)¶
Resets a control scales with breakTrackControl(); as per the zoo tracker stored default scale attribute. Performs the scale in the shape’s object space and then reconnects. Break-off uses the zoo tracker information to build the object space.
- Parameters:
cntrl (str) – The control transform name to scale.
- scaleResetBrkCnctCtrlList(cntrlList)¶
Resets a list of controls with breakTrackControl(); as per the zoo tracker stored default scale attribute. Performs the scale in the shape’s object space and then reconnects. Break-off uses the zoo tracker information to build the object space.
- Parameters:
cntrlList (list(str)) – The list of control transform names to scale.
- rotateResetBrkCnctCtrl(cntrl)¶
Resets a control with breakTrackControl(); as per the zoo tracker stored default rotate attribute. Performs the rotate in the shape’s object space and then reconnects. Break-off uses the zoo tracker information to build the object space.
- Parameters:
cntrl (str) – The control transform name to rotate.
- rotateResetBrkCnctCtrlList(cntrlList)¶
Resets a list of controls with breakTrackControl(); as per the zoo tracker stored default rotate attribute. Performs the rotate in the shape’s object space and then reconnects. Break-off uses the zoo tracker information to build the object space.
- Parameters:
cntrlList (list(str)) – The list of control transform names to scale.
- mirrorControl(currentCntrl, destinationCntrl, mirrorAxis='X', keepColor=True)¶
Mirrors a ctrl curve from the current control to the destination control.
- Parameters:
- Returns:
The destination control now with updated shape nodes.
- Return type:
- checkValidMirrorObj(search, replace, pureName, namespace)¶
Checks if the current control “namespace + pureName” has a mirror with the suffix L R names.
Only used internally in mirrorControlAutoName()
Search “_L” and replace “_R”, name “obj_L_ctrl”, will search for “obj_R_ctrl” and return if found + unique.
- Returns:
mirrorName: If it was found, will be an empty str if nothing found.
unique: True if the mirror control found is unique, False if not unique
- Parameters:
search (str) – The existing suffix or search text eg. “_L”, note does not have to be a suffix eg “control1_L_ctrl”
replace (str) – The new suffix or replace text eg. “_R”, note does not have to be a suffix eg “control1_R_ctrl”
pureName (str) – The existing controls Maya pure name without long or namespace
namespace (str) – The namespace if it exists, will include in the search. Can be empty ie “”
- Return mirrorCtrl:
The name of the mirrorCtrl, will be empty str if not found “”
- Rtype mirrorCtrl:
str
- Return unique:
True only if found and the name is unique in the scene, only one obj found
- Rtype unique:
bool
- mirrorReturnExists(mirrorName, unique, currentCntrl, keepColor, mirrorAxis, message=True)¶
Performs the mirror only if the mirrorName is unique in the scene.
For kwarg docs see mirrorControlAutoName(), only used internally in mirrorControlAutoName()
- Return mirrorName:
The name of the mirror object, will be empty string “” if duplicates
- Rtype mirrorName:
str
- Return unique:
True if the found object mirrorName is unique in the scene? False if duplicates
- Rtype unique:
bool
- mirrorControlAutoName(currentCntrl, searchTags=(('_L', '_R'), ('_lft', 'rgt')), mirrorAxis='X', keepColor=True)¶
Mirrors a single control and tries to automatically find the opposite control if it exists with the searchTags.
If the mirrorObject is found and is also unique then perform the mirror. If not, it won’t mirror.
- Returns:
mirrorName: If it was found, will be an empty str if nothing found.
unique: If True the obj was mirrored, the found mirror ctrl is unique, False if not unique and or not found
- Parameters:
currentCntrl (str) – The control (curve) name to mirror
searchTags (tuple(tuple(str))) – A tuple of tuples, each tuple contains the search and replace text for left and right.
mirrorAxis (str) – The axis to mirror across “X’, “Y” or “Z”
keepColor (bool) – Keep the existing control color if it exists?
- Return mirrorName:
The destination control name, the object that has been mirrored if also unique
- Rtype mirrorName:
str
- Return unique:
True if the mirror object was found and it is unique
- Rtype unique:
bool
- mirrorControlAutoNameList(cntrlList, searchTags=(('_L', '_R'), ('_lft', '_rgt')), mirrorAxis='X', keepColor=True, message=False)¶
Mirrors a control list and tries to automatically find the opposite control if it exists with the searchTags.
If a mirrorObject is found and is also unique then perform the mirror. If not, it won’t mirror.
- Returns a list of lists, each list contains:
mirrorName: If found returns the name of the mirror object, if not found returns an empty str
unique: If True the obj was mirrored, the found mirror ctrl is unique, False if not unique and or not found
- Parameters:
cntrlList (list(str)) – The control list (curve list) names to mirror
searchTags (tuple(tuple(str))) – A tuple of tuples, each tuple contains the search and replace text for left and right.
mirrorAxis (str) – The axis to mirror across “X’, “Y” or “Z”
keepColor (bool) – Keep the existing control color if it exists?
message (bool) – Report the message to the user?
- Return mirrorInfoList:
A list of lists, each list contains the mirrorObj (empty if not found) and if it is unique
- Rtype mirrorInfoList:
list(list(str))
- mirrorControlAutoNameSelected(searchTags=(('_L', '_R'), ('_lft', 'rgt')), mirrorAxis='X', keepColor=True, children=False, message=True)¶
Mirrors a control selection, tries to automatically find the opposite control if it exists with the searchTags.
If a mirrorObject is found and is also unique then perform the mirror. If not, it won’t mirror.
- Returns a list of lists, each list contains:
mirrorName: If found returns the name of the mirror object, if not found returns an empty str
unique: If True the obj was mirrored and the mirror ctrl is unique, False if not unique and or not found
Detailed user messages from mirrorControlAutoNameList() if messages=True
- Parameters:
searchTags (tuple(tuple(str))) – A tuple of tuples, each tuple contains the search and replace text for left and right.
mirrorAxis (str) – The axis to mirror across “X’, “Y” or “Z”
keepColor (bool) – Keep the existing control color if it exists?
children (bool) – Include all children in the hierarchy?
message (bool) – Report the message to the user?
- Return mirrorInfoList:
A list of lists, each list contains the mirrorObj (empty if not found) and if it is unique
- Rtype mirrorInfoList:
list(list(str))
- copyControl(ctrl)¶
Copies the zoo tracker information from a control. Returns:
Translate Rotate Scale Color Shape
While pasting this info is needed in conjunction with the paste control name to paste from.
- Parameters:
ctrl (str) – The transform name of the control
- Return translate:
The zoo tracker translation value as [X, Y, Z]
- Rtype translate:
list(float)
- Return rotate:
The zoo tracker rotation value as [X, Y, Z]
- Rtype rotate:
list(float)
- Return scale:
The zoo tracker scale value as [X, Y, Z]
- Rtype scale:
list(float)
- Return color:
The zoo tracker color value as [R, G, B], color is linear float 0-1
- Rtype color:
list(float)
- Return shape:
The name of the zoo tracker design shape of the control ie “circle”
- Rtype shape:
str
- pasteControl(ctrlList, pasteCtrl, translate, rotate, scale, color, shape)¶
Pastes the curve shape nodes and zoo tracker information onto a list of controls.
- Parameters:
ctrlList (list(str)) – The list of control transform names to paste the control shapes onto.
pasteCtrl (str) – The control transform name to paste the curve shapes from
translate (list(float)) – The zoo tracker translation value as [X, Y, Z]
rotate (list(float)) – The zoo tracker rotation value as [X, Y, Z]
scale (list(float)) – The zoo tracker scale value as [X, Y, Z]
color (list(float)) – The zoo tracker color value as [R, G, B], color is linear float 0-1
shape (str) – The name of the zoo tracker design shape of the control ie “circle”
- templateRefToggle(ctrl, template=True, message=False)¶
Toggles the template or reference attributes of a control.
- templateRefToggleList(ctrlList, template=True, message=False, unTemplateRef=False)¶
Toggles the template or reference attributes of a list of controls.
- orientAimControlsNulls(objList, globalOrientObj)¶
Creates nulls (grps) for orient matching via aims. Also gives global up vectors relative to a globalOrientObj this is a messy function, could be done more cleanly with math instead of using aims, but it works Currently aims controls on y
- Parameters:
objList (list[zapi.DagNode]) – objects for locator positions
globalOrientObj (list[zapi.DagNode]) – The object name that dictates the overall up vector
- Return nullList:
the created locators
- Rtype nullList:
list
- orientControlsAims(controlList, orientGlobalVectorObj=None)¶
Orients a control list so that the controls aim toward each other, useful for splines possibly other The orientGlobalVectorObj gives an overall object up for the scene Aims controls +y and globalObject up is -z
- Parameters:
controlList (list) – the control names
orientGlobalVectorObj (zapi.DagNode) – the object for the world up on aims, uses obj -z (ie spine), if “” will be 1st ctrl
- buildControlsGUI(buildType='Match Selection Only', folderpath='', designName='circle', rotateOffset=(0, -90, 0), scale=(1.0, 1.0, 1.0), children=False, rgbColor=(0, 0, 1), postSelectControls=True, trackScale=True, lineWidth=-1, grp=True, freezeJnts=True, addToUndo=True)¶
Builds controls usually based on the GUI value from the list CONTROL_BUILD_TYPE_LIST:
“Joint, Shape Parent Ctrl” “Match Selection Only” “Constrain Obj, Cnstn Ctrl” “Constrain Obj, Parent Ctrl” “Constrain Obj, Float Ctrl”
- Parameters:
buildType (str) – The type to build
folderpath (str) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
designName (str) – The shape/look/design of the control
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
scale (list(float)) – The scale of each control in Maya units. Is measured in radius, not width.
children (bool) – Will create controls for all children
rgbColor (tuple) – The color of the control in rgb color (color values should be in linear color)
postSelectControls (bool) – If True will select the controls at the end of the function
trackScale (bool) – Suffix the controls with an underscore and filterTypes.CONTROLLER_SX, usually “ctrl”
lineWidth (int) – The width of the curve’s lines in pixels, -1 is default and will use global pref settings
grp (bool) – Group the controls where possible
freezeJnts (bool) – Freeze the joints to be sure they’re good?
- replaceControlCurves(cntrlList, folderpath='', designName='circle', autoScale=True, rotateOffset=(0, 0, 0), message=True, maintainLineWidth=True, deselect=True, addToUndo=True)¶
Replace Control Curves function usually called by GUI as it supports undo
Replaces a list of controls with a new shape design as per “designName” with break-off functionality. Deletes existing curve shape nodes.
Break-off functionality maintains the ctrl’s offset picot and scale information by using the zoo tracker attrs. For example the replace will maintain any offsets of the control.
- Parameters:
cntrlList (list(str)) – A control transform list of names, will replace their curves.
folderpath (list(str)) – Optional folder path of the .shape file. If empty “” then search within the Zoo internal library
designName (str) – The shape/look/design of the control, control names can be found in skeleton builder’s folder
autoScale (bool) – Try to automatically scale the size of the designName replacing the current control?
rotateOffset (list(float)) – rotate offset of the control, is a CV rotation offset not object
message (bool) – Report the messages to the user?
maintainLineWidth (bool) – If True will keep the line thickness of the previous control (default)
deselect (bool) – Will deselect the object after completing
Deformers¶
- createClustersOnCurve(partPrefixName, splineCurve, relative=False, showHandles=False, padding=2)¶
Creates clusters on a curve automatically adding the clusters to each cv in order
- Parameters:
partPrefixName (str) – The prefix, name of the rig/part, optional, can be an empty string (auto), is a shortname
splineCurve (str) – can be a nurbsCurve shape node or transform with nurbsCurve shape, longname preferred
relative (bool) – If True only the transformations directly above the cluster are used by the cluster.
showHandles (bool) – If True show the Maya handles display mode, little crosses on each handle
padding (bool) – The numerical padding
- Return clusterList:
The created cluster names
- Rtype clusterList:
list
- createClustersOnCurveSelection(partPrefixName='', relative=False, showHandles=False)¶
Creates a cluster on each CV of a nurbsCurve of the first selected object.
If a transform selection will check shapes for the first nurbsCurve shape node
- Parameters:
- Return clusterList:
The created cluster names,
- Rtype clusterList:
list(list(str))
Duplicatealongcurve¶
- class DuplicateAlongCurveCore¶
Bases:
object
- classmethod autoWorldUpVector(splineCurve, upVectorName, controlScale=1.0)¶
Creates an arrow attaches it’s grp to the start of the motion path with no follow/orientation for up vector
- classmethod duplicateAlongCurve(sourceObjects, splineCurve, multiplyObjects=5, deleteMotionPaths=False, spacingWeight=0.0, spacingStart=0.0, spacingEnd=1.0, rotationStart=(0, 0, 0), rotationEnd=(0, 0, 0), scaleStart=(1.0, 1.0, 1.0), scaleEnd=(1.0, 1.0, 1.0), worldUpVector=(0, 1, 0), follow=True, worldUpType='scene', group=True, instance=False, upAxis='z', motionPName='moPth', worldUpObject='', followAxis='y', fractionMode=True, inverseFront=False, inverseUp=False, weightPosition=True, weightRotation=True, weightScale=True, autoWorldUpV=False, message=False, duplicateSourceObjects=False, sourceGrp=False)¶
From the selection, object or objects and then a NURBS curve, places objects along a spline using motion paths, added weighting kwarg for non-uniform spacing.
This function will duplicate or instance the objectList by the multiplyObjects value.
Can also use MASH but this will work on joints too. MASH only uses meshes.
The options are mostly Maya’s motionPath kwargs see:
- Parameters:
modifier (om2.MDGModifier) –
sourceObjects (list[zapi.DagNode]) – List of object/s in order to distribute along the curve, will be duplicated by multiplyObjects
splineCurve (zapi.DagNode) – The NURBS spline transform node to distribute the objects along
deleteMotionPaths (bool) – Deletes history so there are no motion paths returned
spacingWeight (float) – The spacing of the objects, 0.5 is uniform. 0.0 weights more towards the start 1.0 to end
spacingStart (float) – The spacing of the objects starts at this ratio along the curve
spacingEnd (float) – The spacing of the objects ends at this ratio along the curve
worldUpVector (float) – The upVector for the joints
group (bool) – Group all objects
instance (bool) – Instance objects instead of duplicating?
follow (bool) – Objects will follow the curve
worldUpType (str) – “scene”, “object”, “objectrotation”, “vector”, or “normal”
upAxis (str) – This flag specifies which object local axis to be aligned a computed up direction. Default is z
motionPName (str) – The suffix name of the motion path example “obj_moPth”
worldUpObject (str) – Obj name if worldUpType “object” or “objectrotation”. Default value is no up object, or world space.
followAxis (str) – Object local axis to be aligned to the tangent of the path curve. Default is y
fractionMode (bool) – Calculate the position as a fraction of curve 0.0-1.0 or distance?
inverseFront (bool) – Invert the follow axis?
- Return motionPathNodes:
The motion path nodes created, a list of names
- Rtype motionPathNodes:
list(str)
- Return objectList:
A full list of objects stuck to the spline in the rig
- Rtype objectList:
list(str)
- Return grp:
The group containing the objects, if no group then will be “”
- Rtype grp:
str
- Return splineCurve:
The spline object
- Rtype splineCurve:
str
- Return upVGrp:
The name of the upVector grp if it was built otherwise “”
- Rtype upVGrp:
str
- Return upVArrow:
The name of the upVector control if it was built otherwise “”
- Rtype upVArrow:
str
- Return upVMoPath:
The name of the upVector motion path if it was built otherwise “”
- Rtype upVMoPath:
str
- classmethod duplicateAlongCurveSelected(multiplyObjects=5, deleteMotionPaths=False, spacingWeight=0.0, spacingStart=0.0, spacingEnd=1.0, rotationStart=(0, 0, 0), rotationEnd=(0, 0, 0), scaleStart=(1.0, 1.0, 1.0), scaleEnd=(1.0, 1.0, 1.0), worldUpVector=(0, 1, 0), follow=True, worldUpType='scene', group=True, instance=False, upAxis='z', motionPName='moPth', worldUpObject='', followAxis='y', fractionMode=True, inverseFront=False, inverseUp=False, weightPosition=True, weightRotation=True, weightScale=True, autoWorldUpV=False)¶
Same as objectsAlongSplineDuplicate() but for selection
The selection is the objects to duplicate and then the curve transform last.
See objectsAlongSplineDuplicate() for documentation
Fcurvescalerig¶
- fCurveProfileScaleJoints(name='hair')¶
This function adds a function curve that acts as a profile scale for a joint chain.
Used in the hair rig setup.
Requires the joints to be all parented to world and y aligned as it takes the y pos of each joint to hookup to the length.
- Parameters:
name (str) – Prefix name of all nodes
- Return curveNode:
The animCurveTU node that is created, this is the function curve
- Rtype curveNode:
str
- Return selJoints:
The joints that the setup was applied to
- Rtype selJoints:
list(str)
- Return frameCacheNodes:
A list of all the frameCacheNodes created, these give the offset
- Rtype frameCacheNodes:
list(str)
Follicles¶
from zoo.libs.maya.cmds.rig import follicles follicles.connectFollicleToSelMesh()
- connectFollicleToShape(shape, follicleShape)¶
Connects a follicle to a new mesh shape node.
- connectFollicleToSelMesh(message=True)¶
Transfers a follicle onto another mesh.
Select one or multiple follicles and then the single mesh to transfer to and run.
Jointsalongcurve¶
- jointsAlongACurve(splineCurve, jointCount=30, jointName='joint', spacingWeight=0.0, spacingStart=0.0, spacingEnd=1.0, secondaryAxisOrient='yup', fractionMode=True, numberPadding=2, suffix=True, buildMetaNode=False, reverseDirection=False, hideCurve=False, message=True)¶
Given a spline curve build joints along the curve, parent and orient them into an FK chain.
- Parameters:
splineCurve (str) – The name of the transform node of the curve
jointCount (int) – The number of joints to build in the chain
jointName (str) – The base name of the joints to be created
spacingWeight (float) – The weighting of the spacing, causes more joints to be sqashed to one end or another 0.0 - 1.0
spacingStart (float) – The start of the curve where the joint chain will start usually 0.0 (start)
spacingEnd (float) – The end of the curve where the joint chain will start usually 1.0 (end)
secondaryAxisOrient (str) – this axis of the joints orients in what direction? Default is “yup”
fractionMode (bool) – calculates in real world coords based on the curve, is affected by the spacing on the CVs.
numberPadding (int) – Pad the joint names with numbers and this padding. ie 2 is 01, 02, 03
suffix (bool) – Add a joint suffix “jnt” to the end of the joint names ie “joint_01_jnt”
buildMetaNode (bool) – builds the meta node for tracking and altering the joints later
reverseDirection (bool) – reverses the curve while building, the reverses it back after build
hideCurve (bool) – hides the incoming curve splineCurve
message (bool) – return any messages to the user?
- Return jointList:
A list of joint string names
- Rtype jointList:
list(str)
- jointsAlongACurveSelected(jointCount=30, jointName='joint', spacingWeight=0.0, spacingStart=0.0, spacingEnd=1.0, secondaryAxisOrient='yup', fractionMode=True, numberPadding=2, suffix=True, buildMetaNode=True, reverseDirection=False)¶
Given a selected spline curve build joints along the curve, parent and orient them into an FK chain.
- Parameters:
jointCount (int) – The number of joints to build in the chain
jointName (str) – The base name of the joints to be created
spacingWeight (float) – The weighting of the spacing, causes more joints to be sqashed to one end or another 0.0 - 1.0
spacingStart (float) – The start of the curve where the joint chain will start usually 0.0 (start)
spacingEnd (float) – The end of the curve where the joint chain will start usually 1.0 (end)
secondaryAxisOrient (str) – this axis of the joints orients in what direction? Default is “yup”
fractionMode (bool) – calculates in real world coords based on the curve, is affected by the spacing on the CVs.
numberPadding (int) – Pad the joint names with numbers and this padding. ie 2 is 01, 02, 03
suffix (bool) – Add a joint suffix “jnt” to the end of the joint names ie “joint_01_jnt”
buildMetaNode (bool) – builds the meta node for tracking and altering the joints later
reverseDirection (bool) – reverses the curve while building, the reverses it back after build
- Return jointListList:
A list of a list of joint string names
- Rtype jointListList:
list(list(str))
- deleteSplineJoints(relatedObjs, message=False)¶
Deletes all joints and the meta node setup related to the selection
- deleteSplineJointsSelected(message=True)¶
Deletes all joints and the meta node setup related to the selection
- Parameters:
message (bool) – report the message to the user
- rebuildSplineJointsSelected(jointCount=30, jointName='joint', spacingWeight=0.0, spacingStart=0.0, spacingEnd=1.0, secondaryAxisOrient='yup', fractionMode=True, numberPadding=2, suffix=True, buildMetaNode=True, reverseDirection=False, message=True, renameMode=False)¶
Deletes all joints and the meta node setup related to the selection and then rebuilds it as per the kwargs
See jointsAlongACurve() for documentation
- Parameters:
renameMode (bool) – If True will use the incoming name to build the new setup. If False will use the existing name
Jointsflowpath¶
- pathGuide(startjoint, endjoint, curve, frontAxis='x', num_of_joints=7, upAxis='y', lattice_value=5)¶
Creates a motion/flow path rig using the joint chain and its selected curve
- Parameters:
- Returns:
- Return type:
Motionpaths¶
- createGroupMatchParent(obj, suffixName='_grp', maintainOffset=False, parentObjOverride='', noParent=False)¶
Creates a grp matched to the obj, then parents it under the same parent.
- Parameters:
- Return grp:
The new group that was created, will be a unique name
- Rtype grp:
str
- createMotionPathRig(obj, curve, group=True, controlObj='', attrName='path', followAxis='z', upAxis='y', worldUpVector=(0, 1, 0), worldUpObject='', worldUpType=3, frontTwist=True, upTwist=True, sideTwist=True, parentConstrain=False, maintainOffset=False, follow=True)¶
Creates a motion path and creates an attribute on the controlObj. Makes motion paths a lot easier to animate. If no controlObj will create the attribute on the obj.
Various options for either constraining to the motion path object or parenting under the motion path object:
group=True, parentConstrain=True - The object is grouped and the group is parent constrained to the follow grp. group=False, parentConstrain=True - The object parent constrained to the follow grp which has the motion path. group=True, parentConstrain=False - The object is parented under the follow grp which has the motion path. group=False, parentConstrain=False - The object has the motion path directly connected to it and attrs added.
Animatable attributes are always added to the main object “obj”, unless a “controlObj” is specified.
- Parameters:
obj (str) – The object to attach to a motion path
curve (str) – The curve that will be the motion path
controlObj (str) – Optional object that the attribute will be assigned to, might be a control, if empty will be obj
attrName (str) – The name of the attribute that will control the animation, default is “path”
followAxis (str) – The axis to follow, default is “z”, can be “x”, “y”, “z”, “-x”, “-y”, “-z”
upAxis – The up vector axis
worldUpVector (tuple(float)) – The up vector x, y, z as a list or tuple (0, 1, 0)
worldUpObject (str) – The object for the object up rotation or object up (aim).
worldUpType (int) – 0 “scene”, 1 “object”, 2 “objectrotation”, 3 “vector”, or 4 “normal”
frontTwist (bool) – Add the attr frontTwist to the controlObj?
upTwist (bool) – Add the attr frontTwist to the controlObj?
sideTwist (bool) – Add the attr frontTwist to the controlObj?
parentConstrain (bool) – parent constriain the obj, or obj’s group, to a follow group which has the motion path
maintainOffset (bool) – Will keep the object in it’s current location, only if parent constrained or grouped.
follow (bool) – Will rotation follow the path, if off only translation is controlled.
- Return motionPath:
The motionPath node that was created
- Rtype motionPath:
str
- Return obj:
The obj possible new long name because of parenting
- Rtype obj:
str
- Return followGrp:
The group that has the motion path on it. Created if group or parentConstrain.
- Rtype followGrp:
str
- Return parentConstrainGrp:
The group parent constrained to the follow group. Created if group and parentConstrain.
- Rtype parentConstrainGrp:
str
- Return controlObj:
The controlObj that receives the attributes. May have a new long name because of parenting.
- Rtype controlObj:
str
- Return constraint:
The parent constraint name. Created if parentConstrain.
- Rtype constraint:
str
- createMotionPathRigSel(curve='', group=True, attrName='path', followAxis='z', upAxis='y', worldUpVector=(0, 1, 0), worldUpObject='', worldUpType=3, frontTwist=True, upTwist=True, sideTwist=True, parentConstrain=False, maintainOffset=False, follow=True, message=True)¶
Creates a motion path and creates an attribute on the controlObj from the current selection and a potential UI. Makes motion paths a lot easier to create and animate by copying the driving attributes onto the object itself.
Supports multiple object selection, the curve path object should be selected last if it not given directly.
- Parameters:
curve (str) – The curve that will be the motion path
group (bool) – Group the object so that the motion path is on the group, not on the selected objects
attrName (str) – The name of the attribute that will control the animation, default is “path”
followAxis (str) – The axis to follow, default is “z”, can be “x”, “y” or “z”
upAxis – The up vector axis
worldUpVector (tuple(float)) – The up vector x, y, z as a list or tuple (0, 1, 0)
frontTwist (bool) – Add the attr frontTwist to the controlObj?
upTwist (bool) – Add the attr frontTwist to the controlObj?
sideTwist (bool) – Add the attr frontTwist to the controlObj?
parentConstrain (bool) – parent constrain the obj, or obj’s group, to a follow group which has the motion path
maintainOffset (bool) – Will keep the object in it’s current location, only if parent constrained or grouped.
follow (bool) – Will rotation follow the path, if off only translation is controlled.
message (bool) – Report a message to the user?
- Return motionPaths:
The motionPath node that was created
- Rtype motionPaths:
str
- Return objs:
The obj possible new long name because of parenting
- Rtype objs:
str
- Return followGrps:
The group that has the motion path on it. Created if group or parentConstrain.
- Rtype followGrps:
str
- Return parentConstrainGrps:
The group parent constrained to the follow group. Created if group and parentConstrain.
- Rtype parentConstrainGrps:
str
- Return controlObjs:
The controlObj that receives the attributes. May have a new long name because of parenting.
- Rtype controlObjs:
str
- Return constraints:
The parent constraint name. Created if parentConstrain.
- Rtype constraints:
str
- setCurveObj(obj)¶
Checks the curve given in the UI is a curve and it exists with a unique name.
- setCurveObjSelection()¶
Returns the curve for UI code. Must be a nurbsCurve object.
- Return surfaceObject:
The first selected nurbsCurve object.
- Rtype surfaceObject:
str
- setUpObj(obj)¶
Checks the object given in the UI is a transform and it exists with a unique name.
- setUpObjSelection(selectLast=True)¶
Returns an object for UI code. Must be a transform node.
- Return surfaceObject:
The first selected object (transfrom node)
- Rtype surfaceObject:
str
- createArrowControl(ctrlName, controlScale)¶
Creates an arrow control for the up vector, with pivot correctly placed.
Nodes¶
- conditionMulti(driverAttr, drivenAttrList, value, suffix='')¶
Creates a condition node, on/off values to multiple nodes useful for visibility and constraint switching Common to use this multiple times on the same driverAttr
- createNetworkNodeWithConnections(nodeName, attributeName, connectionList, createNetworkNode=True)¶
Creates a new network node with connections to all nodes in the connection list via message connections Handy for rigging and keeping track of connected objects to delete or handle later, like metadata
- messageNodeObjs(networkNodeName, nodeList, connectAttr, createNetworkNode=True)¶
Connects all nodes in the list to a network node
The network node can be handy later, when we want to delete the cube array and all objects connected to it
- Parameters:
networkNodeName (str) – the name of the network node, can exist or will be created, see kwarg createNetworkNode
nodeList (list) – list of Maya node names strings (nodes)
connectAttr (str) – the attribute on each node to connect to
createNetworkNode (bool) – Option to create the network node, or if False, connect to an existing node
- Return networkNodeName:
The name of the network node created, Maya name string
- Rtype networkNodeName:
str
- getNodeAttrConnections(nodeList, attributeName, shapes=False)¶
Returns a list of network nodes connected to the given objects/nodes, searches nodes by their attribute name For each object find if it has an network node attached
Note: Known issues regarding shapes not being returned in some tool code, should fix all references to shapes = True Shapes=True will return the shape node if that’s the connected node, so should be always on. Need to check all tools
- Parameters:
- Return connectedNodes:
list of unique network nodes connected to the objects
- Rtype connectedNodes:
list
- getNodesFromNetworkNodeAttr(networkNode, attribute)¶
From a network node return the nodes connected via the attribute name
Parentfk¶
- parentGroupControls(controlList, groupList, reverse=False, long=False)¶
Parents controls with groups into a simple hierarchy, zeroing the controls, can be reversed in order
- Parameters:
controlList (list[zapi.DagNode]) – list of the controls
groupList (list[zapi.DagNode]) – list of groups of the controls
reverse (boolean) – If True reverse the parent hierarchy
- Return controlList:
A list of controls as zapi objects
- Rtype controlList:
list[zapi.DagNode]
- Return groupList:
A list of groups as zapi objects
- Rtype groupList:
list[zapi.DagNode]
Reparentgrouptoggle¶
Creates and toggles parenting of groups containing ‘_zooParentToRig’ into and out of _zooParentToRig Based on first object being in world or not
- createGroupToRig(parentName, wildcardSuffix='_zooParentToRig', matchObject=True, message=True)¶
Creates a group with the name of a unique parentName short name and the wildcard suffix. Will match the new group to the parent.
Creates and matches new group:
“parentName_zooParentToRig”
- Parameters:
parentName (str) – The short name name of the parent obj, will create “parentName_zooParentToRig”
wildcardSuffix (str) – The suffix of the group name, needs this name for toggling
matchObject (bool) – If True then match the objects only if parenting
message (bool) – Report the success message to the user?
- Return groupName:
The name of the group that was created
- Rtype groupName:
str
- createGroupToRigSelected(wildcardSuffix='_zooParentToRig', matchObject=True, message=True)¶
Creates a group with the name of the selected obj and the wildcard suffix. Will match the new group to the parent. Only one object should be selected and must be a transform or a joint.
Creates and matches new group:
“parentName_zooParentToRig”
- parentReparentGrp(reparentGrp, parent=True, wildcardSuffix='_zooParentToRig', matchObject=True, message=True)¶
Either “Parents and matches” or “Unparents” a single reparent grp
- Parameters:
reparentGrp (str) – The name of the reparent group
parent (bool) – If True will parent, if False will parent to world (unparent)
wildcardSuffix (str) – The suffix of the group name, needs this name for toggling
matchObject (bool) – If True then match the objects only if parenting
message (bool) – Report a message to the user?
- Return success:
True if the parent or unparent was successful
- Rtype success:
list(str)
- parentReparentGrpScene(parent=True, wildcardSuffix='_zooParentToRig', matchObject=True, message=True)¶
Either “Parents and matches” or “Unparents” a single reparent grp for the entire scene
- Parameters:
- Return success:
True if the parent or unparent was successful
- Rtype success:
list(str)
- toggleReparentGrps(reparentGrps, wildcardSuffix='_zooParentToRig', matchObject=True, selectGrps=True, message=True)¶
Toggles a list of reparent grps either in or out of their parent targets/world
- Parameters:
reparentGrps (list(str)) – A list of reparent groups, can be parented or unparented
wildcardSuffix (str) – The suffix of the group name, needs this name for toggling
matchObject (bool) – Will match the grp to its parent, False will skip
selectGrps (bool) – Selects all reparent groups after finishing, False does not select
message (bool) – Report messages to the user?
- Return reparentGrps:
A list of all the reparent objects that were toggled.
- Rtype reparentGrps:
list(str)
- Return successList:
A list of booleans confirming if the parent or reparent was successful
- Rtype successList:
list(bool)
- toggleReparentGrpsScene(wildcardSuffix='_zooParentToRig', matchObject=True, selectGrps=True, message=True)¶
Toggles all reparent grps in the scene either in or out of their parent targets/world
- Parameters:
reparentGrps (list(str)) – A list of reparent groups, can be parented or unparented
wildcardSuffix (str) – The suffix of the group name, needs this name for toggling
matchObject (bool) – Will match the grp to its parent, False will skip
selectGrps (bool) – Selects all reparent groups after finishing, False does not select
message (bool) – Report messages to the user?
- Return reparentGrps:
A list of all the reparent objects that were toggled.
- Rtype reparentGrps:
list(str)
- Return successList:
A list of booleans confirming if the parent or reparent was successful
- Rtype successList:
list(bool)
Riggingmisc¶
Module for assorted rigging related functions
Examples:
Example use:
# Unlock and unhide all nodes in a hierarchy.
from zoo.libs.maya.cmds.rig import riggingmisc
riggingmisc.markCenterPivot(name="")
# Unlock and unhide all nodes in a hierarchy.
from zoo.libs.maya.cmds.rig import riggingmisc
riggingmisc.unlockUnhideAll()
Author: Andrew Silke
- markCenterPivot(name='')¶
Creates a locator with display handles on at the center pivot of the selection.
Uses a cluster to mark the center point and then deletes it.
- Return locator:
The newly created locator
- Rtype locator:
str
- deleteAllCenterPivots()¶
Deletes all the pivot locators in the scene named “tempPivot_loc”
- bakeNamespaces()¶
replaces a namespace : character with _ on an object selection list:
[“rig:polyCube1”, “rig:polyCube2”] becomes [“rig_polyCube1”, “rig_polyCube2”]
- selectionHighlightList(objs, highlight=True, message=True)¶
Turns on or off selection highlight for an object list. Attribute selectionChildHighlighting
If True then highlighting is on, if False then children are not highlighted when selected.
Maya preferences must be set to “Use Object Highlight Setting”:
Windows > Settings Preferences > preferences > Settings > Selection > Selection Child Highlighting
- selectionHighlightSelected(highlight=True)¶
Turns on or off selection highlight for an object list. Attribute selectionChildHighlighting
If True then highlighting is on, if False then children are not highlighted when selected.
See selectionHighlightList() for more information.
- Parameters:
highlight (bool) – If True then highlighting is on, if False then children are not highlighted when selected.
- unlockUnhideAll()¶
Unlocks and unhides everything selected
Splinebuilder¶
Example code:
from zoo.libs.maya.cmds.rig import splinebuilder rigName = “rigX” jointList = [“joint1”, “joint2”,”joint3”, “joint4”, “joint5”, “joint6”, “joint7”, “joint8”, “joint9”] splinebuilder.buildSpine(rigName, jointList, controlCount=5, scale=1.0)
- class SplineBuilder(rigName, jointList, controlCount=5, scale=1.0, fk=True, revFk=True, flt=True, spine=True, stretchy=True, cogUpAxis='Auto', message=True, buildType=1, ikHandleBuild=None, addToUndo=True, splineCurve=None, useProvidedCurve=False)¶
Bases:
object
Main class that builds the spline rig with multiple control types and various switching functionality
- firstLastControls()¶
Returns the first and the last controls of the first available control set
- returnAllNodes()¶
Returns all nodes collected in this class
- Return allNodes:
A list of nodes and lists of nodes
- Rtype allNodes:
list
- buildAll(buildType, autoOrientRoot=False, message=True)¶
Main method that builds the spline rig
- validStartEndJoint(startJoint, endJoint, warning=True)¶
UI help function to check if the user has added the start and end joint correctly.
Checks if endJoint is a descendant of (parented somewhere under the) startJoint
- Return valid:
True if the end Joint is a descendant of startJoint
- Rtype valid:
bool
- buildSpineJoints(rigName, jointList=None, startJoint='', endJoint='', controlCount=5, scale=1.0, buildFk=True, buildRevFk=True, buildSpine=True, buildFloat=True, cogUpAxis='Auto', message=True, buildType=0, ikHandleBuild=None, addToUndo=True, splineCurve=None)¶
Builds the spine rig
- Parameters:
rigName (str) – The name of the rig
jointList (list(str)) – list of joints to add to the spline
controlCount (int) – The amount of controls to build, will be 5 if a spine
scale (float) – The scale of the rig, affects the controls
buildFk (bool) – Builds the Fk controls part of the rig
buildRevFk (bool) – Builds the Reverse Fk controls part of the rig
buildSpine (bool) – Builds the Spine controls part of the rig
buildFloat (bool) – Builds the Floating controls part of the rig
cogUpAxis (str) – The up axis of the cog control, “+y” or “-x” etc, “Auto” will figure the axis automatically.
- Return splineInstance:
The instance of the spline class
- Rtype splineInstance:
object
- Return allNodes:
See splineBuilder.returnAllNodes() for all nodes
- Rtype splineInstance:
Splinerigswitcher¶
Switching Spline Rig, match switches the controls on the Spline Rig
Current Mode to FK example:
from zoo.libs.maya.cmds.rig import splinerigswitcher splinerigswitcher.switchMatchSplineMode(‘fk’, switchObj=”splineRig_cog_ctrl”, selectControls=True)
- retrieveSpineControlList(meta)¶
Gets the current spline mode (spine, fk, float or revFk) and retrieves all control and joint settings.
This function is for spline switching not building.
Returns as a tuple:
spineList: the spine control list(str)
fkList: the fk control list(str)
floatList: the float control list(str)
revFkList: the revFk control list(str)
spineMidRot: The middle control of the Spine setup as a str, if doesn’t exist will be None
currentMode: The current spline mode, what controls are we currently seeing? eg “revFk” string
controlTypesList: A list(str) of all the controls by mode that exist eg [“fk”, “spline”]
firstJoint: The first joint full name str
lastJoint: The last joint full name str
- switchToSplineMode(switchMode, spineList, fkList, floatList, revFkList, spineMidRot, currentMode, controlTypesList, firstJoint, lastJoint, selObjs=None, switchObj='root_ctrl', selectControls=True)¶
Does the switching for the spline to a given mode ‘spine’, ‘fk’, ‘float’, ‘revFk’
- Parameters:
switchMode (str) – The spline mode to switch to, ‘spine’, ‘fk’, ‘float’, ‘revFk’
spineList (list) – The spline list of controls
fkList (list) – The fk list of controls
floatList (list) – The floating list of controls
revFkList (list) – The fk list of controls
currentMode (str) – What mode is the spline in now?
controlTypesList (list) – A list of all the controls by mode that exist eg [“fk”, “spline”]
firstJoint (str) – first joint name in the rig
lastJoint (str) – last joint name in the rig
selObjs (list) – The selected objects
switchObj (str) – The object that controls the spline
selectControls (bool) – Should we select the matching control on the new set and deselect the old?
- switchOrientNulls(currentControlList, matchExact=False)¶
This creates a bunch of group nulls and positions and orients them to match the objectList.
The up vector of all joints is based off the first joint (z up) and the last control off the lastJoint (z up).
- Parameters:
- Return nullList:
A list of nulls that have been created to match the new control positions to
- Rtype nullList:
list(str)
- switchMatchSplineMode(switchMode, meta, switchObj='root_ctrl', selectControls=True)¶
Main function for spline space switching. Switch the spline to a mode can be… ‘spine’, ‘fk’, ‘float’, ‘revFk’
- Parameters:
switchMode (str) – The spline mode to switch to, ‘spine’, ‘fk’, ‘float’, ‘revFk’
meta (zoo.libs.maya.cmds.meta.metasplinerig.MetaSplineRig) –
switchObj (str) – The object that controls the spine with the enum attribute
selectControls (bool) – Select the switched controls after the switch?
Splines¶
- WORLD_UP_SCENE = 'scene'¶
Misc
- stepWeightCalculate(spacingWeight, steps)¶
Given the steps and spacing weight returns a list. Ignores negative values and makes them positive.
Works off powers. The spacing weight is a power + 1:
Spacing weight of 0.0 will be a power of 1.0 Spacing weight of 1.0 will be a power of 2.0 etc
Returns a list of spacing values to multiply, the range is normalized from 0.0-1.0:
Spacing weight: 0.0 with 4 steps returns [1.0, 1.0, 1.0, 1.0, 1.0, 1.0] Spacing Weight: 1.0 with 4 steps returns [0.25, 0.5, 0.7499999999999999, 1.0] Spacing Weight: 2.0 with 4 steps returns [0.0625, 0.25, 0.5625, 1.0]
- Parameters:
- Return stepList:
A list of values now weighted depending on the spacingWeight [0.25, 0.5, 0.7499999999999999, 1.0]
- Rtype stepList:
list(float)
- calculateSpacing(spacingWeight, steps, startValue, endValue)¶
Returns spacing values in the 0-1 range
- Parameters:
- Return spacingValueList:
The spacing value list normalized from 0.0-1.0 range
- Rtype spacingValueList:
list(float)
- objectsAlongSpline(objectList, splineCurve, deleteMotionPaths=False, spacingWeight=0.0, spacingStart=0.0, spacingEnd=1.0, rotationStart=(0.0, 0.0, 0.0), rotationEnd=(0.0, 0.0, 0.0), scaleStart=(1.0, 1.0, 1.0), scaleEnd=(1.0, 1.0, 1.0), worldUpVector=(0.0, 1, 0.0), follow=True, worldUpType='scene', upAxis='z', motionPName='moPth', worldUpObject='', followAxis='y', fractionMode=True, inverseFront=False, inverseUp=False, weightPosition=True, weightRotation=True, weightScale=True)¶
Places objects along a spline using motion paths, added weighting kwarg for non-uniform spacing.
The options are mostly Maya’s motionPath kwargs see:
- Note:
Make sure you are in centimeters for the motion path to be created correctly, this is a maya bug.
- Parameters:
objectList (list(str)) – List of objects in order to distribute along the curve
splineCurve (str) – The NURBS spline transform node to distribute the objects along
deleteMotionPaths (bool) – Deletes history so there are no motion paths returned
spacingWeight (float) – The spacing of the objects, 0.5 is uniform. 0.0 weights more towards the start 1.0 to end
spacingStart (float) – The spacing of the objects starts at this ratio along the curve
spacingEnd (float) – The spacing of the objects ends at this ratio along the curve
rotationStart (tuple or list) – The twist offset start of all objects (frontTwist, upTwist, sideTwist)
rotationEnd (tuple or list) – The twist offset end of all objects (frontTwist, upTwist, sideTwist)
worldUpVector (float) – The upVector for the joints
follow (bool) – Objects will follow the curve
worldUpType (str) – “scene”, “object”, “objectrotation”, “vector”, or “normal”
upAxis (str) – This flag specifies which object local axis to be aligned a computed up direction. Default is z
motionPName (str) – The suffix name of the motion path example “obj_moPth”
worldUpObject (str) – Obj name if worldUpType “object” or “objectrotation”. Default value is no up object, or world space.
followAxis (str) – Object local axis to be aligned to the tangent of the path curve. Default is y
fractionMode (bool) – Object local axis to be aligned to the tangent of the path curve. Default is y
inverseFront (bool) – Invert the follow axis?
inverseUp (bool) – Invert the up axis?
- Return motionPathNodes:
The motion path nodes created a salist of names
- Rtype motionPathNodes:
list(str)
- calculateRangeSpacing(spacingWeight, steps, startValue, endValue, rotStart, rotEnd, scaleStart, scaleEnd, weightPosition, weightRotation, weightScale)¶
Returns the spacing values adjusted for range
- Parameters:
- Return spacingValueList:
The spacing value list now adjusted to the start and end range
- Rtype spacingValueList:
list(float)
- clusterTransforms(clusterPairs, transform=True)¶
Lazy helper function to return the transforms in the cluster list annoying nested list that should be a list of dicts.
Input:
[[clusterName, clusterTransformName], [clusterName2, clusterTransformName2]]
- Returns:
[clusterTransformName, clusterTransformName2]
- of if transform = False then:
[clusterTransformName, clusterTransformName2]
- createSplineIk(partPrefixName, jointChain, curveSpans=2, curve=None)¶
Creates spline ik with given curve spans from a joint list
- Parameters:
- Return splineIkList:
0 = ?, 2 = ?, 3 = The Curve
- Rtype splineIkList:
list
- Type:
curve: class:zapi.DagNode
- Return splineSolver:
spline solver name
- Rtype splineSolver:
str
- buildSplineCogControl(partPrefixName, clusterList, scale=1.0, suffixName='cog', upAxis='+y', addToUndo=True)¶
Builds a cog control at the first cluster
- Parameters:
- Return cogControl:
the control name
- Rtype cogControl:
zapi
- Return cogGroup:
the group name
- Rtype cogGroup:
zapi
- buildSplineUpVectors(partPrefixName, clusterList, suffixName='upV', scale=1.0, addToUndo=True)¶
Builds the up vector controls for spline rig based on global variable settings
- Parameters:
partPrefixName (str) – The name of the part prefix “eg spine”
clusterList (list) – Cluster names, up vector goes on the first and the last with constraints
suffixName (str) – name of the control parts
scale (float) – overall scale multiplier of the controls
addToUndo (bool) – Handles whether the zoo command undo queue is on or off re zapi
- Return upVBaseCtrl:
The up vector control base
- Rtype upVBaseCtrl:
zapi
- Return upVBaseGroup:
The up vector group base
- Rtype upVBaseGroup:
zapi
- Return upVEndCtrl:
The up vector control end
- Rtype upVEndCtrl:
zapi
- Return upVEndGroup:
The up vector group base
- Rtype upVEndGroup:
zapi
- Return pConstraintBase:
The parent constraint node base
- Rtype pConstraintBase:
zapi
- Return pConstraintEnd:
The parent constraint node end
- Rtype pConstraintEnd:
zapi
- buildControlsSplineFk(partPrefixName, clusterList, scale=1.0, suffixName='fkSpline', orientControls=True, orientGlobalVectorObj='', controlColor=(1.0, 1.0, 0.0), addToUndo=True)¶
Builds controls for a spline cluster in regular fk
- Parameters:
partPrefixName (str) – The name of the part prefix “eg spine”
clusterList (list) – Cluster names must be 5 total
scale (float) – overall scale multiplier of the controls
suffixName (str) – name of the second half of the controls, will also have _i on the end
orientGlobalVectorObj (zapi.DagNode) – the object for the world up on aims, uses obj -z (ie spine), if “” will be 1st ctrl
controlColor (tuple) – control color in rgb float srgb (0, 0, 1)
- Return fkControlList:
control names created
- Rtype fkControlList:
list
- Return fkGroupList:
group names created
- Rtype fkGroupList:
list
- buildControlsSplineRevfk(partPrefixName, clusterList, scale=1.0, suffixName='revfkSpline', orientControls=True, orientGlobalVectorObj='', controlColor=(0.0, 0.0, 1.0), addToUndo=True)¶
Builds controls for a spline cluster in reversed fk
- Parameters:
partPrefixName (str) – The name of the part prefix “eg spine”
clusterList (list) – Cluster names must be 5 total
scale (float) – overall scale multiplier of the controls
suffixName (str) – name of the second half of the controls, will also have _i on the end
orientGlobalVectorObj (str) – the object for the world up on aims, uses obj -z (ie spine), if “” will be 1st ctrl
controlColor (tuple) – control color in rgb float srgb (0, 0, 1)
- Return revfkControlList:
control names created
- Rtype revfkControlList:
list
- Return revfkGroupList:
grp names created
- Rtype revfkGroupList:
list
- buildControlsSplineFloat(partPrefixName, clusterList, scale=1.0, suffixName='floatSpline', orientControls=True, orientGlobalVectorObj='', controlColor=(0.0, 1.0, 1.0), addToUndo=True)¶
Builds controls for a spline cluster floating (no parenting)
- Parameters:
partPrefixName (str) – The name of the part prefix “eg spine”
clusterList (list) – Cluster names must be 5 total
scale (float) – overall scale multiplier of the controls
suffixName (str) – name of the second half of the controls, will also have _i on the end
orientGlobalVectorObj (str) – the object for the world up on aims, uses obj -z (ie spine), if “” will be 1st ctrl
controlColor (tuple) – control color in rgb float srgb (0, 0, 1)
- Return floatControlList:
control names created
- Rtype floatControlList:
list
- Return floatControlList:
grp names created
- Rtype floatControlList:
list
- buildControlsSplineSpine(partPrefixName, clusterList, scale=1.0, extraRotation=True, orientControls=True, orientGlobalVectorObj='', controlColor=(1, 0, 0), midCntrlColor=(0, 1, 0), addToUndo=True)¶
builds the controls for a simple spline spline This is 5 main controls with a rotation offset extra mid control, so 6 controls in all Expects the cluster list to match to 5 clusters of the main controls
- Parameters:
- Return spineControlList:
The five main control names
- Rtype spineControlList:
list
- Return spineGroupList:
The five control group names
- Rtype spineGroupList:
list
- Return otherConstraintList:
The constraints needed by the part
- Rtype otherConstraintList:
list
- Return spineRotControl:
The cntrl and grp name of the extra rotation control
- Rtype spineRotControl:
list
- createEnumList(fkControlList, fkGroupList, revfkControlList, revfkGroupList, floatControlList, floatGroupList, spineControlList, spineGroupList)¶
gets a list of the keys in mainControls for the drop down name list “controlEnumList”
- Parameters:
fkControlList (list) – list of the fk controls, can be empty
fkGroupList (list) – list of the fk srt groups, can be empty
revfkControlList (list) – list of the revFk controls, can be empty
revfkGroupList (list) – list of the revFk srt groups, can be empty
floatControlList (list) – list of the float controls, can be empty
floatGroupList (list) – list of the float srt groups, can be empty
spineControlList (list) – list of the spine controls , can be empty
spineGroupList (list) – list of the spine srt groups, can be empty
- Return controlEnumList:
list for the enum dropdown attribute [“spine”, “fk”, “revFk”, “float”] etc
- Rtype controlEnumList:
list
- Return controlDict:
dictionary with the control lists, enum values as keys
- Rtype controlDict:
list
- Return controlGrpDict:
dictionary with the control grps, enum values as keys
- Rtype controlGrpDict:
list
- constrainControls(constrainToList, controlEnumList, controlDict, rigName)¶
Constrains the spline to the controls, no switching, needs setupConditionNodesConstraints() later
- Parameters:
- Rtype controlEnumList:
list
- Return objConstraintList:
list of the constraint names created
- Rtype objConstraintList:
list
- setupConditionNodesConstraints(controlEnumList, controlDict, controlGrpDict, objConstraintList, rigName, driverAttr, spineRotGrp)¶
setup condition node switching for constraints and vis switching
- Parameters:
controlEnumList – list for the enum dropdown attribute [“spine”, “fk”, “revFk”, “float”] etc
controlDict (dict) – dictionary with the control lists, enum values as keys
controlGrpDict (dict) – dictionary with the srt grp lists, enum values as keys
objConstraintList (list[zapi.DagNode]) – list of the constraint names created
rigName (str) – the name of the rig
driverAttr (str) – the attribute name that drives the switching i think?
- Rtype controlEnumList:
list
- Return hchySwitchCondPnts:
condition node name for switching parents
- Rtype hchySwitchCondPnts:
str
- Return hchySwitchCondVis:
condition node name for switching visibility
- Rtype hchySwitchCondVis:
str
- constrainToControls(fkControlList, fkGroupList, revfkControlList, revfkGroupList, floatControlList, floatGroupList, spineControlList, spineGroupList, clusterList, switchAttrObject, rigName, spineRotGrp, switchAttrName='hierarchySwitch')¶
Main function that constrains the spline to various control structures, can be multiple, empty control lists aren’t created. Constraints are all hooked up to condition nodes for vis and parent switching
- Parameters:
fkControlList (list) – list of the fk controls, can be empty
fkGroupList (list) – list of the fk srt groups, can be empty
revfkControlList (list) – list of the revFk controls, can be empty
revfkGroupList (list) – list of the revFk srt groups, can be empty
floatControlList (list) – list of the float controls, can be empty
floatGroupList (list) – list of the float srt groups, can be empty
spineControlList (list) – list of the spine controls , can be empty
spineGroupList (list) – list of the spine srt groups, can be empty
clusterList (list) – list of the spline cluster names
switchAttrObject (str) – the object where the switching attributes will be built
rigName (str) – the name of the rig
switchAttrName (str) – the name of the switch attribute ‘hierarchySwitch’
- Return controlEnumList:
list for the enum dropdown attribute [“spine”, “fk”, “revFk”, “float”] etc
- Rtype controlEnumList:
list
- Return driverAttr:
the attribute name that drives the switching i think?
- Rtype driverAttr:
str
- Return hchySwitchCondPnts:
condition node name for switching parents
- Rtype hchySwitchCondPnts:
str
- Return hchySwitchCondVis:
condition node name for switching visibility
- Rtype hchySwitchCondVis:
str
- Return objConstraintList:
list of the constraint names created
- Rtype objConstraintList:
list
- createMessageNodeSetupSpline(messageManager, fkControlList, revfkControlList, floatControlList, spineControlList, spineRotControl)¶
Connects the message nodes to the spine controls
- Parameters:
messageManager (str) – the message node name
fkControlList (list) – list of the fk controls, can be empty
revfkControlList (list) – list of the revFk controls, can be empty
floatControlList (list) – list of the float controls, can be empty
spineControlList (list) – list of the spine controls, can be empty
spineRotControl (str) – the extra spine rot control for the spine setup name
- cleanupSplineRig(fkGroupList, revfkGroupList, floatGroupList, spineGroupList, clusterList, rigName, splineIkList, splineSolver, jointList, spineRotControl, cogControl, cogGroup, scaleGroup)¶
Parents the objects so that the spine rig all sits under one group. Creates extra groups, hides unwanted grps
- Parameters:
fkGroupList –
revfkGroupList –
floatGroupList –
spineGroupList –
clusterList –
rigName –
splineIkList –
splineSolver –
jointList –
spineRotControl –
cogControl (zapi.DagNode) –
cogGroup (zapi.DagNode) –
scaleGroup –
- advancedSplineIkTwist(splineIk, objStart, objectEnd, startVector=(0, 0, -1), endVector=(0, 0, -1))¶
Sets up advanced ik twist on existing splineIK handle Currently obj rot up start and end
- jointStretchMultiplySetup(joints, curveInfo, splineCurve)¶
Sets up the “stretch” part of a squash/stretch component for a regular spline ik chain Returns a blend node (and multiplyDivideA) which can blend between the stretch and the non stretch modes The blend node attribute should later be hooked up to the controls
- Parameters:
- Return splineMultiplyNode:
multiply/divide node
- Rtype splineMultiplyNode:
str
- Return splineStretchBlendTwoAttr:
spline stretch blend node
- Rtype splineStretchBlendTwoAttr:
str
- Return multiplyStretchNodes:
multiply nodes created if the joints have uneven lengths. Will be empty list if even.
- Rtype multiplyStretchNodes:
list
- jointSquashMaintainScale(joints, forceMaintainNodes)¶
Maintains the scale or the rig on joints Y and Z scale. Needed for creating the rig if the joints have / non uniform scale values. Creates an extra multiplyDivide node for every joint.
If all joints are set to 1.0 then skip the creation of these extra multiply and divide nodes. of forceMaintainNodes = True will always build the extra nodes as can be useful for extra scale control
- Parameters:
- Return maintainScaleNodes:
A list of multiplyDivide nodes created, will be an empty list if skipped.
- Rtype maintainScaleNodes:
list(str)
- jointSquashMultiplySetup(joints, splineCurve, curveInfo, splineMultiplyNode, maintainScale=True, forceMaintainNodes=True)¶
Sets up the stretch part of a squash/stretch component for a regular spline ik chain Returns a blend node (and multiplyDivideB) which can blend between the stretch and the non stretch modes also builds and returns the curve info node for measuring the length of the spline curve The blend node attribute should later be hooked up to the controls
- Parameters:
- Return splineSquashBlendTwoAttr:
spline stretch blend 2 node
- Rtype splineSquashBlendTwoAttr:
str
- Return splineMultiplyNode2:
multiply/divide 2 node
- Rtype splineMultiplyNode2:
string
- createStretchy(splineCurve, joints, forceMaintainNodes=True)¶
Builds the squash and stretch setup for regular spline ik The blend nodes are needed for later setup when assigning attributes to the controls (.attributesBlender attrs) Squash and Stretch can be mixed/multiplied independently Returned nodes curveInfo: node to measure the length of a curve splineMultiplyNode: multiplies to find the offset for x (length joints)
- Parameters:
splineCurve (str) – the spline curve name
joints (list) – the joint list
- Return curveInfo:
the curve info node
- Rtype curveInfo:
str
- Return splineMultiplyNode:
the spline multiply node, multiplies to find the offset for x (length joints)
- Rtype splineMultiplyNode:
str
- Return splineMultiplyNode2:
the second spline multiply node?
- Rtype splineMultiplyNode2:
str
- Return splineStretchBlendTwoAttr:
the stretch blend two node name also used for attribute too I think
- Rtype splineStretchBlendTwoAttr:
str
- Return splineSquashBlendTwoAttr:
the stretch blend two node name aslo used for attribute too I think
- Rtype splineSquashBlendTwoAttr:
str
- Return multiplyStretchNodes:
the multiplyDivide stretch nodes
- Rtype multiplyStretchNodes:
list
- stretchyConnectCntrlAttributes(stretchBlend, squashBlend, controlObj)¶
Adds and connects the squash and stretch setup to a control and creates 2 attributes - squash - stretch for multiplying the squash and stretch
- Parameters:
stretchBlend (zapi.DagNode) – the stretch blend node
squashBlend (str) – the squash blend node
controlObj (zapi.DagNode) – the control object where the control attributes go
- stretchyWorldScaleMod(cogControl, splineMultiplyNode2, rigName)¶
A mod that fixes world scale to the squash and stretch spline setup.
Creates a grp that is scale constrained to the cog, this will keep world scale info, needs to be parented later.
The scale_grp then feeds into a multiple node doubling it’s size, this can be plugged into the splineMultiplyNode2 to maintain world scale while scaling the entire rig.
- Parameters:
- Return scaleGroup:
The name of the scaleGrp that was created to measure world scale of the rig.
- Rtype scaleGroup:
str
- Return scaleMultiplyNode:
The new multiply node that doubles the scaleGrp size
- Rtype scaleMultiplyNode:
str
- Return scaleGroupConstraint:
The scale constraint node, connects the cogControl to the scaleGrp
- Rtype scaleGroupConstraint:
str
- all_same(items)¶
tests if all items in a list are the same
- Parameters:
items (list) – any python list
- Return same:
True if all items are the same
- Rtype same:
bool
- jointListLengthSame(jointList)¶
checks to see if all the lengths of joints are the same ignoring the first joint
- Parameters:
jointList (list) – joint names
- Return lengthSame:
is every joint the same distance apart?
- Rtype lengthSame:
bool
- controlsClusterCurve(splineCurve, partPrefixName='', scale=(1.0, 1.0, 1.0), design='cube', relative=False, showHandles=False, rgbColor=(0.0, 0.0, 1.0), padding=2)¶
Creates clusters parented to controls from a spline curve. The spline be a transform or a nurbsCurve shape
- Uses:
deformers.createClustersOnCurve() controls.createControlsMatchList()
- Parameters:
splineCurve (str) – The name of the spline curve to create the clusters, can be a transform or a nurbsCurve shape
partPrefixName (str) – The prefix, name of the rig/part, optional, can be an empty string (auto), is a shortname
relative (bool) – If True only the transformations directly above the cluster are used by the cluster.
showHandles (bool) – If True show the Maya handles display mode, little crosses on each handle
padding (int) – The numerical padding
scale (tuple(float)) – The scale size of the curves to be created in x y z (1.0, 1.0, 1.0)
design (str) – The name of the shape to create from the shape library
- Return splineCurve:
The name of the splineCurce as it could be renamed
- Rtype splineCurve:
str
- controlsClusterCurveSelected(partPrefixName='', scale=(1.0, 1.0, 1.0), design='cube', relative=False, showHandles=False, rgbColor=(0.0, 0.0, 1.0), padding=2, message=True)¶
Creates clusters parented to controls from a selected spline curve.
- Parameters:
partPrefixName (str) – The prefix, name of the rig/part, optional, can be an empty string (auto), is a shortname
relative (bool) – If True only the transformations directly above the cluster are used by the cluster.
showHandles (bool) – If True show the Maya handles display mode, little crosses on each handle
padding (int) – The numerical padding
scale (tuple(float)) – the scale size of the curves to be created in x y z (1.0, 1.0, 1.0)
design (str) – the name of the shape to create from the shape library
message (bool) – Report the message to the user?
- Return splineTransform:
the spline transform name, empty string if none found
- Rtype splineTransform:
str
- getClusterCurveNetworkNodes(nodeList)¶
From a node list return the Cluster Curve Network node/s
- Parameters:
nodeList (list) – Any objects related to the controlsClusterCurve() setup, auto finds network nodes
- Return networkNodeList:
A list of network nodes, one for each Cluster Curve Spline rig
- Rtype networkNodeList:
- deleteClusterCurve(nodeList, deleteSpline=False, deleteHistory=True, message=True)¶
Removes the rig, and optionally the original spline curve of a controlsClusterCurve() setup
Pass in any object/s of the Cluster Curve Rig, will find the associated network nodes and delete the rig/setup.
- Parameters:
nodeList (list) – Any objects related to the controlsClusterCurve() setup, auto finds all objects from network nodes
deleteSpline (bool) – If True deletes the whole setup including the original spline curve, False leaves the spline.
deleteHistory (bool) – If the spline is left, delete it’s history so that it doesn’t assume it’s old shape.
message (bool) – Report the message to the user
- deleteClusterCurveSelected(deleteSpline=False, message=True)¶
From selected removes the rig, and optionally the original spline curve of a controlsClusterCurve() setup
- visControlsClusterCurve(controls, splineCurve, show=True)¶
Shows or hides the controls of Cluster Curve rig/s. Main curve is template/un-templated
- toggleVisClusterCurve(nodeList, message=True)¶
Toggles the controls of Cluster Curve rig/s. Main curve is template/un-templated
- Parameters:
nodeList (list) – Any objects related to the controlsClusterCurve() setup, auto finds all objects from network nodes
message (bool) – Report the message to the user?
- toggleVisClusterCurveSelected(message=True)¶
Toggles the controls of Cluster Curve rig/s from any selected object on the rig. Main curve is template/un-templated
- Parameters:
message (bool) – Report the message to the user?
- toggleTemplateClusterCurve(nodeList, message=False)¶
Toggles the template state of the main curve on the ClusterCurve rig.
- Parameters:
nodeList (list) – Any objects related to the controlsClusterCurve() setup, auto finds all objects from network nodes
message (bool) – Report the message to the user?
- toggleTemplateClstrCrvSelected(message=True)¶
Toggles template state of the main curve in the Cluster Curve rig/s from any selected rig object.
- Parameters:
message (bool) – Report the message to the user?
- getClstrCrvSelected(message=True, attr='clstrC_cntrlsTrack')¶
Returns a list of control curves from any selected control on the rig
- autoWorldUpVector(splineCurve, upVectorName, controlScale=1.0)¶
Creates an arrow attaches it’s grp to the start of the motion path with no follow/orientation for up vector
- objectsAlongSplineDuplicate(sourceObjects, splineCurve, multiplyObjects=5, deleteMotionPaths=False, spacingWeight=0.0, spacingStart=0.0, spacingEnd=1.0, rotationStart=(0, 0, 0), rotationEnd=(0, 0, 0), scaleStart=(1.0, 1.0, 1.0), scaleEnd=(1.0, 1.0, 1.0), worldUpVector=(0, 1, 0), follow=True, worldUpType='scene', group=True, instance=False, upAxis='z', motionPName='moPth', worldUpObject='', followAxis='y', fractionMode=True, inverseFront=False, inverseUp=False, weightPosition=True, weightRotation=True, weightScale=True, autoWorldUpV=False, message=False)¶
From the selection, object or objects and then a NURBS curve, places objects along a spline using motion paths, added weighting kwarg for non-uniform spacing.
This function will duplicate or instance the objectList by the multiplyObjects value.
Can also use MASH but this will work on joints too. MASH only uses meshes.
The options are mostly Maya’s motionPath kwargs see:
- Parameters:
sourceObjects (list(str)) – List of object/s in order to distribute along the curve, will be duplicated by multiplyObjects
splineCurve (str) – The NURBS spline transform node to distribute the objects along
deleteMotionPaths (bool) – Deletes history so there are no motion paths returned
spacingWeight (float) – The spacing of the objects, 0.5 is uniform. 0.0 weights more towards the start 1.0 to end
spacingStart (float) – The spacing of the objects starts at this ratio along the curve
spacingEnd (float) – The spacing of the objects ends at this ratio along the curve
worldUpVector (float) – The upVector for the joints
group (bool) – Group all objects
instance (bool) – Instance objects instead of duplicating?
follow (bool) – Objects will follow the curve
worldUpType (str) – “scene”, “object”, “objectrotation”, “vector”, or “normal”
upAxis (str) – This flag specifies which object local axis to be aligned a computed up direction. Default is z
motionPName (str) – The suffix name of the motion path example “obj_moPth”
worldUpObject (str) – Obj name if worldUpType “object” or “objectrotation”. Default value is no up object, or world space.
followAxis (str) – Object local axis to be aligned to the tangent of the path curve. Default is y
fractionMode (bool) – Calculate the position as a fraction of curve 0.0-1.0 or distance?
inverseFront (bool) – Invert the follow axis?
fractionMode – Calculates in real world coords based on the curve, is affected by the spacing on the CVs.
- Return motionPathNodes:
The motion path nodes created, a list of names
- Rtype motionPathNodes:
list(str)
- Return objectList:
A full list of objects stuck to the spline in the rig
- Rtype objectList:
list(str)
- Return grp:
The group containing the objects, if no group then will be “”
- Rtype grp:
str
- Return splineCurve:
The spline object
- Rtype splineCurve:
str
- Return upVGrp:
The name of the upVector grp if it was built otherwise “”
- Rtype upVGrp:
str
- Return upVArrow:
The name of the upVector control if it was built otherwise “”
- Rtype upVArrow:
str
- Return upVMoPath:
The name of the upVector motion path if it was built otherwise “”
- Rtype upVMoPath:
str