Python maya.OpenMaya.MFnTypedAttribute() Examples
The following are 6
code examples of maya.OpenMaya.MFnTypedAttribute().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
maya.OpenMaya
, or try the search function
.
Example #1
Source File: oyTrajectoryDrawer.py From anima with MIT License | 6 votes |
def nodeInitializer(): '''initializer ''' # create the size attr uAttrFn = OpenMaya.MFnUnitAttribute() oyTrajectoryDrawer.aSize = uAttrFn.create( "size", "in", OpenMaya.MFnUnitAttribute.kDistance ) uAttrFn.setDefault(1.0) oyTrajectoryDrawer.addAttribute( oyTrajectoryDrawer.aSize ) # create the trajectory positions attr nAttrFn = OpenMaya.MFnNumericAttribute() tAttrFn = OpenMaya.MFnTypedAttribute() mAttrFn = OpenMaya.MFnMessageAttribute() defaultVectorArray = OpenMaya.MVectorArray() vectorArrayDataFn = OpenMaya.MFnVectorArrayData() vectorArrayDataFn.create( defaultVectorArray ) oyTrajectoryDrawer.aTPos = tAttrFn.create( "trajectoryPosition", "tp", OpenMaya.MFnData.kVectorArray, vectorArrayDataFn.object() ) tAttrFn.setWritable(True) tAttrFn.setStorable(True) oyTrajectoryDrawer.addAttribute( oyTrajectoryDrawer.aTPos )
Example #2
Source File: characterRoot.py From AdvancedPythonForMaya with GNU General Public License v3.0 | 6 votes |
def initialize(): # First lets add the version number attribute so we can easily query the rig version number nAttr = om.MFnNumericAttribute() CharacterRoot.version = nAttr.create('version', 'ver', om.MFnNumericData.kInt, 0) nAttr.setStorable(True) # Then lets store the author of the rig as meta data as well. # Strings are a generic typed attribute tAttr = om.MFnTypedAttribute() # To create the default value we must create it from MFnStringData sData = om.MFnStringData() defaultValue = sData.create('Dhruv Govil') # Finally we make our attirbute CharacterRoot.author = tAttr.create('author', 'a', om.MFnData.kString, defaultValue) # Then lets add them to our node CharacterRoot.addAttribute(CharacterRoot.version) CharacterRoot.addAttribute(CharacterRoot.author)
Example #3
Source File: greenCageDeformer.py From maya_greenCageDeformer with MIT License | 6 votes |
def initialize(cls): fnTyped = api1.MFnTypedAttribute() fnNumeric = api1.MFnNumericAttribute() cls.aInCage = fnTyped.create('inCage', 'ic', api1.MFnData.kMesh) fnTyped.setStorable(False) fnTyped.setCached(False) cls.addAttribute(cls.aInCage) cls.aBaseCage = fnTyped.create('baseCage', 'bc', api1.MFnData.kMesh) cls.addAttribute(cls.aBaseCage) cls.aEnvelope = _deformerAttr('envelope') cls.aInput = _deformerAttr('input') cls.aOutputGeom = _deformerAttr('outputGeom') cls.attributeAffects(cls.aInCage, cls.aOutputGeom) cls.attributeAffects(cls.aBaseCage, cls.aOutputGeom)
Example #4
Source File: sticker.py From NodeSticker with MIT License | 5 votes |
def _create_attribute(): """Internal function for attribute create""" attr = oldOm.MFnTypedAttribute() mattr = attr.create(ICON_ATTRIBUTE, ICON_ATTR, oldOm.MFnData.kString) return mattr
Example #5
Source File: mayascenewrapper.py From cross3d with MIT License | 4 votes |
def _createAttribute(cls, mObj, name, dataType=None, shortName=None, default=None): """ Create a attribute on the provided object. Returns the attribute name and shortName. You should provide dataType or default when calling this method so a valid dataType is selected. MayaSceneWrapper._normalizeAttributeName is called on name to ensure it is storing the attribute with a valid attribute name. If shortName is not provided, the name will have MayaSceneWrapper._normalizeAttributeShortName called on it. :param mObj: The OpenMaya.MObject to create the attribute on :param name: The name used to access the attribute :param dataType: The type of data to store in the attribute. Defaults to None. :param shortName: The shortName used by scripting. Defaults to None. :param default: The default value assigned to the attribute. Defaults to None. :return: (name, short name) Because the attribute name and shortName are normalized, this returns the actual names used for attribute names. """ name = cls._normalizeAttributeName(name) if dataType == None and default != None: dataType == cls._getAttributeDataType(default) if dataType == om.MFnData.kInvalid: # No vaid dataType was found, default to None so we can handle it diffrently dataType == None cross3d.logger.debug('Unable To determine the attribute type.\n{}'.format(str(default))) if dataType == None: # MCH 09/17/14 # TODO Evaluate if this is a valid default? dataType = om.MFnData.kAny with ExceptionRouter(): if shortName == None: shortName = cls._normalizeAttributeShortName(name, uniqueOnObj=mObj) depNode = om.MFnDependencyNode(mObj) sAttr = om.MFnTypedAttribute() if False: #if default: # TODO: Handle creating the default object attr = sAttr.create(name, shortName, dataType, default) else: attr = sAttr.create(name, shortName, dataType) # TODO MIKE: Problem with "|groundPlane_transform". try: depNode.addAttribute(attr) except RuntimeError: pass return name, shortName
Example #6
Source File: oyCenterOfMass.py From anima with MIT License | 4 votes |
def nodeInitializer(): """node initializer """ # create attributes mAttrFn = OpenMaya.MFnMessageAttribute() tAttrFn = OpenMaya.MFnTypedAttribute() cAttrFn = OpenMaya.MFnCompoundAttribute() # lets try calculating with mesh vertices # so create an attribute like inMesh that accepts # mesh objects # ---------------------------------------------- # ---- INPUTS ---- # ---------------- # objectList # # object list should be an array that accepts mesh oyCenterOfMass.aInMesh = tAttrFn.create( "inMesh", "im", OpenMaya.MFnData.kMesh ) tAttrFn.setStorable(False) tAttrFn.setKeyable(False) tAttrFn.setArray(True) oyCenterOfMass.addAttribute( oyCenterOfMass.aInMesh ) # ---------------- # input it self oyCenterOfMass.aInput = cAttrFn.create( "input", "in" ) cAttrFn.addChild( oyCenterOfMass.aInMesh ) oyCenterOfMass.addAttribute( oyCenterOfMass.aInput ) # ---------------------------------------------- # ---- OUTPUTS ---- # ---------------- # center of mass positions defaultVectorArray = OpenMaya.MVectorArray() vectorArrayDataFn = OpenMaya.MFnVectorArrayData() vectorArrayDataFn.crate( defaultVectorArray ) oyCenterOfMass.aCOMPos = tAttrFn.create( "centerOfMass", "com", OpenMaya.MFnData.kVectorArray, vectorArrayDataFn.object() ) tAttr.setWritable(False) tAttr.setStorable(False) oyCenterOfMass.addAttribute( oyCenterOfMass.aCOMPos ) # output itself oyCenterOfMass.aOutput = cAttrFn.create( "output", "op" ) oyCenterOfMass.addAttribute( oyCenterOfMass.aOutput ) # set releations oyCenterOfMass.attributeAffects( oyCenterOfMass.aObjectList, oyCenterOfMass.aCOMPos ) oyCenterOfMass.attributeAffects( oyCenterOfMass.aStartFrame, oyCenterOfMass.aCOMPos ) oyCenterOfMass.attributeAffects( oyCenterOfMass.aEndFrame , oyCenterOfMass.aCOMPos )