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


Python OpenMaya.MFnNumericAttribute方法代碼示例

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


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

示例1: nodeInitializer

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnNumericAttribute [as 別名]
def nodeInitializer():
    """initializes the node
    """
    nAttr = OpenMaya.MFnNumericAttribute()

    # input position
    RandomizeDeformer.aMaxOffset = nAttr.create(
        "maxOffset", "mo", OpenMaya.MFnNumericData.kInt, 4
    )
    nAttr.setMin(1)
    nAttr.setKeyable(True)
    nAttr.setWritable(True)
    nAttr.setReadable(True)
    nAttr.setStorable(True)

    RandomizeDeformer.addAttribute(RandomizeDeformer.aMaxOffset)
    RandomizeDeformer.attributeAffects(
        RandomizeDeformer.aMaxOffset,
        OpenMayaMPx.cvar.MPxDeformerNode_outputGeom
    )

    return True 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:24,代碼來源:randomizeUVDeformer.py

示例2: nodeInitializer

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnNumericAttribute [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

示例3: initialize

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnNumericAttribute [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

示例4: initialize

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnNumericAttribute [as 別名]
def initialize():
        nAttr = om.MFnNumericAttribute()

        PushDeformer.push = nAttr.create('push', 'p', om.MFnNumericData.kFloat, 0.0)
        nAttr.setKeyable(True)
        nAttr.setStorable(True)
        nAttr.setChannelBox(True)

        PushDeformer.addAttribute(PushDeformer.push)
        PushDeformer.attributeAffects(PushDeformer.push, outputGeomAttr)

        # We also want to make our node paintable
        cmds.makePaintable(
            PushDeformer.name,
            'weights',
            attrType='multiFloat',
            shapeMode='deformer'
        ) 
開發者ID:dgovil,項目名稱:AdvancedPythonForMaya,代碼行數:20,代碼來源:pushDeformer.py

示例5: initialize

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnNumericAttribute [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

示例6: addCompoundVector3Attribute

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnNumericAttribute [as 別名]
def addCompoundVector3Attribute(cls, compoundAttribute, attributeName, unitType, arrayAttr, inputAttr, defaultValue):

        # Schematic view of compound attribute:
        # compoundAttribute[?]
        #   compoundAttributeX
        #   compoundAttributeY
        #   compoundAttributeZ

        unitAttr = OpenMaya.MFnUnitAttribute()
        nAttr = OpenMaya.MFnNumericAttribute()

        compoundAttribute.x = unitAttr.create(attributeName + "X", attributeName + "X", unitType, defaultValue.x)
        unitAttr.setWritable( inputAttr )
        cls.addAttribute(compoundAttribute.x)

        compoundAttribute.y = unitAttr.create(attributeName + "Y", attributeName + "Y", unitType, defaultValue.y)
        unitAttr.setWritable( inputAttr )
        cls.addAttribute(compoundAttribute.y)

        compoundAttribute.z = unitAttr.create(attributeName + "Z", attributeName + "Z", unitType, defaultValue.z)
        unitAttr.setWritable( inputAttr )
        cls.addAttribute(compoundAttribute.z)

        # Output compound
        compoundAttribute.compound = nAttr.create(attributeName, attributeName,
                                     compoundAttribute.x, compoundAttribute.y, compoundAttribute.z)
        nAttr.setWritable( inputAttr )
        nAttr.setArray( arrayAttr )
        nAttr.setUsesArrayDataBuilder( arrayAttr )
        nAttr.setDisconnectBehavior(OpenMaya.MFnAttribute.kDelete)
        cls.addAttribute(compoundAttribute.compound) 
開發者ID:mmerchante,項目名稱:instanceAlongCurve,代碼行數:33,代碼來源:instanceAlongCurve.py

示例7: addRampAttributes

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnNumericAttribute [as 別名]
def addRampAttributes(cls, rampAttributes, attributeName, unitType, defaultAxisValue):

        # Not a compound attribute, just adds them all to the node
        
        nAttr = OpenMaya.MFnNumericAttribute()

        rampAttributes.ramp = OpenMaya.MRampAttribute.createCurveRamp(attributeName + "Ramp", attributeName + "Ramp")
        cls.addAttribute(rampAttributes.ramp)

        rampAttributes.rampOffset = nAttr.create(attributeName + "RampOffset", attributeName + "RampOffset", OpenMaya.MFnNumericData.kFloat, 0.0)
        nAttr.setKeyable( True )
        cls.addAttribute( rampAttributes.rampOffset )

        rampAttributes.rampAmplitude = nAttr.create(attributeName + "RampAmplitude", attributeName + "RampAmplitude", OpenMaya.MFnNumericData.kFloat, 0.0)
        nAttr.setKeyable( True )
        cls.addAttribute( rampAttributes.rampAmplitude )

        rampAttributes.rampRepeat = nAttr.create(attributeName + "RampRepeat", attributeName + "RampRepeat", OpenMaya.MFnNumericData.kFloat, 1.0)
        nAttr.setKeyable( True )
        cls.addAttribute( rampAttributes.rampRepeat )

        rampAttributes.rampRandomAmplitude = nAttr.create(attributeName + "RampRandomAmplitude", attributeName + "RampRandomAmplitude", OpenMaya.MFnNumericData.kFloat, 0.0)
        nAttr.setMin(0.0)
        nAttr.setSoftMax(1.0)
        nAttr.setKeyable( True )
        cls.addAttribute( rampAttributes.rampRandomAmplitude )

        cls.addCompoundVector3Attribute(rampAttributes.rampAxis, attributeName + "RampAxis", unitType, False, True, defaultAxisValue) 
開發者ID:mmerchante,項目名稱:instanceAlongCurve,代碼行數:30,代碼來源:instanceAlongCurve.py

示例8: addCurveAxisHandleAttribute

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnNumericAttribute [as 別名]
def addCurveAxisHandleAttribute(cls, curveAxisHandleAttr, attributeName, defaultAxisValue):

        # Schematic view of compound attribute:
        # curveAxisHandle[]
        #   curveAxisHandleParameter
        #   curveAxisHandleAngle

        nAttr = OpenMaya.MFnNumericAttribute()
        cmpAttr = OpenMaya.MFnCompoundAttribute()

        curveAxisHandleAttr.parameter = nAttr.create(attributeName + "Parameter", attributeName + "Parameter", OpenMaya.MFnNumericData.kDouble, 0.0)
        nAttr.setWritable( True )
        cls.addAttribute(curveAxisHandleAttr.parameter)

        curveAxisHandleAttr.angle = nAttr.create(attributeName + "Angle", attributeName + "Angle", OpenMaya.MFnNumericData.kDouble, 0.0)
        nAttr.setWritable( True )
        cls.addAttribute(curveAxisHandleAttr.angle)

        # cls.addCompoundVector3Attribute(curveAxisHandleAttr.axis, attributeName + "Axis", OpenMaya.MFnUnitAttribute.kAngle, False, True, defaultAxisValue)

        # Build compound array attribute
        curveAxisHandleAttr.compound = cmpAttr.create(attributeName, attributeName)
        cmpAttr.addChild(curveAxisHandleAttr.parameter)
        cmpAttr.addChild(curveAxisHandleAttr.angle)
        cmpAttr.setWritable( True )
        cmpAttr.setArray( True )
        cmpAttr.setUsesArrayDataBuilder( True )

        cls.addAttribute(curveAxisHandleAttr.compound) 
開發者ID:mmerchante,項目名稱:instanceAlongCurve,代碼行數:31,代碼來源:instanceAlongCurve.py

示例9: nodeInitializer

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MFnNumericAttribute [as 別名]
def nodeInitializer():

	nAttr = OpenMaya.MFnNumericAttribute()
	uAttr = OpenMaya.MFnUnitAttribute()

	# input

	ShakeNode.amp = nAttr.create( "amplitude", "amp", OpenMaya.MFnNumericData.k3Float, 1.0 )
	nAttr.setStorable(True)
	nAttr.setKeyable(True)

	ShakeNode.freq = nAttr.create( "frequency", "freq", OpenMaya.MFnNumericData.k3Float, 1.0 )
	nAttr.setStorable(True)
	nAttr.setKeyable(True)

	ShakeNode.seed = nAttr.create( "randomSeed", "seed", OpenMaya.MFnNumericData.kLong, 1000 )
	nAttr.setStorable(True)
	nAttr.setKeyable(False)
	nAttr.setMin(0)

	ShakeNode.octaves = nAttr.create( "octaves", "oct", OpenMaya.MFnNumericData.kInt, 3 )
	nAttr.setStorable(True)
	nAttr.setKeyable(True)
	nAttr.setMin(2)
	
	# the time attribute should be connected to the default "time1" node
	# or any time node to provide a changing time value
	ShakeNode.time = uAttr.create( "currentTime", "time" , OpenMaya.MFnUnitAttribute.kTime,  0.0 )
	uAttr.setHidden(True)
	nAttr.setStorable(False)
		
	# output
	ShakeNode.output = nAttr.create( "output", "out", OpenMaya.MFnNumericData.k3Float, 0.0 )
	nAttr.setStorable(False)
	nAttr.setWritable(False)
	nAttr.setHidden(False)


	# add attributes to the node
	ShakeNode.addAttribute( ShakeNode.amp )
	ShakeNode.addAttribute( ShakeNode.freq )
	ShakeNode.addAttribute( ShakeNode.seed )
	ShakeNode.addAttribute( ShakeNode.time )
	ShakeNode.addAttribute( ShakeNode.octaves )
	ShakeNode.addAttribute( ShakeNode.output )

	# when one attribute is changed, it will cause
	# the other to become "dirty", meaning that its value
	# should be computed again
	ShakeNode.attributeAffects( ShakeNode.amp, ShakeNode.output )
	ShakeNode.attributeAffects( ShakeNode.freq, ShakeNode.output )
	ShakeNode.attributeAffects( ShakeNode.seed, ShakeNode.output )
	ShakeNode.attributeAffects( ShakeNode.octaves, ShakeNode.output )
	ShakeNode.attributeAffects( ShakeNode.time, ShakeNode.output )
	


# initialize the script plug-in 
開發者ID:justinfx,項目名稱:tutorials,代碼行數:60,代碼來源:shakeNode.py


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