当前位置: 首页>>代码示例>>Python>>正文


Python OpenMaya.MFnNumericAttribute方法代码示例

本文整理汇总了Python中maya.api.OpenMaya.MFnNumericAttribute方法的典型用法代码示例。如果您正苦于以下问题:Python OpenMaya.MFnNumericAttribute方法的具体用法?Python OpenMaya.MFnNumericAttribute怎么用?Python OpenMaya.MFnNumericAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.api.OpenMaya的用法示例。


在下文中一共展示了OpenMaya.MFnNumericAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initialize

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnNumericAttribute [as 别名]
def initialize():
        eAttr = om.MFnEnumAttribute()
        CustomLocator.shape = eAttr.create('shape', 's')
        eAttr.storable = True

        # We can simply add shapes from the dictionary above
        for i, shape in enumerate(shapeNames):
            eAttr.addField(shape, i)

        CustomLocator.addAttribute(CustomLocator.shape)

        # Now add the color attribute
        nAttr = om.MFnNumericAttribute()
        CustomLocator.color = nAttr.createColor('color', 'col')
        nAttr.default = (0.5, 0.1, 0.1)
        nAttr.storable = True

        CustomLocator.addAttribute(CustomLocator.color)


# This class is required to let us control how viewport 2 will render our node 
开发者ID:dgovil,项目名称:AdvancedPythonForMaya,代码行数:23,代码来源:customLocator.py

示例2: _addOutputControls

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnNumericAttribute [as 别名]
def _addOutputControls(obj, side):
    '''
    Adds attributes to card for tracking the created controls.  Used in conjunction
    with OutputControls.
    
    :param PyNode obj: The card to add attributes to
    :param str side: Either "Left", "Right" or "Center"
    '''
    if obj.hasAttr('output' + side):
        return

    mobj = core.capi.asMObject(obj)
    cattr = OpenMaya.MFnCompoundAttribute()
    mattr = OpenMaya.MFnMessageAttribute()
    nattr = OpenMaya.MFnNumericAttribute()
    
    extraNodes = cattr.create('output' + side, 'out' + side[0])
    cattr.array = True

    link = mattr.create( 'outputLink' + side, 'ol' + side[0] )
    type = nattr.create('out' + side + 'Type', 'o' + side[0] + 't', OpenMaya.MFnNumericData.kInt, 0)
    
    cattr.addChild(link)
    cattr.addChild(type)

    mobj.addAttribute(extraNodes) 
开发者ID:patcorwin,项目名称:fossil,代码行数:28,代码来源:card.py

示例3: _addSeqAttr

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnNumericAttribute [as 别名]
def _addSeqAttr(obj):
    '''
    Add `.sequence` attribute to a Script node to enable the custom Sequence api.
    Safe to run repeatedly since it only adds required attrs.
    '''
    if not obj:
        return
    
    if not obj.hasAttr('sequence'):
        mobj = core.capi.asMObject(obj)
        cattr = OpenMaya.MFnCompoundAttribute()
        nattr = OpenMaya.MFnNumericAttribute()
        tattr = OpenMaya.MFnTypedAttribute()
        mattr = OpenMaya.MFnMessageAttribute()

        sequence = cattr.create("sequence", 'seq')
        cattr.array = True

        for long, short, type in _dataSequenceAttr:
            if type is OpenMaya.MFnStringData.kString:
                newAttr = tattr.create(long, short, type)
            elif type is OpenMaya.MFnNumericData.kInt:
                newAttr = nattr.create(long, short, type, 0)
            elif type == 'message':
                newAttr = mattr.create(long, short)

            cattr.addChild(newAttr)

        mobj.addAttribute(sequence)
        
    if not obj.hasAttr( 'animNotes' ):
        obj.addAttr( 'animNotes', dt='string' )
        obj.animNotes.set('') 
开发者ID:patcorwin,项目名称:fossil,代码行数:35,代码来源:getNodes.py

示例4: _attribute_changed

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnNumericAttribute [as 别名]
def _attribute_changed(self, attribute_message, plug_dst, plug_scr, *args):
        # Message attribute edits
        if attribute_message & om2.MNodeMessage.kOtherPlugSet:
            input_uuid = om2.MFnDependencyNode(plug_scr.node()).uuid()
            if plug_dst.isElement:
                plug_dst = plug_dst.array()
            if attribute_message & om2.MNodeMessage.kConnectionMade:
                om2.MUserEventMessage.postUserEvent(self.attr_user_event,
                                                    (self.uuid, plug_dst.partialName(), input_uuid, True))
            elif attribute_message & om2.MNodeMessage.kConnectionBroken:
                om2.MUserEventMessage.postUserEvent(self.attr_user_event,
                                                    (self.uuid, plug_dst.partialName(), input_uuid, False))
        # Data attribute edits
        elif attribute_message & om2.MNodeMessage.kAttributeSet:
            dst_attribute = plug_dst.attribute()
            dst_type = dst_attribute.apiType()
            if plug_dst.isElement:
                attr_name = plug_dst.array().partialName()
                index = plug_dst.logicalIndex()
            else:
                attr_name = plug_dst.partialName()
                index = None
            if dst_type == om2.MFn.kTypedAttribute:
                attr_type = om2.MFnTypedAttribute(dst_attribute).attrType()
                if attr_type == om2.MFnData.kString:
                    om2.MUserEventMessage.postUserEvent(self.attr_user_event,
                                                        (self.uuid, attr_name, plug_dst.asString(), index))
                elif attr_type == om2.MFnData.kStringArray:
                    data_object = plug_dst.asMDataHandle().data()
                    string_array = om2.MFnStringArrayData(data_object)
                    om2.MUserEventMessage.postUserEvent(self.attr_user_event,
                                                        (self.uuid, attr_name, string_array.array(), index))
            elif dst_type == om2.MFn.kNumericAttribute:
                dstUnitType = om2.MFnNumericAttribute(dst_attribute).numericType()
                if dstUnitType == om2.MFnNumericData.kBoolean:
                    om2.MUserEventMessage.postUserEvent(self.attr_user_event,
                                                        (self.uuid, attr_name, plug_dst.asBool(), index))
                elif dstUnitType in {om2.MFnNumericData.kFloat, om2.MFnNumericData.kDouble, om2.MFnNumericData.kAddr}:
                    om2.MUserEventMessage.postUserEvent(self.attr_user_event,
                                                        (self.uuid, attr_name, plug_dst.asDouble(), index))
                elif dstUnitType in {om2.MFnNumericData.kShort, om2.MFnNumericData.kInt,
                                     om2.MFnNumericData.kLong, om2.MFnNumericData.kByte}:
                    om2.MUserEventMessage.postUserEvent(self.attr_user_event,
                                                        (self.uuid, attr_name, plug_dst.asShort(), index)) 
开发者ID:arenanet,项目名称:metanode,代码行数:46,代码来源:core.py

示例5: initialize

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnNumericAttribute [as 别名]
def initialize():
        # We need to create an instance of the Numeric Attribute Function set
        # This lets us in turn create numeric attributes
        nAttr = om.MFnNumericAttribute()

        # Lets start b defining our two input attributes
        # We assign this to an attribute on the class
        # The arguments in order are:
        # long name, short name, attribute type, default value
        # A double is like a float but with **double** the precision
        MinMaxNode.inputA = nAttr.create('inputA', 'ia', om.MFnNumericData.kDouble, 0.0)

        # After each attribute, we can then configure it
        # the nAttr object remembers the last object created
        nAttr.storable = True  # Allows us to store data on this plug
        nAttr.keyable = True  # Allows us to key it, but also needed to see in Node Editor

        # Finally we can do the same for the next attribute
        MinMaxNode.inputB = nAttr.create('inputB', 'ib', om.MFnNumericData.kDouble, 0.0)
        nAttr.storable = True
        nAttr.keyable = True

        # Then lets create our output in the same way
        MinMaxNode.output = nAttr.create('output', 'out', om.MFnNumericData.kDouble, 0.0)
        nAttr.storable = True
        nAttr.writable = True

        # We should also create our mode selection
        # This is a different type called enum
        eAttr = om.MFnEnumAttribute()
        MinMaxNode.mode = eAttr.create('mode', 'm')
        eAttr.addField('min', 0)
        eAttr.addField('max', 1)
        eAttr.storable = True

        # We then add our attributes to the node
        # Otherwise they won't show up
        MinMaxNode.addAttribute(MinMaxNode.inputA)
        MinMaxNode.addAttribute(MinMaxNode.inputB)
        MinMaxNode.addAttribute(MinMaxNode.mode)
        MinMaxNode.addAttribute(MinMaxNode.output)

        # Finally we need to tell our node which attributes affect the output of other attributes
        # If we don't do this then our attributes won't update dynamically
        # In this case both our inputs affect the output
        # Our mode selection will also affect it
        MinMaxNode.attributeAffects(MinMaxNode.inputA, MinMaxNode.output)
        MinMaxNode.attributeAffects(MinMaxNode.inputB, MinMaxNode.output)
        MinMaxNode.attributeAffects(MinMaxNode.mode, MinMaxNode.output)

    # Finally all of our computation will happen in this method here
    # We get two inputs, the MPlug being requested, and the MDatablock which stores this nodes data 
开发者ID:dgovil,项目名称:AdvancedPythonForMaya,代码行数:54,代码来源:minMaxNode.py

示例6: initialize

# 需要导入模块: from maya.api import OpenMaya [as 别名]
# 或者: from maya.api.OpenMaya import MFnNumericAttribute [as 别名]
def initialize(cls):
        fnUnit = api.MFnUnitAttribute()
        fnNumeric = api.MFnNumericAttribute()
        fnEnum = api.MFnEnumAttribute()

        cls.aMethod = fnEnum.create('method', 'met')
        fnEnum.addField('Stereographic Projection', 0)
        fnEnum.addField('Exponential Map', 1)
        cls.addAttribute(cls.aMethod)

        cls.aReverseOrder = fnNumeric.create('reverseOrder', 'ror', api.MFnNumericData.kBoolean, False)
        cls.addAttribute(cls.aReverseOrder)

        cls.aRotateX = fnUnit.create('rotateX', 'rx', api.MFnUnitAttribute.kAngle, 0.)
        cls.aRotateY = fnUnit.create('rotateY', 'ry', api.MFnUnitAttribute.kAngle, 0.)
        cls.aRotateZ = fnUnit.create('rotateZ', 'rz', api.MFnUnitAttribute.kAngle, 0.)
        cls.aRotate = fnNumeric.create('rotate', 'r', cls.aRotateX, cls.aRotateY, cls.aRotateZ)
        cls.addAttribute(cls.aRotate)

        cls.aRotateOrder = fnEnum.create('rotateOrder', 'ro')
        fnEnum.addField('xyz', 0)
        fnEnum.addField('yzx', 1)
        fnEnum.addField('zxy', 2)
        fnEnum.addField('xzy', 3)
        fnEnum.addField('yxz', 4)
        fnEnum.addField('zyx', 5)
        cls.addAttribute(cls.aRotateOrder)

        cls.aAxisOrientX = fnUnit.create('axisOrientX', 'aox', api.MFnUnitAttribute.kAngle, 0.)
        cls.aAxisOrientY = fnUnit.create('axisOrientY', 'aoy', api.MFnUnitAttribute.kAngle, 0.)
        cls.aAxisOrientZ = fnUnit.create('axisOrientZ', 'aoz', api.MFnUnitAttribute.kAngle, 0.)
        cls.aAxisOrient = fnNumeric.create('axisOrient', 'ao', cls.aAxisOrientX, cls.aAxisOrientY, cls.aAxisOrientZ)
        cls.addAttribute(cls.aAxisOrient)

        cls.aOutRoll = fnUnit.create('outRoll', 'orl', api.MFnUnitAttribute.kAngle, 0.)
        cls.aOutBendH = fnUnit.create('outBendH', 'obh', api.MFnUnitAttribute.kAngle, 0.)
        cls.aOutBendV = fnUnit.create('outBendV', 'obv', api.MFnUnitAttribute.kAngle, 0.)
        cls.aOutDecomposedAngle = fnNumeric.create('outDecomposedAngle', 'oda', cls.aOutRoll, cls.aOutBendH, cls.aOutBendV)
        fnNumeric.writable = False
        fnNumeric.storable = False
        cls.addAttribute(cls.aOutDecomposedAngle)

        cls.attributeAffects(cls.aMethod, cls.aOutDecomposedAngle)
        cls.attributeAffects(cls.aReverseOrder, cls.aOutDecomposedAngle)
        cls.attributeAffects(cls.aRotate, cls.aOutDecomposedAngle)
        cls.attributeAffects(cls.aRotateOrder, cls.aOutDecomposedAngle)
        cls.attributeAffects(cls.aAxisOrient, cls.aOutDecomposedAngle) 
开发者ID:ryusas,项目名称:maya_rotationDriver,代码行数:49,代码来源:rotationDriver.py


注:本文中的maya.api.OpenMaya.MFnNumericAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。