mgear.core.attribute module¶
Attribute creation functions
-
class
mgear.core.attribute.
FCurveParamDef
(scriptName, keys=None, interpolation=0, extrapolation=0)¶ Bases:
mgear.core.attribute.ParamDef
Create an Fcurve parameter definition.
Parameters: - scriptName (str) – Attribute fullName.
- keys (list) – The keyframes to define the function curve.
- interpolation (int) – the curve interpolation.
- extrapolation (int) – the curve extrapolation.
-
create
(node)¶ Add a parameter to property using the parameter definition.
Parameters: node (dagNode) – The node to add the attribute
-
get_as_dict
()¶
-
set_from_dict
(param_dict)¶
-
class
mgear.core.attribute.
ParamDef
(read as Parameter Definition)¶ Bases:
object
Encapsulate the attribute creation arguments in a handy object. Also include a creation method.
Example
This can be use later to create attr or export the description to xml or json file
- Arguments:
- scriptName (str): Attribute fullName paranDef (dic): The stored param definition
-
create
(node)¶ Add a parameter to property using the parameter definition.
Parameters: node (dagNode) – The node to add the attribute
-
get_as_dict
()¶
-
set_from_dict
(param_dict)¶
-
class
mgear.core.attribute.
ParamDef2
(scriptName, valueType, value, niceName=None, shortName=None, minimum=None, maximum=None, keyable=True, readable=True, storable=True, writable=True)¶ Bases:
mgear.core.attribute.ParamDef
ParamDef2 inherit from ParamDef
Parameters: - scriptName (str) – Parameter scriptname.
- valueType (str) – The Attribute Type. Exp: ‘string’, ‘bool’, ‘long’, etc..
- value (float or int) – Default parameter value.
- niceName (str) – Parameter niceName.
- shortName (str) – Parameter shortName.
- minimum (float or int) – mininum value.
- maximum (float or int) – maximum value.
- keyable (boo) – If true is keyable
- readable (boo) – If true is readable
- storable (boo) – If true is storable
- writable (boo) – If true is writable
Returns: The stored parameter definition.
Return type:
-
mgear.core.attribute.
addAttribute
(node, longName, attributeType, value=None, niceName=None, shortName=None, minValue=None, maxValue=None, keyable=True, readable=True, storable=True, writable=True, channelBox=False, softMinValue=None, softMaxValue=None)¶ Add attribute to a node
Parameters: - node (dagNode) – The object to add the new attribute.
- longName (str) – The attribute name.
- attributeType (str) – The Attribute Type. Exp: ‘string’, ‘bool’, ‘long’, etc..
- value (float or int) – The default value.
- niceName (str) – The attribute nice name. (optional)
- shortName (str) – The attribute short name. (optional)
- minValue (float or int) – minimum value. (optional)
- maxValue (float or int) – maximum value. (optional)
- keyable (bool) – Set if the attribute is keyable or not. (optional)
- readable (bool) – Set if the attribute is readable or not. (optional)
- storable (bool) – Set if the attribute is storable or not. (optional)
- writable (bool) – Set if the attribute is writable or not. (optional)
- channelBox (bool) – Set if the attribute is in the channelBox or not, when the attribute is not keyable. (optional)
Returns: The long name of the new attribute
Return type: str
-
mgear.core.attribute.
addColorAttribute
(node, longName, value=False, keyable=True, readable=True, storable=True, writable=True, niceName=None, shortName=None)¶ Add a color attribute to a node
Parameters: - node (dagNode) – The object to add the new attribute.
- longName (str) – The attribute name.
- value (list of flotat) – The default value in a list for RGB. exp [1.0, 0.99, 0.13].
- keyable (bool) – Set if the attribute is keyable or not. (optional)
- readable (bool) – Set if the attribute is readable or not. (optional)
- storable (bool) – Set if the attribute is storable or not. (optional)
- writable (bool) – Set if the attribute is writable or not. (optional)
- niceName (str) – The attribute nice name. (optional)
- shortName (str) – The attribute short name. (optional)
Returns: The long name of the new attribute
Return type: str
-
mgear.core.attribute.
addEnumAttribute
(node, longName, value, enum, niceName=None, shortName=None, keyable=True, readable=True, storable=True, writable=True)¶ Add an enumerate attribute to a node
Parameters: - node (dagNode) – The object to add the new attribute.
- longName (str) – The attribute name.
- value (int) – The default value.
- enum (list of str) – The list of elements in the enumerate control
- niceName (str) – The attribute nice name. (optional)
- shortName (str) – The attribute short name. (optional)
- keyable (bool) – Set if the attribute is keyable or not. (optional)
- readable (bool) – Set if the attribute is readable or not. (optional)
- storable (bool) – Set if the attribute is storable or not. (optional)
- writable (bool) – Set if the attribute is writable or not. (optional)
Returns: The long name of the new attribute
Return type: str
-
mgear.core.attribute.
addFCurve
(node, name='fcurve', keys=[])¶ FCurve attribute
Just a animCurveUU node connected to an attribute
Warning
This Method is deprecated.
Parameters: - node (dagNode) – The object to add the new fcurve attribute
- name (str) – The attribute name
- key (list) – list of keyframes and values
Returns: Fcurve and attribute name
-
mgear.core.attribute.
addProxyAttribute
(sourceAttrs, targets, duplicatedPolicy=None)¶ Add proxy paramenter to a list of target dagNode Duplicated channel policy, stablish the rule in case the channel already exist on the target.
Duplicate policy options
index This policy will add an index to avoid clashing channel names fullName This policy will add the name of the source object to the channel merge This policy will merge the channels Parameters: - sourceAttrs (attr or list of attr) – The parameters to be connected as proxy
- targets (dagNode or list of dagNode) – The list of dagNode to add the proxy paramenter
- duplicatedPolicy (string, optional) – Set the duplicated channel policy
-
mgear.core.attribute.
addVector3Attribute
(node, longName, value=False, keyable=True, readable=True, storable=True, writable=True, niceName=None, shortName=None, childLabels=['X', 'Y', 'Z'], usedAsColor=False, attributeType='float3')¶ Add a vector3 attribute to a node
Parameters: - node (dagNode) – The object to add the new attribute.
- longName (str) – The attribute name.
- value (list of flotat) – The default value in a list for RGB. exp [1.0, 0.99, 0.13].
- keyable (bool) – Set if the attribute is keyable or not. (optional)
- readable (bool) – Set if the attribute is readable or not. (optional)
- storable (bool) – Set if the attribute is storable or not. (optional)
- writable (bool) – Set if the attribute is writable or not. (optional)
- niceName (str) – The attribute nice name. (optional)
- shortName (str) – The attribute short name. (optional)
Returns: The long name of the new attribute
Return type: str
-
mgear.core.attribute.
add_mirror_config_channels
(ctl, conf=[0, 0, 0, 0, 0, 0, 0, 0, 0])¶ Add channels to configure the mirror posing
Parameters: ctl (dagNode) – Control Object
-
mgear.core.attribute.
change_default_value
(attributes, defaultValue)¶ Change the default value of the attr
Parameters: - attributes (list or str or pynode) – attributes to change the default val
- defaultValue (numeric value) – defaul value. Only numeric values are valid
-
mgear.core.attribute.
collect_attrs
(node, attrs, attrs_list, shapes=False)¶ Collect the channel full path in a list.
Checks that the channel is not repeated.
Parameters: - node (PyNode) – Node that owns the channels
- attrs (str) – the list to add the channels full path
- attrs_list (list) – the list of channels names
- shapes (bool, optional) – If True will search the attr only in shapes
-
class
mgear.core.attribute.
colorParamDef
(scriptName, value=False)¶ Bases:
mgear.core.attribute.ParamDef
Create a Color parameter definition.
Parameters: - scriptName (str) – Attribute fullName
- value (list of float) – The default value in a list for RGB. exp [1.0, 0.99, 0.13].
-
create
(node)¶ Add a parameter to property using the parameter definition.
Parameters: node (dagNode) – The node to add the attribute
-
get_as_dict
()¶
-
set_from_dict
(param_dict)¶
-
mgear.core.attribute.
connectSet
(source, target, testInstance)¶ Connect or set attributes
Connects or set attributes depending if is instance of a instance check
Parameters: - source (str or Attr) – Striname of the attribute or PyNode attribute
- target (str or Attr) – Striname of the attribute or PyNode attribute
- testInstance (tuple) – Tuple of types to check
-
mgear.core.attribute.
connect_add_dynamic_pivot
(pivots, driven)¶ connect dynamic pivot with option to add offset channels on XYZ
Parameters: - pivot (dagNode list) – pivot translation
- driven (dagNode list) – Driven object
-
mgear.core.attribute.
connect_dynamic_pivot
(pivot, driven)¶ connects translation of pivot dagNode to rotatePivot and scalePivot of the driven transform
Parameters: - pivot (dagNode) – pivot translation
- driven (dagNode) – Driven object
-
mgear.core.attribute.
disconnect_inputs
(node, attributes=['scale', 'sx', 'sy', 'sz', 'translate', 'tx', 'ty', 'tz', 'rotate', 'rx', 'ry', 'rz'])¶ Disconnects only the input connections of the specified attributes of the provided node.
Parameters: - node (PyNode) – The PyNode object for which to disconnect input
- connections. –
- attributes (list, optional) – A list of attributes to disconnect
- connections from. Defaults to disconnecting all translation, (input) –
- and scale attributes in all directions. (rotation,) –
-
mgear.core.attribute.
disconnect_outputs
(node, attributes=['scale', 'sx', 'sy', 'sz', 'translate', 'tx', 'ty', 'tz', 'rotate', 'rx', 'ry', 'rz'])¶ Disconnects only the output connections of the specified attributes of the provided node.
Parameters: - node (PyNode) – The PyNode object for which to disconnect output
- connections. –
- attributes (list, optional) – A list of attributes to disconnect
- connections from. Defaults to disconnecting all translation, (output) –
- and scale attributes in all directions. (rotation,) –
-
class
mgear.core.attribute.
enumParamDef
(scriptName, enum, value=False)¶ Bases:
mgear.core.attribute.ParamDef
Create an enumarator parameter definition.
Parameters: - scriptName (str) – Attribute fullName
- enum (list of str) – The list of elements in the enumerate control.
- value (int) – The default value.
-
create
(node)¶ Add a parameter to property using the parameter definition.
Parameters: node (dagNode) – The node to add the attribute
-
get_as_dict
()¶
-
set_from_dict
(param_dict)¶
-
mgear.core.attribute.
getSelectedChannels
(userDefine=False)¶ Get the selected channels on the channel box
Parameters: userDefine (bool, optional) – If True, will return only the user defined channels. Other channels will be skipped. Returns: The list of selected channels names Return type: list
-
mgear.core.attribute.
getSelectedObjectChannels
(oSel=None, userDefine=False, animatable=False)¶ Get the selected object channels.
Parameters: - oSel (None, optional) – The pynode with channels to get
- userDefine (bool, optional) – If True, will return only the user defined channels. Other channels will be skipped.
- animatable (bool, optional) – If True, only animatable parameters will be return
Returns: The list of the selected object channels names
Return type: list
-
mgear.core.attribute.
get_channelBox
()¶ Get the channel box
Returns: channel box path Return type: str
-
mgear.core.attribute.
get_default_value
(node, attribute)¶ Get the default attribute value
Parameters: - node (str, PyNode) – The object with the attribute
- attribute (str) – The attribute to get the value
Returns: The attribute value
Return type: variant
-
mgear.core.attribute.
get_next_available_index
(attr)¶ get the next available index from a multi attr This function is a workaround because the connect attr flag next available is not working.
- The connectAttr to the children attribute is giving error
- i.e: pm.connectAttr(ctt.attr(“parent”),
- tpTagNode.attr(“children”), na=True)
if using the next available option flag I was expecting to use ctt.setParent(tagParent) but doest’t work as expected. After reading the documentation this method looks prety useless. Looks like is boolean and works based on selection :(
Parameters: attr (attr) – Attr multi Returns: index Return type: int
-
mgear.core.attribute.
get_selected_channels_full_path
()¶ Get the selected channels full path from channel box This function will collect channels from any area of the channel box. This include, Main, shape, input and output
Returns: list of channels full path Return type: list
-
mgear.core.attribute.
has_in_connections
(node, attributes=['translate', 'tx', 'ty', 'tz', 'rotate', 'rx', 'ry', 'rz', 'scale', 'sx', 'sy', 'sz'])¶ Checks if the provided node has any input connections on the specified attributes.
Parameters: - node (PyNode) – The PyNode object for which to check connections.
- attributes (list, optional) – A list of attributes to check for connections. Defaults to checking all translation,
- and scale attributes in all directions. (rotation,) –
Returns: True if any connections are found, False otherwise.
Return type: bool
Examples
>>> jnt = pm.PyNode('myJoint') >>> has_connections(jnt) Found some connections. >>> has_connections(jnt, ['visibility']) No connections found.
-
mgear.core.attribute.
lockAttribute
(node, attributes=['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'])¶ Lock attributes of a node.
By defaul will lock the rotation, scale and translation.
Parameters: - node (dagNode) – The node with the attributes to lock.
- attributes (list of str) – The list of the attributes to lock.
Example
>>> att.lockAttribute(self.root_ctl, ["sx", "sy", "sz", "v"])
-
mgear.core.attribute.
moveChannel
(attr, sourceNode, targetNode, duplicatedPolicy=None)¶ Move channels keeping the output connections. Duplicated channel policy, stablish the rule in case the channel already exist on the target.
NOTE: For the moment move channel only supports type double and enum
Duplicate policy options
index This policy will add an index to avoid clashing channel names fullName This policy will add the name of the source object to the channel merge This policy will merge the channels Parameters: - attr (str) – Name of the channel to move
- sourceNode (PyNoe or str) – The source node with the channel
- targetNode (PyNoe or str) – The target node for the channel
- duplicatedPolicy (None, str) – Set the duplicated channel policy
-
mgear.core.attribute.
move_input_connections
(source, target, type_filter=None)¶ Move the input connections from source node to target node. The connections can be filtered by type of the incoming node
- exp: attribute.move_input_connections(
- cns_obj, cns_off, type_filter=”parentConstraint”
)
Parameters: - source (PyNode) – node with input connection
- target (PyNode) – target to receive the input connections
- type_filter (None, str) – node type to filter connections list
-
mgear.core.attribute.
move_output_connections
(source, target, type_filter=None)¶ Move the output connections from source node to target node. The connections can be filtered by type of the outgoing node
- exp: attribute.move_output_connections(
- cns_obj, cns_off, type_filter=”parentConstraint”
)
Parameters: - source (PyNode) – node with output connection
- target (PyNode) – target to receive the input connections
- type_filter (None, str) – node type to filter connections list
-
mgear.core.attribute.
reset_SRT
(objects=None, attributes=['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'])¶ Reset Scale Rotation and translation attributes to default value
Parameters: - objects (None, optional) – The objects to reset the channels
- attribute (list) – The attribute to reset
-
mgear.core.attribute.
reset_selected_channels_value
(objects=None, attributes=None)¶ Reset the the selected channels if not attribute is provided
Parameters: - objects (None, optional) – The objects to reset the channels
- attribute (list, optional) – The attribute to reset
-
mgear.core.attribute.
setInvertMirror
(node, invList=None)¶ Set invert mirror pose values
Parameters: node (dagNode) – The object to set invert mirror Values
-
mgear.core.attribute.
setKeyableAttributes
(nodes, params=['tx', 'ty', 'tz', 'ro', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'])¶ Set keyable attributes of a node.
By defaul will set keyable the rotation, scale and translation.
Parameters: - node (dagNode) – The node with the attributes to set keyable.
- attributes (list of str) –
The list of the attributes to set keyable. Attrs not in the list will be locked if None, [“tx”, “ty”, “tz”, “rorder”, “rx”, “ry”, “rz”, “sx”, “sy”,
”sz”] is used
-
mgear.core.attribute.
setNotKeyableAttributes
(nodes, attributes=['tx', 'ty', 'tz', 'ro', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'])¶ Set not keyable attributes of a node.
By defaul will set not keyable the rotation, scale and translation.
Parameters: - node (dagNode) – The node with the attributes to set keyable.
- attributes (list of str) – The list of the attributes to set not keyable
-
mgear.core.attribute.
setRotOrder
(node, s='XYZ')¶ Set the rotorder of the object.
Parameters: - node (dagNode) – The object to set the rot order on.
- s (str) – Value of the rotorder. Possible values : (“XYZ”, “XZY”, “YXZ”, “YZX”, “ZXY”, “ZYX”)
-
mgear.core.attribute.
set_default_value
(node, attribute)¶ Set the default value to the attribute
Parameters: - node (str, PyNode) – The object with the attribute to reset
- attribute (str) – The attribute to reset
-
mgear.core.attribute.
smart_reset
(*args)¶ Reset the SRT or the selected channels
Checks first if we have channels selected. If not, will try to reset SRT
Parameters: *args – Dummy
-
mgear.core.attribute.
toggle_bool_attr
(attr)¶
-
mgear.core.attribute.
unlockAttribute
(node, attributes=['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'])¶ Unlock attributes of a node.
By defaul will unlock the rotation, scale and translation.
Parameters: - node (dagNode) – The node with the attributes to unlock.
- attributes (list of str) – The list of the attributes to unlock.
Example
>>> att.unlockAttribute(self.root_ctl, ["sx", "sy", "sz", "v"])