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:
- serialize()¶
Returns a plain dict representation of this layer, suitable for JSON encoding and for round-tripping through
fromData().- Return type:
- 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.GuideDefinitioninstance that is attached to this Definition instance.- Parameters:
guideId (str) – The guide id value
- Return type:
definitionnodes.GuideDefinitionor 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.
- 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.AttributeDefinitionor 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.
- addGuide(guide)¶
Appends a new
definitionnodes.GuideDefinitionto 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- 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:
- serialize()¶
Returns a plain dict representation of this layer, suitable for JSON encoding and for round-tripping through
fromData().- Return type:
- update(kwargs)¶
- setSettingValue(nodeName, name, value)¶
Sets the value for a setting.
- addSetting(nodeName, **kwargs)¶
Adds a setting(attribute) for the node to the definition.
- Parameters:
- Returns:
The new settings instance.
- Return type:
definitionattrs.AttributeDefinitionor 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.AttributeDefinitionor 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:
- insertSetting(nodeName, index, settingDef)¶
Inserts a setting either before or after the existing setting by the given name.
- Parameters:
- Returns:
Whether or not the attribute was successfully inserted.
- Return type:
- insertSettings(nodeName, index, settingDefs)¶
- settingIndex(nodeName, name)¶
- deleteSettings(nodeName, names)¶
Deletes a group of settings from the layer node.
- deleteSetting(nodeName, name)¶
Deletes a group of setting by name from the layer node.
- setting(nodeName, name)¶
Return’s the
definitionattrs.AttributeDefinitioninstance attached to the node in this definition if it exists.
- 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:
- serialize()¶
Returns a plain dict representation of this layer, suitable for JSON encoding and for round-tripping through
fromData().- Return type:
- 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.AttributeDefinitionor None
- addInputSetting(**kwargs)¶
Appends a new input setting to this definition
- Parameters:
kwargs – the input Setting instance
- Return type:
definitionattrs.AttributeDefinitionor 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:
- serialize()¶
Returns a plain dict representation of this layer, suitable for JSON encoding and for round-tripping through
fromData().- Return type:
- 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.AttributeDefinitionor 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:
- serialize()¶
Returns a plain dict representation of this layer, suitable for JSON encoding and for round-tripping through
fromData().- Return type:
- 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.JointDefinitionor None
- setParentJoint(jointId, parentJointId)¶
Parents ‘jointId’ def to the ‘parentJointId’ def. Takes care of any internals
- Parameters:
jointId
parentJointId
- Returns:
- Return type:
- findJoints(*ids)¶
Returns the JointDefinition instance by the provided the id.
- addJoint(jointDef)¶
Adds a joint to this definition.
- Parameters:
jointDef (
definitionnodes.JointDefinition) – The output definition
- iterDeformJoints()¶
Returns the
definitionnodes.JointDefinitioninstance that is attached to this Definition instance.- Return type:
definitionnodes.JointDefinitionor None
- class NamedGraphs(iterable=(), /)¶
Bases:
listList of
NamedGraphinstances.- 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:
- serialize()¶
Returns a plain list-of-dicts representation of the contained graphs, suitable for JSON encoding and for round-tripping through
fromData().
- graph(graphId)¶
Returns the graph instance.
- Parameters:
graphId (str) – The graph id to search for.
- Return type:
NamedGraphor None
- class NamedGraph(id='', name='', nodes=<factory>, connections=<factory>, inputsData=<factory>, outputsData=<factory>, metaData=<factory>)¶
Bases:
objectContains a network of Dependency graph nodes, and it’s internal connections
- classmethod fromData(graphData)¶
Parses the provided graphData and creates a
NamedGraphinstance.- Parameters:
graphData (dict) – The Raw Graph data to parse into a
NamedGraph- Returns:
The newly created
NamedGraphinstance.- Return type:
- serialize()¶
Returns a plain dict representation of this graph, suitable for JSON encoding and for round-tripping through
fromData().- Return type:
- 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.DGNodeor 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:
objectBase 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 definitiondict(the common case, data loaded from disk/scene/user input) – it handles defaulting, type coercion (translate/rotate/scale to tuples, attribute dicts todefinitionattrs.AttributeDefinition), recursive child construction and preserving any unrecognized/legacy keys. The plain constructor only does field assignment, matching normal dataclass semantics.- 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 rawtupleinstead (see_translate).
- property rotate¶
Worldspace rotation as a
zapi.EulerRotation(raw tuple length 3) orzapi.Quaternion(raw tuple length 4). Bracket/.get("rotate")access returns the rawtupleinstead (see_rotate).
- property scale: MockExt.OpenMaya.MVector¶
Worldspace scale as a
zapi.Vector. Bracket/.get("scale")access returns the rawtupleinstead (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.AttributeDefinitionor 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:
- Return type:
- serialize()¶
Returns a plain dict representation of this node (and its children), suitable for JSON encoding and for round-tripping through
deserialize().- Return type:
- 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.
- transformationMatrix(translate=True, rotate=True, scale=True)¶
Returns the world
zapi.TransformationMatrixinstance for the current Definition.Note
Requires the translate, rotate, scale keys on the definition. Rotate order key will be applied as well.
- 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:
TransformDefinitionA deform joint. See
TransformDefinitionfor field descriptions.
- 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:
TransformDefinitionA connection point other components can drive/parent to. See
TransformDefinitionfor the remaining field descriptions.
- 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:
TransformDefinitionA connection point other components can read from/parent to. See
TransformDefinitionfor the remaining field descriptions.
- 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:
TransformDefinitionAn animation rig control. See
TransformDefinitionfor the remaining field descriptions.
- 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:
ControlDefinitionA guide: a user-manipulable placement/orientation proxy that guide+rig build logic reads to construct the deform joints and rig controls. See
TransformDefinition/ControlDefinitionfor the remaining field descriptions.- 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:
- Return type:
- 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.
- 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:
- 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:
objectWrapper 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 throughserialize()unchanged, matching the old ObjectDict-based behaviour of tolerating arbitrary keys.- 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:
AttributeDefinitionAn
AttributeDefinitionwhose numeric-valued keys (value/default/min/max/ softMin/softMax) are 3-float compound attributes, exposed aszapi.Vectorvia attribute access while remaining plain(x, y, z)tuples via dict-style access andserialize().- 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 (Nonefor anything never explicitly set). Node-creation call sites (eg.zoo.libs.maya.api.nodes.addAttribute,zapi.Plug.setFromDict) that receive this dict unpacked as**kwargstreat an absent key as “use the default” but an explicitNoneas an invalid value, so those keys need dropping here rather than passed through literally.- Parameters:
attrDef (AttributeDefinition) – The attribute definition to serialize.
- Return type: