mgear.core.attribute¶
Attribute creation functions
-
class
mgear.core.attribute.
FCurveParamDef
(scriptName, keys=None, interpolation=0, extrapolation=0)¶ 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)¶ 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)¶ 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)¶ 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.
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
-
class
mgear.core.attribute.
colorParamDef
(scriptName, value=False)¶ 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
-
class
mgear.core.attribute.
enumParamDef
(scriptName, enum, value=False)¶ 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_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.
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.
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.
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"])