当前位置: 首页>>代码示例>>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;未经允许,请勿转载。