Definition

Main api access for component data

class GuideLayerDefinition(dag: 'list' = <factory>, metaData: 'list[definitionattrs.AttributeDefinition]' = <factory>, settings: 'list' = <factory>, dg: "'NamedGraphs'" = <factory>)

Bases: LayerDef

dg: NamedGraphs
classmethod fromData(layerData)

Transforms the provided data in to a set of guide and attribute classes. Each class created inherits from dict

Parameters:

layerData (dict) – The guide layer data

Returns:

Returns a new GuideLayer definition

Return type:

GuideLayerDefinition

serialize()

Returns a plain dict representation of this layer, suitable for JSON encoding and for round-tripping through fromData().

Return type:

dict

update(kwargs)
classmethod defaultGuideSettings()

Default guide settings

Return type:

list[baseDef.AttributeDefinition]

classmethod mergeDefaultSettings(newState)
classmethod defaultMetadataSettings()

Default guide settings

Return type:

list[baseDef.AttributeDefinition]

classmethod mergeDefaultMetaData(newState)
iterGuides(includeRoot=True)

Generator Function that iterates all guides.

Return type:

Generator(definitionnodes.GuideDefinition)

hasGuides()
guideCount(includeRoot=True)
guide(guideId)

Returns the definitionnodes.GuideDefinition instance that is attached to this Definition instance.

Parameters:

guideId (str) – The guide id value

Return type:

definitionnodes.GuideDefinition or None

findGuides(*ids)

Finds and returns all guides with the specified ids.

Parameters:

ids (iterable[str]) – The guide Ids

Returns:

The guides requested in the order provided.

Return type:

generator[definitionnodes.GuideDefinition]

hasGuideSetting(name)

Returns True if the guide Setting by its already exists.

Parameters:

name (str) – The Guide Setting name

Return type:

bool

addGuideSetting(setting)

Appends a new guide setting to this definition

Parameters:

setting (definitionattrs.AttributeDefinition) – Setting object describing the guide setting

addGuideSettings(settings)

Appends new guide settings to this definition

Parameters:

settings (list[definitionattrs.AttributeDefinition]) – A list of Setting objects describing the guide setting.

guideSetting(name)

Returns the guide setting with the given name.

Parameters:

name (str) – the guide setting to return

Returns:

Returns the guide setting

Return type:

definitionattrs.AttributeDefinition or None

iterGuideSettings()
guideSettings(*names)

Returns all matching guide settings attributes as a dict.

Parameters:

names (iterable[str]) – The Guide Settings attribute names to retrieve.

Returns:

attributeName: attributeDefinition

Return type:

dict[str, definitionattrs.AttributeDefinition]

deleteGuides(*guideIds)
deleteSettings(attributeNames)

Deletes all guide settings based on the provided attributeNames.

Parameters:

attributeNames (iterable[str]) – The list of attribute names to delete.

deleteSetting(name)

Deletes a group of setting by name from the layer node.

Parameters:

name (str) – The Settings name to remove.

Returns:

Whether deletion was successful.

Return type:

bool

addGuide(guide)

Appends a new definitionnodes.GuideDefinition to this definition

Parameters:

guide (definitionnodes.GuideDefinition) – The guide definition to add

hasGuide(guideId)
createGuide(**info)
setGuideParent(child, parent)
class RigLayerDefinition(dag: 'list' = <factory>, metaData: 'list[definitionattrs.AttributeDefinition]' = <factory>, settings: 'dict' = <factory>, dg: "'NamedGraphs'" = <factory>)

Bases: LayerDef

settings: dict
dg: NamedGraphs
classmethod fromData(layerData)

Transforms the provided data in to a set of Rig and attribute classes. Each class created inherits from dict

Parameters:

layerData (dict) – The rig layer data

Returns:

Returns a new RigLayer definition

Return type:

RigLayerDefinition

serialize()

Returns a plain dict representation of this layer, suitable for JSON encoding and for round-tripping through fromData().

Return type:

dict

update(kwargs)
setSettingValue(nodeName, name, value)

Sets the value for a setting.

Parameters:
  • name (str) – The settings name

  • value (int, float, string, list, dict) – The json compatible value to set

addSetting(nodeName, **kwargs)

Adds a setting(attribute) for the node to the definition.

Parameters:
  • nodeName (str) – The node name to attach the setting to, if the node already exists in the definition then it will be appended else a new entry will be added.

  • kwargs (dict) – dict see definitionattrs.AttributeDefinition for more information.

Returns:

The new settings instance.

Return type:

definitionattrs.AttributeDefinition or None

Keyword Arguments:
  • name – The Name for the setting. Type: str.

  • value – The json supported python value. Type: int, float, str or iterable.

  • default – The json supported python value. Type: int, float, str or iterable.

  • Type – The attribute type int, see: zoo.libs.maya.api.attrtypes. Type: int.

  • softMin – The softMin(UI) for the attribute, only valid for numeric Attrs. Type: float.

  • softMax – The softMax(UI) for the attribute, only valid for numeric Attrs. Type: float.

  • min – The min for the attribute, only valid for numeric Attrs. Type: float or int.

  • max – The max for the attribute, only valid for numeric Attrs. Type: float or int.

  • locked – Whether this attribute should be locked. Type: bool.

  • channelBox – Whether this attribute should be displayed in the channelBox. Type: bool.

  • keyable – Whether this attribute should be keyable by an animator. Type: bool.

addSettings(nodeName, settingsDefs)
insertSettingByName(nodeName, name, settingDef, before=False)

Inserts a setting either before or after the existing setting by the given name.

Parameters:
  • nodeName (str) – The node name to attach the setting to, if the node already exists in the definition then it will be appended else a new entry will be added.

  • name (str) – The name of existing setting.

  • settingDef (definitionattrs.AttributeDefinition or Dict) – The new Setting to insert.

  • before (bool) – If True then the Setting will be added before the found Setting

Returns:

Whether the attribute was successfully inserted.

Return type:

bool

insertSetting(nodeName, index, settingDef)

Inserts a setting either before or after the existing setting by the given name.

Parameters:
  • nodeName (str) – The node name to attach the setting to, if the node already exists in the definition then it will be appended else a new entry will be added.

  • index (int) – The index to insert the Setting:

  • settingDef (definitionattrs.AttributeDefinition or Dict) – The new Setting to insert.

Returns:

Whether or not the attribute was successfully inserted.

Return type:

bool

insertSettings(nodeName, index, settingDefs)
settingIndex(nodeName, name)
deleteSettings(nodeName, names)

Deletes a group of settings from the layer node.

Parameters:
  • nodeName (str) – The setting node name to search for settings.

  • names (list[str]) – A list of setting names to search and remove.

Returns:

Whether deletion was successful.

Return type:

bool

deleteSetting(nodeName, name)

Deletes a group of setting by name from the layer node.

Parameters:
  • nodeName (str) – The setting node name to search for the setting.

  • name (str) – The Settings name to remove.

Returns:

Whether deletion was successful.

Return type:

bool

setting(nodeName, name)

Return’s the definitionattrs.AttributeDefinition instance attached to the node in this definition if it exists.

Parameters:
  • nodeName (str) – the node that the setting is part of

  • name (str) – the settings name

Return type:

definitionattrs.AttributeDefinition

nodeSettings(nodeName)

Returns the settings for the given node.

Parameters:

nodeName (str) – the node name.

Return type:

definitionattrs.AttributeDefinition

class InputLayerDefinition(dag: 'list' = <factory>, metaData: 'list[definitionattrs.AttributeDefinition]' = <factory>, settings: 'list' = <factory>)

Bases: LayerDef

classmethod fromData(layerData)

Transforms the provided data in to a set of InputNode and attribute classes. Each class created inherits from dict

Parameters:

layerData (dict) – The input layer data

Returns:

Returns a new InputLayer definition

Return type:

InputLayerDefinition

serialize()

Returns a plain dict representation of this layer, suitable for JSON encoding and for round-tripping through fromData().

Return type:

dict

update(kwargs)
input(name)

Returns the input node.

Parameters:

name (str) – the id of the input node.

Returns:

the input

Return type:

definitionnodes.InputDefinition

iterInputs()

Generator Function that iterates all input definitions.

Return type:

Generator(definitionnodes.InputDefinition)

clearInputs()

Deletes all input nodes from this definition

addInput(inputDef)

Adds an input to this definition.

Parameters:

inputDef (definitionnodes.InputDefinition) – The InputDefinition for the input

createInput(**info)
inputSetting(name)

Returns the input setting from this definition

Parameters:

name (str) – the input name

Return type:

definitionattrs.AttributeDefinition or None

addInputSetting(**kwargs)

Appends a new input setting to this definition

Parameters:

kwargs – the input Setting instance

Return type:

definitionattrs.AttributeDefinition or None

deleteInputs(*inputIds)
class OutputLayerDefinition(dag: 'list' = <factory>, metaData: 'list[definitionattrs.AttributeDefinition]' = <factory>, settings: 'list' = <factory>)

Bases: LayerDef

classmethod fromData(layerData)

Transforms the provided data in to a set of OutputNode and attribute classes. Each class created inherits from dict

Parameters:

layerData (dict) – The output layer data

Returns:

Returns a new OutputLayer definition

Return type:

OutputLayerDefinition

serialize()

Returns a plain dict representation of this layer, suitable for JSON encoding and for round-tripping through fromData().

Return type:

dict

update(kwargs)
output(name)
iterOutputs()

Generator Function that iterates all input definitions.

Return type:

iterable(definitionnodes.OutputDefinition)

clearOutputs()

Deletes all output nodes from this definition

createOutput(**info)
addOutput(outputDef)

Adds an output to this definition.

Parameters:

outputDef (definitionnodes.OutputDefinition) – The output definition

outputSetting(name)

Returns the output setting from this definition

Parameters:

name (str) – the output name

Return type:

definitionattrs.AttributeDefinition or None

addOutputSetting(**kwargs)

Appends a new output setting to this definition

Parameters:

kwargs (definitionattrs.AttributeDefinition) – the output Setting instance

deleteOutputs(*outputIds)
class DeformLayerDefinition(dag: 'list' = <factory>, metaData: 'list[definitionattrs.AttributeDefinition]' = <factory>, settings: 'list' = <factory>)

Bases: LayerDef

classmethod fromData(layerData)

Transforms the provided data in to a set of Joint and attribute classes. Each class created inherits from dict

Parameters:

layerData (dict) – The Deform layer data

Returns:

Returns a new DeformLayer definition

Return type:

DeformLayerDefinition

serialize()

Returns a plain dict representation of this layer, suitable for JSON encoding and for round-tripping through fromData().

Return type:

dict

update(kwargs)
classmethod defaultMetadataSettings()

Default guide settings

Return type:

list[baseDef.AttributeDefinition]

classmethod mergeDefaultMetaData(newState)
clearJoints()
createJoint(**info)
joint(jointId)

Returns the JointDefinition instance by the provided the id.

Parameters:

jointId (str) – The joint id to filter.

Return type:

definitionnodes.JointDefinition or None

setParentJoint(jointId, parentJointId)

Parents ‘jointId’ def to the ‘parentJointId’ def. Takes care of any internals

Parameters:
  • jointId

  • parentJointId

Returns:

Return type:

bool

findJoints(*ids)

Returns the JointDefinition instance by the provided the id.

Parameters:

ids (tuple[str]) – The joint ids to filter.

Return type:

list[definitionnodes.JointDefinition]

addJoint(jointDef)

Adds a joint to this definition.

Parameters:

jointDef (definitionnodes.JointDefinition) – The output definition

iterDeformJoints()

Returns the definitionnodes.JointDefinition instance that is attached to this Definition instance.

Return type:

definitionnodes.JointDefinition or None

deleteJoints(*jointIds)

Deletes the joints from the layer based on the provided joint ids.

Parameters:

jointIds (tuple[str]) – The joint ids to search for.

class NamedGraphs(iterable=(), /)

Bases: list

List of NamedGraph instances.

classmethod fromData(layerData)

Transforms the provided data in to a set of Joint and attribute classes. Each class created inherits from dict

Parameters:

layerData (dict) – List of dicts where each dict is a named graph

Returns:

Returns a new DeformLayer definition

Return type:

NamedGraphs

serialize()

Returns a plain list-of-dicts representation of the contained graphs, suitable for JSON encoding and for round-tripping through fromData().

Return type:

list[dict]

graph(graphId)

Returns the graph instance.

Parameters:

graphId (str) – The graph id to search for.

Return type:

NamedGraph or None

class NamedGraph(id='', name='', nodes=<factory>, connections=<factory>, inputsData=<factory>, outputsData=<factory>, metaData=<factory>)

Bases: object

Contains a network of Dependency graph nodes, and it’s internal connections

id: str = ''
name: str = ''
nodes: list
connections: list
inputsData: dict
outputsData: dict
metaData: dict
classmethod fromData(graphData)

Parses the provided graphData and creates a NamedGraph instance.

Parameters:

graphData (dict) – The Raw Graph data to parse into a NamedGraph

Returns:

The newly created NamedGraph instance.

Return type:

NamedGraph

serialize()

Returns a plain dict representation of this graph, suitable for JSON encoding and for round-tripping through fromData().

Return type:

dict

property graphId: str

Returns the graph id,

node(nodeId)

Returns the node instance in the graph for the provided nodeId

Parameters:

nodeId (str) – The node id to search for

Returns:

Return type:

definitionnodes.DGNode or None

inputs()
outputs()
class TransformDefinition(id='', name='control', children=<factory>, parent=None, hiveType='transform', type='transform', rotateOrder=0, _translate=<factory>, _rotate=<factory>, _scale=<factory>, attributes=<factory>, extras=<factory>)

Bases: object

Base Hive node definition, describing a single transform in a Hive component’s dag (guide, joint, input, output or control).

Field defaults below describe every property a plain transform node can have; subclasses override individual defaults and add their own additional fields.

Note:

This class shouldn’t be instantiated directly other than for SRT definitions, use one of the subclasses.

Construct via deserialize() when starting from a raw definition dict (the common case, data loaded from disk/scene/user input) – it handles defaulting, type coercion (translate/rotate/scale to tuples, attribute dicts to definitionattrs.AttributeDefinition), recursive child construction and preserving any unrecognized/legacy keys. The plain constructor only does field assignment, matching normal dataclass semantics.

id: str = ''
name: str = 'control'
children: list
parent: str | None = None
hiveType: str = 'transform'
type: str = 'transform'
rotateOrder: int = 0
attributes: list
extras: dict
update(other=None, **kwargs)

Bulk in-place merge, blindly overwriting matching keys – matches the semantics of the builtin dict.update() that node instances relied on when they were plain dict subclasses.

Parameters:
  • other – A dict or another node instance to merge from.

  • kwargs – Additional key/value pairs to merge, applied after other.

property translate: MockExt.OpenMaya.MVector

Worldspace translation as a zapi.Vector. Bracket/.get("translate") access returns the raw tuple instead (see _translate).

property rotate

Worldspace rotation as a zapi.EulerRotation (raw tuple length 3) or zapi.Quaternion (raw tuple length 4). Bracket/.get("rotate") access returns the raw tuple instead (see _rotate).

property scale: MockExt.OpenMaya.MVector

Worldspace scale as a zapi.Vector. Bracket/.get("scale") access returns the raw tuple instead (see _scale).

property matrix

Legacy/transient worldspace matrix override, only present when explicitly set (not a declared field – backed by extras["matrix"], raises KeyError like the old ObjectDict-based access did when unset).

property worldMatrix

Worldspace transformation matrix, composed from translate/rotate/scale.

attribute(attributeName)
Parameters:

attributeName (str) – str

Return type:

definitionattrs.AttributeDefinition or None

iterChildren(recursive=True)

Generator function to recursively iterate through all children of this control

Return type:

Generator(TransformDefinition)

classmethod deserialize(data, parent=None)

Given a Definition compatible dict (or another node instance) recursively convert all children to Definitions and then return a new cls.

Parameters:
  • data (dict) – Same data as this class data.

  • parent (str) – The parent transform definition id.

Return type:

TransformDefinition

serialize()

Returns a plain dict representation of this node (and its children), suitable for JSON encoding and for round-tripping through deserialize().

Return type:

dict

copy()
deleteChild(childId)

Deletes a child definition from this transform.

..note: Only filters on the immediate transform children not recursively.

If found then deletion will occur recursively. ie. all the childs children.

Parameters:

childId (str) – The child transform to delete

Returns:

True if child was deleted.

Return type:

bool

transformationMatrix(translate=True, rotate=True, scale=True)

Returns the world zapi.TransformationMatrix instance for the current Definition.

Note

Requires the translate, rotate, scale keys on the definition. Rotate order key will be applied as well.

Parameters:
  • translate (bool) – Include the translation part in the returned matrix

  • rotate (bool) – Include the rotation part in the returned matrix

  • scale (bool) – Include the scale part in the returned matrix

Return type:

zapi.TransformationMatrix

class JointDefinition(id='', name='joint', children=<factory>, parent=None, hiveType='joint', type='transform', rotateOrder=0, _translate=<factory>, _rotate=<factory>, _scale=<factory>, attributes=<factory>, extras=<factory>)

Bases: TransformDefinition

A deform joint. See TransformDefinition for field descriptions.

name: str = 'joint'
hiveType: str = 'joint'
class InputDefinition(id='', name='input', children=<factory>, parent=None, hiveType='input', type='transform', rotateOrder=0, _translate=<factory>, _rotate=<factory>, _scale=<factory>, attributes=<factory>, extras=<factory>, root=False)

Bases: TransformDefinition

A connection point other components can drive/parent to. See TransformDefinition for the remaining field descriptions.

name: str = 'input'
hiveType: str = 'input'
root: bool = False
class OutputDefinition(id='', name='output', children=<factory>, parent=None, hiveType='output', type='transform', rotateOrder=0, _translate=<factory>, _rotate=<factory>, _scale=<factory>, attributes=<factory>, extras=<factory>, root=False)

Bases: TransformDefinition

A connection point other components can read from/parent to. See TransformDefinition for the remaining field descriptions.

name: str = 'output'
hiveType: str = 'output'
root: bool = False
class ControlDefinition(id='ctrl', name='control', children=<factory>, parent=None, hiveType='control', type='transform', rotateOrder=0, _translate=<factory>, _rotate=<factory>, _scale=<factory>, attributes=<factory>, extras=<factory>, shape='circle', color=<factory>, srts=<factory>)

Bases: TransformDefinition

An animation rig control. See TransformDefinition for the remaining field descriptions.

name: str = 'control'
shape: str = 'circle'
id: str = 'ctrl'
color: tuple
hiveType: str = 'control'
srts: list
serialize()

Returns a plain dict representation of this node (and its children), suitable for JSON encoding and for round-tripping through deserialize().

Return type:

dict

class GuideDefinition(id='GUIDE_RENAME', name='GUIDE_RENAME', children=<factory>, parent=None, hiveType='guide', type='transform', rotateOrder=0, _translate=<factory>, _rotate=<factory>, _scale=<factory>, attributes=<factory>, extras=<factory>, shape=<factory>, color=<factory>, srts=<factory>, pivotColor=<factory>, pivotShape='sphere_arrow', pivotShapeType=<factory>, internal=False, mirror=True, _annotationParent=None, _shapeTransform=<factory>)

Bases: ControlDefinition

A guide: a user-manipulable placement/orientation proxy that guide+rig build logic reads to construct the deform joints and rig controls. See TransformDefinition/ ControlDefinition for the remaining field descriptions.

name: str = 'GUIDE_RENAME'
id: str = 'GUIDE_RENAME'
pivotColor: tuple
pivotShape: str = 'sphere_arrow'
pivotShapeType: str
hiveType: str = 'guide'
internal: bool = False
mirror: bool = True
attributes: list
update(other=None, **kwargs)

Bulk in-place merge, blindly overwriting matching keys – matches the semantics of the builtin dict.update() that node instances relied on when they were plain dict subclasses.

Parameters:
  • other – A dict or another node instance to merge from.

  • kwargs – Additional key/value pairs to merge, applied after other.

property annotationParent: str | None

Id of the node this guide’s UI annotation line should be drawn to; falls back to “parent” when not explicitly set.

property shapeTransform

Worldspace offset matrix applied to the guide’s display shape only (independent of the guide’s own translate/rotate/scale).

classmethod deserialize(data, parent=None)

Given a Definition compatible dict recursively convert all children to Definitions and then return a new cls

Parameters:
  • data (dict) – Same data as this class data.

  • parent (str) – The parent guide definition id.

Return type:

GuideDefinition

addSrt(**srtInfo)
isAutoAlign()
aimVector()

Returns the aimVector value for the guide

Return type:

:class:zapi.Vector

upVector()

Returns the upVector value for the guide

Return type:

:class:zapi.Vector

perpendicularVectorIndex()

Given the guides aim and up vector return which axis isn’t being used and determine whether to get positive values from an incoming attribute whether it needs to be negated.

Return type:

tuple[int, bool]

mirrorScaleVector(invertUpVector=False, scale=(1.0, 1.0, 1.0), mirrorAxisIndex=None)

Returns the scale vector and whether the guide requires mirroring by scaling. Designed for the rig control creation so that a control is appropriately mirrored. Provide the result scale vector to the “scale” argument of createControl.

Parameters:
  • invertUpVector (bool) – Whether to invert the upVector of the scaled vector not just the plane vector.

  • scale (tuple[float] or zapi.Vector) – The scale vector to mirror default is (1.0, 1.0, 1.0).

  • mirrorAxisIndex (int) – The axis to mirror instead using the guide settings.

Returns:

The scale vector and whether the guide requires mirroring by scaling.

Return type:

tuple[zapi.Vector, bool]

class AttributeDefinition(name='', Type=None, value=None, default=None, min=None, max=None, softMin=None, softMax=None, locked=None, channelBox=None, keyable=None, extras=None, **kwargs)

Bases: object

Wrapper class describing a single Maya attribute in Hive’s dict/JSON-compatible definition format. Each key which requires a maya data type will be either returned or converted back to a json compatible datatype.

i.e. Matrices will be MMatrix when getting a value but a list will be serialized for json.

Keyword Arguments:
  • name – The name of the attribute. Type: str.

  • value – The current value matching that of the type. Type: int, float, str or iterable.

  • default – The default value matching that of the type. Type: int, float, str or iterable.

  • Type – the attribute mfn number. Type: int. see: Attrtypes.

  • softMin – Type: float.

  • softMax – Type: float.

  • min – If this is a numeric attribute then it’s the min number. Type: float or int.

  • max – If this is a numeric attribute then it’s the max number. Type: float or int.

  • locked – Lock state. Type: bool.

  • channelBox – Whether this attribute displays in the channel box. Type: bool.

  • keyable – Whether this attribute can be keyed. Type: bool.

Any other keyword (eg. enums, isArray, isDynamic, children) is accepted and round-trips through serialize() unchanged, matching the old ObjectDict-based behaviour of tolerating arbitrary keys.

name: str = ''
Type: int | None = None
locked: bool | None = None
channelBox: bool | None = None
keyable: bool | None = None
extras: dict
property typeStr: str
property value
property default
property softMin
property softMax
property min
property max
update(other=None, **kwargs)

Bulk in-place merge, blindly overwriting matching keys – matches the semantics of the builtin dict.update() that attribute definitions relied on when they were plain dict subclasses.

Parameters:
  • other – A dict or another attribute definition instance to merge from.

  • kwargs – Additional key/value pairs to merge, applied after other.

serialize()
class VectorAttributeDefinition(name='', Type=None, value=None, default=None, min=None, max=None, softMin=None, softMax=None, locked=None, channelBox=None, keyable=None, extras=None, **kwargs)

Bases: AttributeDefinition

An AttributeDefinition whose numeric-valued keys (value/default/min/max/ softMin/softMax) are 3-float compound attributes, exposed as zapi.Vector via attribute access while remaining plain (x, y, z) tuples via dict-style access and serialize().

property value
property default
property softMin
property softMax
property min
property max
serialize()
attributeClassForDef(definition)
attributeClassForType(attrType)
serializeForKwargs(attrDef)

Serializes attrDef, dropping the Type/value/locked/channelBox/keyable keys when unset.

AttributeDefinition.serialize() always emits those keys (None for anything never explicitly set). Node-creation call sites (eg. zoo.libs.maya.api.nodes.addAttribute, zapi.Plug.setFromDict) that receive this dict unpacked as **kwargs treat an absent key as “use the default” but an explicit None as an invalid value, so those keys need dropping here rather than passed through literally.

Parameters:

attrDef (AttributeDefinition) – The attribute definition to serialize.

Return type:

dict