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


Python OpenMaya.MPlug方法代码示例

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


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

示例1: keys

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def keys(self):

		# TODO MIKE: I had to do a try except here for the the object called "|groundPlane_transform".
		# It's apparently always in the scene and error with that line.
		try:
			keys = cmds.listAttr(cross3d.SceneWrapper._mObjName(self._nativePointer), userDefined=True)
			if keys:
				return keys
		except ValueError:
			pass
		return []
		
		# http://forums.cgsociety.org/showthread.php?t=888612
		# Note: I was unable to find a way to identify userDefined keys in the following method
		# so I used the maya.cmds method. If possible this finish this method and replace the 
		# above code.
		#depNode = om.MFnDependencyNode(mObj)
		#total = depNode.attributeCount()
		#count = 0
		#while count < total:
		#	attr = depNode.attribute(count)
		#	plug = om.MPlug(mObj, attr)
		#	count += 1
		#	print count, attr.apiTypeStr(), plug.name() 
开发者ID:blurstudio,项目名称:cross3d,代码行数:26,代码来源:mayauserprops.py

示例2: getCurveFn

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def getCurveFn(self):
        inputCurvePlug = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.inputCurveAttr)
        curve = getSingleSourceObjectFromPlug(inputCurvePlug)

        # Get Fn from a DAG path to get the world transformations correctly
        if curve is not None:
            path = OpenMaya.MDagPath()
            trFn = OpenMaya.MFnDagNode(curve)
            trFn.getPath(path)

            path.extendToShape()

            if path.node().hasFn(OpenMaya.MFn.kNurbsCurve):
                return OpenMaya.MFnNurbsCurve(path)

        return None

    # Calculate expected instances by the instancing mode 
开发者ID:mmerchante,项目名称:instanceAlongCurve,代码行数:20,代码来源:instanceAlongCurve.py

示例3: getInstanceCountByMode

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def getInstanceCountByMode(self):
        instancingModePlug = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.instancingModeAttr)
        inputCurvePlug = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.inputCurveAttr)

        if inputCurvePlug.isConnected() and instancingModePlug.asInt() == 1:
            instanceLengthPlug = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.instanceLengthAttr)
            maxInstancesByLengthPlug = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.maxInstancesByLengthAttr)
            curveFn = self.getCurveFn()

            # Known issue: even if the curve fn is dag path constructed, its length is not worldspace... 
            # If you want perfect distance-based instancing, freeze the transformations of the curve
            curveLength = curveFn.length()

            curveStart = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.curveStartAttr).asFloat() * curveLength
            curveEnd = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.curveEndAttr).asFloat() * curveLength

            effectiveCurveLength = min(max(curveEnd - curveStart, 0.001), curveLength)

            return min(maxInstancesByLengthPlug.asInt(), int(math.ceil(effectiveCurveLength / instanceLengthPlug.asFloat())))

        instanceCountPlug = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.instanceCountAttr)
        return instanceCountPlug.asInt() 
开发者ID:mmerchante,项目名称:instanceAlongCurve,代码行数:24,代码来源:instanceAlongCurve.py

示例4: _addAttr

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def _addAttr(_fnDependNode, _sName, _pValue):
    sType = core.getDataType(_pValue)

    # Skip empty list
    bIsMulti = sType == core.TYPE_LIST
    if bIsMulti and len(_pValue) == 0:
        return

    plug = None
    # Get attribute arguments
    try: # TODO: Is a try/catch really the best way to know if the plug exists?
        plug = _fnDependNode.findPlug(_sName)
    except:
        pass

    if plug is None:
        fnAtt = _createAttribute(_sName, _pValue)
        if fnAtt is None: return # In case of invalid value like missing pymel PyNode & Attributes
        fnAtt.setNiceNameOverride(_sName)
        moAtt = fnAtt.object()
        if moAtt is not None:
            _fnDependNode.addAttribute(moAtt)
            plug = OpenMaya.MPlug(_fnDependNode.object(), moAtt)

    if plug is not None:
        _setAttr(plug, _pValue) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:28,代码来源:pluginMaya.py

示例5: __init__

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def __init__(self, node):

        log_lvl = sys._global_spore_dispatcher.spore_globals['LOG_LEVEL']
        self.logger = logging_util.SporeLogger(__name__, log_lvl)


        dg_fn = om.MFnDependencyNode(node)
        self.node_name = dg_fn.name()
        self.node = node # TODO - hold on to selection list instead of mobj
        #  self.bounding_box = None
        self.state = None
        self.data_plug = om.MPlug()
        self.data_object = om.MObject()

        # instance data attributes
        self.position = om.MVectorArray()
        self.scale = om.MVectorArray()
        self.rotation = om.MVectorArray()
        self.instance_id = om.MIntArray()
        self.visibility = om.MIntArray()
        self.normal = om.MVectorArray()
        self.tangent = om.MVectorArray()
        self.u_coord = om.MDoubleArray()
        self.v_coord = om.MDoubleArray()
        self.poly_id = om.MIntArray()
        self.color = om.MVectorArray()
        self.unique_id = om.MIntArray()

        self.exclusive_paint = []

        # collect points for kd tree
        self.np_position = np.empty((0,3), float)
        self.tree = None

        self.logger.info('Instanciate new InstanceData object for: {}'.format(self.node_name)) 
开发者ID:wiremas,项目名称:spore,代码行数:37,代码来源:instance_data.py

示例6: initialize_data

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def initialize_data(self):
        """ get cache data from the sporeNode's instanceData plug/
        :param instance_data_plug MPlug: instanceData plug """

        node_fn = om.MFnDependencyNode(self.node)
        self.data_plug = node_fn.findPlug('instanceData')
        self.data_object = self.data_plug.asMObject()
        array_attr_fn = om.MFnArrayAttrsData(self.data_object)

        self.position = array_attr_fn.vectorArray('position')
        self.scale = array_attr_fn.vectorArray('scale')
        self.rotation = array_attr_fn.vectorArray('rotation')
        self.instance_id = array_attr_fn.intArray('objectIndex')
        self.visibility = array_attr_fn.intArray('visibility')
        self.normal = array_attr_fn.vectorArray('normal')
        self.tangent = array_attr_fn.vectorArray('tangent')
        self.u_coord = array_attr_fn.doubleArray('u_coord')
        self.v_coord = array_attr_fn.doubleArray('v_coord')
        self.poly_id = array_attr_fn.intArray('poly_id')
        self.color = array_attr_fn.vectorArray('color')
        self.unique_id = array_attr_fn.intArray('unique_id')

        # TODO - set bb

        # get position as numpy array
        for i in xrange(self.position.length()):
            position = [[self.position[i].x, self.position[i].y, self.position[i].z]]
            self.np_position = np.append(self.np_position, position, axis=0)

        self.logger.debug('Initialize InstanceData object for: {}'.format(self.node_name)) 
开发者ID:wiremas,项目名称:spore,代码行数:32,代码来源:instance_data.py

示例7: _getPlug

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def _getPlug(cls, mObj, name):
		""" For a given OpenMaya.MObject return the OpenMaya.MPlug object with that attribute name.
		If the property does not exist, raises "RuntimeError: (kInvalidParameter): Cannot find item of required type"
		:param mObj: The source MObject
		:param name: The name of the attribute to get from mObj.
		:return: A OpenMaya.MPlug object
		"""
		with ExceptionRouter():
			depNode = om.MFnDependencyNode(mObj)
			attr = depNode.attribute(name)
			return om.MPlug(mObj, attr) 
开发者ID:blurstudio,项目名称:cross3d,代码行数:13,代码来源:mayascenewrapper.py

示例8: getSize

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def getSize(self):
        thisNode = self.thisMObject()
        plug = OpenMaya.MPlug(thisNode, self.aSize)
        
        sizeVal = plug.asMDistance()
        
        return sizeVal.asCentimeters() 
开发者ID:eoyilmaz,项目名称:anima,代码行数:9,代码来源:oyTrajectoryDrawer.py

示例9: getTPositions

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def getTPositions(self):
        """reads the trajectory positions from the attribute
        by using the plug instead of the dataBlock
        """
        
        thisNode = self.thisMObject()
        plug = OpenMaya.MPlug( thisNode, self.aTPos )
        
        vectorArrayDataFn = OpenMaya.MFnVectorArrayData( plug.asMObject() )
        
        tPosVectArray = vectorArrayDataFn.array()
        
        return tPosVectArray 
开发者ID:eoyilmaz,项目名称:anima,代码行数:15,代码来源:oyTrajectoryDrawer.py

示例10: getShadingGroup

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def getShadingGroup(self):
        inputSGPlug = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.inputShadingGroupAttr)
        sgNode = getSingleSourceObjectFromPlug(inputSGPlug)

        if sgNode is not None and sgNode.hasFn(OpenMaya.MFn.kSet):
            return OpenMaya.MFnSet(sgNode)

        return None 
开发者ID:mmerchante,项目名称:instanceAlongCurve,代码行数:10,代码来源:instanceAlongCurve.py

示例11: getInputTransformPlug

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def getInputTransformPlug(self):

        # Backward compatibility
        inputTransformPlug = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.inputTransformAttr)
        legacyInputTransformPlug = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.legacyInputTransformAttr)

        if(legacyInputTransformPlug.isConnected()):
            inputTransformPlug = legacyInputTransformPlug

        return inputTransformPlug 
开发者ID:mmerchante,项目名称:instanceAlongCurve,代码行数:12,代码来源:instanceAlongCurve.py

示例12: getWorldValueAtFrame

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def getWorldValueAtFrame(attr, frame):
    mSelectionList = OpenMaya.MSelectionList()
    mSelectionList.add(attr)
    plug = OpenMaya.MPlug()
    mSelectionList.getPlug(0, plug)
    context = OpenMaya.MDGContext(OpenMaya.MTime(frame))
    return plug.asDouble(context) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:9,代码来源:ml_arcTracer.py

示例13: __init__

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def __init__(self, mObject, dataBlock, rampAttr, normalize, instanceCount):            
            self.ramp = OpenMaya.MRampAttribute(OpenMaya.MPlug(mObject, rampAttr.ramp))
            self.rampOffset = dataBlock.inputValue(rampAttr.rampOffset).asFloat()
            self.rampRandomAmplitude = dataBlock.inputValue(rampAttr.rampRandomAmplitude).asFloat()
            self.rampAmplitude = dataBlock.inputValue(rampAttr.rampAmplitude).asFloat()
            self.rampRepeat = dataBlock.inputValue(rampAttr.rampRepeat).asFloat()

            if normalize:
                self.rampAxis = dataBlock.inputValue(rampAttr.rampAxis.compound).asVector().normal()
            else:
                self.rampAxis = dataBlock.inputValue(rampAttr.rampAxis.compound).asVector()

            self.useDynamicAmplitudeValues = False

            amplitudePlug = OpenMaya.MPlug(mObject, rampAttr.rampAmplitude)

            if amplitudePlug.isConnected():

                # Get connected input plugs
                connections = OpenMaya.MPlugArray()
                amplitudePlug.connectedTo(connections, True, False)

                # Find input transform
                if connections.length() == 1:
                    node = connections[0].node()
                    nodeFn = OpenMaya.MFnDependencyNode(node)

                    resultColors = OpenMaya.MFloatVectorArray()
                    resultTransparencies = OpenMaya.MFloatVectorArray()

                    uValues = OpenMaya.MFloatArray(instanceCount, 0.0)
                    vValues = OpenMaya.MFloatArray(instanceCount, 0.0)

                    # Sample a line, for more user flexibility
                    for i in xrange(instanceCount):
                        uValues.set(i / float(instanceCount), i)
                        vValues.set(i / float(instanceCount), i)

                    # For now... then we can just use the plug (TODO)
                    if(node.hasFn(OpenMaya.MFn.kTexture2d)):                        
                        
                        OpenMayaRender.MRenderUtil.sampleShadingNetwork(nodeFn.name() + ".outColor", instanceCount, False, False, OpenMaya.MFloatMatrix(), None, uValues, vValues, None, None, None, None, None, resultColors, resultTransparencies)

                        self.rampAmplitudeValues = []
                        self.useDynamicAmplitudeValues = True

                        for i in xrange(resultColors.length()):
                            self.rampAmplitudeValues.append(resultColors[i].length() / math.sqrt(3))

    # Ramps base offset 
开发者ID:mmerchante,项目名称:instanceAlongCurve,代码行数:52,代码来源:instanceAlongCurve.py

示例14: compute

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MPlug [as 别名]
def compute(self, plug, dataBlock):
        try:
            curveDataHandle = dataBlock.inputValue(instanceAlongCurveLocator.inputCurveAttr)
            curve = curveDataHandle.asNurbsCurveTransformed()

            updateTranslation = (plug == instanceAlongCurveLocator.outputTranslationAttr.compound)
            updateRotation = (plug == instanceAlongCurveLocator.outputRotationAttr.compound)
            updateScale = (plug == instanceAlongCurveLocator.outputScaleAttr.compound)

            if not curve.isNull():

                if updateTranslation or updateRotation or updateScale:
                    curveFn = OpenMaya.MFnNurbsCurve(curve)

                    instanceCount = self.getInstanceCountByMode()
                    distOffset = dataBlock.inputValue(instanceAlongCurveLocator.distOffsetAttr).asFloat()
                    curveLength = curveFn.length()

                    # Curve thresholds
                    curveStart = dataBlock.inputValue(instanceAlongCurveLocator.curveStartAttr).asFloat() * curveLength
                    curveEnd = dataBlock.inputValue(instanceAlongCurveLocator.curveEndAttr).asFloat() * curveLength

                    effectiveCurveLength = min(max(curveEnd - curveStart, 0.001), curveLength)
                    lengthIncrement = self.getIncrementByMode(instanceCount, effectiveCurveLength)

                    # Common data
                    inputTransformPlug = self.getInputTransformPlug()
                    inputTransformFn = self.getInputTransformFn()
                    
                    # Force update of transformation 
                    if OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.inputTransformAttr).isConnected():
                        dataBlock.inputValue(inputTransformPlug).asMatrix()

                    # Manipulator data
                    curveAxisHandleArray = dataBlock.inputArrayValue(instanceAlongCurveLocator.curveAxisHandleAttr.compound)
                    axisHandlesSorted = getSortedCurveAxisArray(self.thisMObject(), curveAxisHandleArray, instanceCount)

                    if updateTranslation:
                        self.updateInstancePositions(curveFn, dataBlock, instanceCount, distOffset, curveStart, curveEnd, effectiveCurveLength, lengthIncrement, inputTransformPlug, inputTransformFn, axisHandlesSorted)

                    if updateRotation:
                        self.updateInstanceRotations(curveFn, dataBlock, instanceCount, distOffset, curveStart, curveEnd, effectiveCurveLength, lengthIncrement, inputTransformPlug, inputTransformFn, axisHandlesSorted)

                    if updateScale:
                        self.updateInstanceScale(curveFn, dataBlock, instanceCount, distOffset, curveStart, curveEnd, effectiveCurveLength, lengthIncrement)

        except:
            sys.stderr.write('Failed trying to compute locator. stack trace: \n')
            sys.stderr.write(traceback.format_exc())
            return OpenMaya.kUnknownParameter 
开发者ID:mmerchante,项目名称:instanceAlongCurve,代码行数:52,代码来源:instanceAlongCurve.py


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