當前位置: 首頁>>代碼示例>>Python>>正文


Python OpenMaya.MFnTypedAttribute方法代碼示例

本文整理匯總了Python中maya.OpenMaya.MFnTypedAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Python OpenMaya.MFnTypedAttribute方法的具體用法?Python OpenMaya.MFnTypedAttribute怎麽用?Python OpenMaya.MFnTypedAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.OpenMaya的用法示例。


在下文中一共展示了OpenMaya.MFnTypedAttribute方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: nodeInitializer

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnTypedAttribute [as 別名]
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 ) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:26,代碼來源:oyTrajectoryDrawer.py

示例2: initialize

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnTypedAttribute [as 別名]
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) 
開發者ID:dgovil,項目名稱:AdvancedPythonForMaya,代碼行數:20,代碼來源:characterRoot.py

示例3: initialize

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnTypedAttribute [as 別名]
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) 
開發者ID:ryusas,項目名稱:maya_greenCageDeformer,代碼行數:19,代碼來源:greenCageDeformer.py

示例4: _create_attribute

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnTypedAttribute [as 別名]
def _create_attribute():
    """Internal function for attribute create"""
    attr = oldOm.MFnTypedAttribute()
    mattr = attr.create(ICON_ATTRIBUTE,
                        ICON_ATTR,
                        oldOm.MFnData.kString)
    return mattr 
開發者ID:davidlatwe,項目名稱:NodeSticker,代碼行數:9,代碼來源:sticker.py

示例5: _createAttribute

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnTypedAttribute [as 別名]
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 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:44,代碼來源:mayascenewrapper.py

示例6: nodeInitializer

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnTypedAttribute [as 別名]
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 ) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:56,代碼來源:oyCenterOfMass.py


注:本文中的maya.OpenMaya.MFnTypedAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。