Definition¶
Main api access for component data
- todo:
allow for special syntax for referencing in definition files eg. {“include”: vchaincomponent}.
- todo:
definition validation.
- todo:
create a registry of definitions which will allow us to deserialize with more types.
- todo:
better merging of attributes and the dag.
- class GuideLayerDefinition¶
Bases:
LayerDef
- 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:
- update([E, ]**F) None. Update D from dict/iterable E and F. ¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- 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.
- addGuideSetting(setting)¶
Appends a new guide setting to this definition
- Parameters:
setting (
definitionattrs.AttributeDefinition
) – Setting object 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.
- 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¶
Bases:
LayerDef
- 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:
- update([E, ]**F) None. Update D from dict/iterable E and F. ¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- setSettingValue(nodeName, name, value)¶
Sets the value for a setting.
- 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.(str) (name) – The Name for the setting.
iterable) (default (int or float or str or) – The json supported python value.
iterable) – The json supported python value.
(int) (Type) – The attribute type int, see:
zoo.libs.maya.api.attrtypes
(float) (softMax) – The softMin(UI) for the attribute, only valid for numeric Attrs
(float) – The softMax(UI) for the attribute, only valid for numeric Attrs
int) (max (float or) – The min for the attribute, only valid for numeric Attrs
int) – The max for the attribute, only valid for numeric Attrs
(bool) (keyable) – Whether this attribute should be locked.
(bool) – Whether this attribute should be displayed in the channelBox.
(bool) – Whether this attribute should be keyable by an animator.
- Returns:
The new settings instance.
- Return type:
definitionattrs.AttributeDefinition
or None
- 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:
- 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.
- class InputLayerDefinition¶
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:
- update([E, ]**F) None. Update D from dict/iterable E and F. ¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- 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¶
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:
- update([E, ]**F) None. Update D from dict/iterable E and F. ¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- 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¶
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:
- update([E, ]**F) None. Update D from dict/iterable E and F. ¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- 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
- 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
- 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:
- graph(graphId)¶
Returns the graph instance.
- Parameters:
graphId (str) – The graph id to search for.
- Return type:
NamedGraph
or None
- class NamedGraph¶
Bases:
ObjectDict
Contains a network of Dependency graph nodes, and it’s internal connections
- 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:
- property nodes¶
Returns the DG nodes for this graph.
- Return type:
list[
definitionnodes.DGNode
]
- 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(*args, **kwargs)¶
Bases:
ObjectDict
- Parameters:
kwargs (dict) – dict
Kwargs is in the form of
{ "name": "nodeName", "translation": [0,0,0], "rotation": [0,0,0,1], "rotateOrder": 0, "shape": "cube", "id": "myId", "children": [], "color": [0,0,0], "worldMatrix": [], "shapeTransform": {"translate": [0,0,0], "rotate": [0,0,0,1], "scale": [1,1,1]} }
- DEFAULTS = {'children': [], 'hiveType': 'transform', 'name': 'control', 'parent': None, 'rotate': [0.0, 0.0, 0.0, 1.0], 'rotateOrder': 0, 'scale': [1.0, 1.0, 1.0], 'translate': [0.0, 0.0, 0.0], 'type': 'transform'}¶
- property translate¶
- property rotate¶
- property scale¶
- property matrix¶
- property worldMatrix¶
- attribute(attributeName)¶
- 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 recursively convert all children to Definitions and then return a new cls
- Parameters:
data (dict) – Same data as the this class
parent (
TransformDefinition
) – The parent parent transform definition.
- Return type:
- copy() a shallow copy of D ¶
- deleteChild(childId)¶
- localTransformationMatrix(translate=True, rotate=True, scale=True)¶
Returns the local
zapi.TransformationMatrix
instance for the current Definition.Note
Requires the Matrix key on the definition.
- 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.
- class JointDefinition(*args, **kwargs)¶
Bases:
TransformDefinition
- DEFAULTS = {'children': [], 'hiveType': 'joint', 'id': '', 'name': 'joint', 'parent': None, 'rotate': [0.0, 0.0, 0.0, 1.0], 'rotateOrder': 0, 'scale': [1.0, 1.0, 1.0], 'translate': [0.0, 0.0, 0.0]}¶
- class InputDefinition(*args, **kwargs)¶
Bases:
TransformDefinition
- DEFAULTS = {'children': [], 'hiveType': 'input', 'id': '', 'name': 'input', 'parent': None, 'root': False, 'rotate': [0.0, 0.0, 0.0, 1.0], 'rotateOrder': 0, 'scale': [1.0, 1.0, 1.0], 'translate': [0.0, 0.0, 0.0]}¶
- class OutputDefinition(*args, **kwargs)¶
Bases:
TransformDefinition
- DEFAULTS = {'children': [], 'hiveType': 'output', 'id': '', 'name': 'output', 'parent': None, 'root': False, 'rotate': [0.0, 0.0, 0.0, 1.0], 'rotateOrder': 0, 'scale': [1.0, 1.0, 1.0], 'translate': [0.0, 0.0, 0.0]}¶
- class ControlDefinition(*args, **kwargs)¶
Bases:
TransformDefinition
- DEFAULTS = {'children': [], 'color': (), 'hiveType': 'control', 'id': 'ctrl', 'name': 'control', 'parent': None, 'rotate': [0.0, 0.0, 0.0, 1.0], 'rotateOrder': 0, 'scale': [1.0, 1.0, 1.0], 'shape': 'circle', 'srts': [], 'translate': [0.0, 0.0, 0.0]}¶
- class GuideDefinition(*args, **kwargs)¶
Bases:
ControlDefinition
- DEFAULTS = {'attributes': [{'name': 'autoAlignAimVector', 'value': (1.0, 0.0, 0.0), 'Type': 31, 'default': (1.0, 0.0, 0.0)}, {'name': 'autoAlignUpVector', 'value': (0.0, 1.0, 0.0), 'Type': 31, 'default': (0.0, 1.0, 0.0)}], 'children': [], 'hiveType': 'guide', 'id': 'GUIDE_RENAME', 'internal': False, 'mirror': True, 'name': 'GUIDE_RENAME', 'parent': None, 'pivotColor': (1.0, 1.0, 0.0), 'rotate': [0.0, 0.0, 0.0, 1.0], 'rotateOrder': 0, 'scale': [1.0, 1.0, 1.0], 'shape': {}, 'shapeTransform': {'rotate': [0.0, 0.0, 0.0, 1.0], 'rotateOrder': 0, 'scale': [1, 1, 1], 'translate': [0.0, 0.0, 0.0]}, 'srts': [], 'translate': [0.0, 0.0, 0.0]}¶
- update([E, ]**F) None. Update D from dict/iterable E and F. ¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- 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 the this class
parent (
GuideDefinition
) – The parent parent guide definition.
- Return type:
- addSrt(**srtInfo)¶
- class AttributeDefinition¶
Bases:
ObjectDict
Wrapper class to handle maya type to dict storage. 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.
- Parameters:
(str) (name) – The name of the attribute.
iterable) (default (int or float or str or) – The current value matching that of the type.
iterable) – The default value matching that of the type.
(int) (Type) – the attribute mfn number. see: Attrtypes.
(float) (softMax) –
(float) –
int) (max (float or) – If this is a numeric attribute then it’s the min number.
int) – If this is a numeric attribute then it’s the max number.
(bool) (keyable) – Lock state.
(bool) – Whether this attribute displays in the channel box.
(bool) – Whether this attribute can be keyed.
- property value¶
- property default¶
- property softMin¶
- property softMax¶
- property min¶
- property max¶
- class VectorAttributeDefinition¶
Bases:
AttributeDefinition
- property value¶
- property default¶
- property softMin¶
- property softMax¶
- property min¶
- property max¶
- attributeClassForDef(definition)¶