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


Python OpenMaya.MObject方法代碼示例

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


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

示例1: getComponent

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def getComponent(name):
    """
    Args:
      name (str)

    Returns:
      MOBject
    """
    selList = om.MSelectionList()
    selList.add (name)
    dagPath = om.MDagPath()
    component = om.MObject()
    selList.getDagPath(0, dagPath, component)
    return component

#---------------------------------------------------------------------- 
開發者ID:WebberHuang,項目名稱:DeformationLearningSolver,代碼行數:18,代碼來源:utils.py

示例2: getGeometryComponents

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def getGeometryComponents(skinCls):
    """Get the geometry components from skincluster

    Arguments:
        skinCls (PyNode): The skincluster node

    Returns:
        dagPath: The dagpath for the components
        componets: The skincluster componets
    """
    fnSet = OpenMaya.MFnSet(skinCls.__apimfn__().deformerSet())
    members = OpenMaya.MSelectionList()
    fnSet.getMembers(members, False)
    dagPath = OpenMaya.MDagPath()
    components = OpenMaya.MObject()
    members.getDagPath(0, dagPath, components)
    return dagPath, components 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:19,代碼來源:skin.py

示例3: getCurrentWeights

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def getCurrentWeights(skinCls, dagPath, components):
    """Get the skincluster weights

    Arguments:
        skinCls (PyNode): The skincluster node
        dagPath (MDagPath): The skincluster dagpath
        components (MObject): The skincluster components

    Returns:
        MDoubleArray: The skincluster weights

    """
    weights = OpenMaya.MDoubleArray()
    util = OpenMaya.MScriptUtil()
    util.createFromInt(0)
    pUInt = util.asUintPtr()
    skinCls.__apimfn__().getWeights(dagPath, components, weights, pUInt)
    return weights

######################################
# Skin Collectors
###################################### 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:24,代碼來源:skin.py

示例4: getDagPathComponents

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def getDagPathComponents(compList):
    """
    Args:
      compList (list)

    Returns:
      MObject
    """

    currSel = cmds.ls(sl=1, l=1)
    cmds.select(compList, r=1)
    selList = om.MSelectionList()
    om.MGlobal.getActiveSelectionList(selList)
    dagPath = om.MDagPath()
    components = om.MObject()
    selList.getDagPath(0, dagPath, components)
    cmds.select(cl=1)
    try:
        cmds.select(currSel, r=1)
    except:
        pass
    return dagPath, components

#---------------------------------------------------------------------- 
開發者ID:WebberHuang,項目名稱:DeformationLearningSolver,代碼行數:26,代碼來源:utils.py

示例5: _selectionIter

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def _selectionIter(cls):
		""" A Maya Helper that returns a iterator of maya objects currently
		selected.
		"""
		# Create object named selection and type - SelectionList
		selection = om.MSelectionList()
		# Fill variable "selection" with list of selected objects
		om.MGlobal.getActiveSelectionList(selection)
		# Create iterator through list of selected object
		selection_iter = om.MItSelectionList(selection)
		# Loop though iterator objects
		while not selection_iter.isDone():
			obj = om.MObject()
			selection_iter.getDependNode(obj)
			yield obj
			selection_iter.next() 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:18,代碼來源:mayascene.py

示例6: _objectsOfMTypeIter

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def _objectsOfMTypeIter(cls, objectType):
		""" Maya Helper that returns a iterator of maya objects filtered by objectType.
		:param objectType: A enum value used to identify objects.
		.. seeAlso.. SceneObject._abstractToNativeObjectType
		"""
		if not isinstance(objectType, (tuple, list)):
			objectType = [objectType]
		for oType in objectType:
			# Create iterator traverse all camera nodes
			oIter = om.MItDependencyNodes(oType)
			# Loop though iterator objects
			while not oIter.isDone():
				# oIter.thisNode() points to current MObject in iterator
				yield oIter.thisNode()
				oIter.next()

	#--------------------------------------------------------------------------------
	#							cross3d private methods
	#-------------------------------------------------------------------------------- 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:21,代碼來源:mayascene.py

示例7: _getchildShapeNodes

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def _getchildShapeNodes(cls, nativeObject):
		""" A Maya helper that returns a generator of all shape nodes for the provided transform node.
		
		Args:
			nativeObject (OpenMaya.MObject): The object to get the shape nodes of.
		"""
		if nativeObject.apiType() == om.MFn.kTransform:
			path = om.MDagPath.getAPathTo(nativeObject)
			numShapes = om.MScriptUtil()
			numShapes.createFromInt(0)
			numShapesPtr = numShapes.asUintPtr()
			path.numberOfShapesDirectlyBelow(numShapesPtr)
			for index in range(om.MScriptUtil(numShapesPtr).asUint()):
				p = om.MDagPath.getAPathTo(nativeObject)
				p.extendToShapeDirectlyBelow(index)
				yield p.node() 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:18,代碼來源:mayascenewrapper.py

示例8: _getShapeNode

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def _getShapeNode(cls, nativeObject):
		""" A Maya Helper that returns the first shape node of the provided transform node.
		
		If no shape node exists the nativeObject is returned.
		
		Args:
			nativeObject (OpenMaya.MObject): The MObject to get the first shape node from.
		
		Returns:
			OpenMaya.MObject: The first shape node of the transform or the passed in object.
		"""
		if nativeObject.apiType() == om.MFn.kTransform:
			path = om.MDagPath.getAPathTo(nativeObject)
			numShapes = om.MScriptUtil()
			numShapes.createFromInt(0)
			numShapesPtr = numShapes.asUintPtr()
			path.numberOfShapesDirectlyBelow(numShapesPtr)
			if om.MScriptUtil(numShapesPtr).asUint():
				# TODO: Should this return the last shape, instead of the first?
				path.extendToShapeDirectlyBelow(0)
				return path.node()
		return nativeObject 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:24,代碼來源:mayascenewrapper.py

示例9: _getTransformNode

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def _getTransformNode(cls, nativeObject):
		""" A Maya Helper that returns the first transform node of the provided shape node.
		The nativeObject is returned if the nativeObject is a transform node.
		:param nativeObject: The OpenMaya.MObject to get the transform node of
		:return: OpenMaya.MObject
		"""
		with ExceptionRouter():
			# If its not a dag object, there is no transform to return use the nativeObject
			if not cls._isDagNode(nativeObject):

				# The world node doesn't play well with the getting transform code.
				return nativeObject
			path = om.MDagPath.getAPathTo(nativeObject)
			newPointer = path.transform()
			if newPointer != nativeObject:
				return newPointer
		return nativeObject 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:19,代碼來源:mayascenewrapper.py

示例10: _mObjName

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def _mObjName(cls, nativeObject, fullName=True):
		""" A Maya Helper that returns the name of a object, because OpenMaya can't 
		expose the name in a single call.
		:param nativeObject: The OpenMaya.MObject to get the name of
		:param fullName: If True return the Name(Full Path), else return the displayName. Defaults to True
		:return: nativeObject's name as a string
		"""
		with ExceptionRouter():
			if cls._isDagNode(nativeObject):
				dagPath = om.MDagPath.getAPathTo(nativeObject)
				if fullName:
					return dagPath.fullPathName()
				return dagPath.partialPathName().split("|")[-1]
			return om.MFnDependencyNode(nativeObject).name()

	#--------------------------------------------------------------------------------
	#							cross3d private methods
	#-------------------------------------------------------------------------------- 
開發者ID:blurstudio,項目名稱:cross3d,代碼行數:20,代碼來源:mayascenewrapper.py

示例11: _get_rotation_quaternion

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def _get_rotation_quaternion(self):
        obj=OpenMaya.MObject()
        #make a object of type MSelectionList
        sel_list=OpenMaya.MSelectionList()
        #add something to it
        #you could retrieve this from function or the user selection
        sel_list.add(self.maya_node)
        #fill in the MObject
        sel_list.getDependNode(0,obj)
        #check if its a transform
        if (obj.hasFn(OpenMaya.MFn.kTransform)):
            quat = OpenMaya.MQuaternion()
            #then we can add it to transfrom Fn
            #Fn is basically the collection of functions for given objects
            xform=OpenMaya.MFnTransform(obj)
            xform.getRotation(quat)
            # glTF requires normalize quat
            quat.normalizeIt()
        
        py_quat = [quat[x] for x in range(4)]
        return py_quat 
開發者ID:matiascodesal,項目名稱:maya-glTF,代碼行數:23,代碼來源:glTFExport.py

示例12: _encode1

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def _encode1(path):
    """Convert `path` to Maya API 1.0 MObject

    Arguments:
        path (str): Absolute or relative path to DAG or DG node

    Raises:
        ExistError on `path` not existing

    """

    selectionList = om1.MSelectionList()

    try:
        selectionList.add(path)
    except RuntimeError:
        raise ExistError("'%s' does not exist" % path)

    mobject = om1.MObject()
    selectionList.getDependNode(0, mobject)
    return mobject 
開發者ID:mottosso,項目名稱:cmdx,代碼行數:23,代碼來源:cmdx.py

示例13: createNode

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def createNode(self, type, name=None, parent=None):
        parent = parent._mobject if parent else om.MObject.kNullObj

        try:
            mobj = self._modifier.createNode(type, parent)
        except TypeError:
            raise TypeError("'%s' is not a valid node type" % type)

        template = self._opts["template"]
        if name or template:
            name = (template or "{name}").format(
                name=name or "",
                type=type,
                index=self._index,
            )
            self._modifier.renameNode(mobj, name)

        return DagNode(mobj, exists=False, modifier=self) 
開發者ID:mottosso,項目名稱:cmdx,代碼行數:20,代碼來源:cmdx.py

示例14: __init__

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def __init__(self, skin_cluster):
        """Constructor"""
        self.node = skin_cluster
        self.shape = cmds.listRelatives(
            cmds.deformer(skin_cluster, q=True, g=True)[0], parent=True, path=True
        )[0]

        # Get the skinCluster MObject
        self.mobject = shortcuts.get_mobject(self.node)
        self.fn = OpenMayaAnim.MFnSkinCluster(self.mobject)
        self.data = {
            "weights": {},
            "blendWeights": [],
            "name": self.node,
            "shape": self.shape,
        } 
開發者ID:chadmv,項目名稱:cmt,代碼行數:18,代碼來源:skinio.py

示例15: gather_influence_weights

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MObject [as 別名]
def gather_influence_weights(self, dag_path, components):
        """Gathers all the influence weights

        :param dag_path: MDagPath of the deformed geometry.
        :param components: Component MObject of the deformed components.
        """
        weights = self.__get_current_weights(dag_path, components)

        influence_paths = OpenMaya.MDagPathArray()
        influence_count = self.fn.influenceObjects(influence_paths)
        components_per_influence = weights.length() // influence_count
        for ii in range(influence_paths.length()):
            influence_name = influence_paths[ii].partialPathName()
            # We want to store the weights by influence without the namespace so it is easier
            # to import if the namespace is different
            influence_without_namespace = shortcuts.remove_namespace_from_name(
                influence_name
            )
            self.data["weights"][influence_without_namespace] = [
                weights[jj * influence_count + ii]
                for jj in range(components_per_influence)
            ] 
開發者ID:chadmv,項目名稱:cmt,代碼行數:24,代碼來源:skinio.py


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