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


Python OpenMaya.MDagPath方法代码示例

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


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

示例1: getSkinWeights

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [as 别名]
def getSkinWeights(dag, skinCluster, component):
    """
    Get the skin weights of the original vertex and of its connected vertices.

    :param OpenMaya.MDagPath dag:
    :param OpenMayaAnim.MFnSkinCluster skinCluster:
    :param OpenMaya.MFn.kMeshVertComponent component:
    :return: skin weights and number of influences
    :rtype: tuple(OpenMaya.MDoubleArray, int)
    """
    # weights variables
    weights = OpenMaya.MDoubleArray()

    # influences variables
    influenceMSU = OpenMaya.MScriptUtil()
    influencePTR = influenceMSU.asUintPtr()

    # get weights
    skinCluster.getWeights(dag, component, weights, influencePTR)

    # get num influences
    num = OpenMaya.MScriptUtil.getUint(influencePTR)

    return weights, num 
开发者ID:robertjoosten,项目名称:maya-skinning-tools,代码行数:26,代码来源:skin.py

示例2: modify_radius

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [as 别名]
def modify_radius(self):
        """ modify the brush radius """

        delta_x = self.state.last_x - self.state.cursor_x

        view = window_utils.active_view()
        cam_dag = om.MDagPath()
        view.getCamera(cam_dag)
        cam_node_fn = node_utils.get_dgfn_from_dagpath(cam_dag.fullPathName())
        cam_coi = cam_node_fn.findPlug('centerOfInterest').asDouble()

        step = delta_x * (cam_coi * -0.01)
        if (self.state.radius + step) >= 0.01:
            self.state.radius += step

        else:
            self.state.radius = 0.01 
开发者ID:wiremas,项目名称:spore,代码行数:19,代码来源:spore_context.py

示例3: get_mesh_fn

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [as 别名]
def get_mesh_fn(target):
    """ get mesh function set for the given target
    :param target: dag path of the mesh
    :return MFnMesh """

    if isinstance(target, str) or isinstance(target, unicode):
        slls = om.MSelectionList()
        slls.add(target)
        ground_path = om.MDagPath()
        slls.getDagPath(0, ground_path)
        ground_path.extendToShapeDirectlyBelow(0)
        ground_node = ground_path.node()
    elif isinstance(target, om.MObject):
        ground_node = target
        ground_path = target
    elif isinstance(target, om.MDagPath):
        ground_node = target.node()
        ground_path = target
    else:
        raise TypeError('Must be of type str, MObject or MDagPath, is type: {}'.format(type(target)))

    if ground_node.hasFn(om.MFn.kMesh):
        return om.MFnMesh(ground_path)
    else:
        raise TypeError('Target must be of type kMesh') 
开发者ID:wiremas,项目名称:spore,代码行数:27,代码来源:mesh_utils.py

示例4: getGeometryComponents

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [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

示例5: getCurrentWeights

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [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

示例6: getComponent

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [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

示例7: getDagPathComponents

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [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

示例8: getNormals

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [as 别名]
def getNormals(dag):
    """
    Get the average normal in world space of each vertex on the provided mesh.
    The reason why OpenMaya.MItMeshVertex function has to be used is that the
    MFnMesh class returns incorrect normal results.

    :param OpenMaya.MDagPath dag:
    :return: Normals
    :rtype: list
    """
    # variables
    normals = []

    iter = OpenMaya.MItMeshVertex(dag)
    while not iter.isDone():
        # get normal data
        normal = OpenMaya.MVector()
        iter.getNormal(normal, OpenMaya.MSpace.kWorld)
        normals.append(normal)

        iter.next()

    return normals 
开发者ID:robertjoosten,项目名称:maya-skinning-tools,代码行数:25,代码来源:mesh.py

示例9: getConnectedVertices

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [as 别名]
def getConnectedVertices(dag, component):
    """
    index -> OpenMaya.MFn.kMeshVertComponent

    :param OpenMaya.MDagPath dag:
    :param OpenMaya.MFn.kMeshVertComponent component:
    :return: Initialized component(s), number of connected vertices
    :rtype: tuple(OpenMaya.MFn.kMeshVertComponent, int)
    """
    connected = OpenMaya.MIntArray()

    # get connected vertices
    iter = OpenMaya.MItMeshVertex(dag, component)
    iter.getConnectedVertices(connected)

    # get component of connected vertices
    component = asComponent(connected)
    return component, len(connected) 
开发者ID:robertjoosten,项目名称:maya-skinning-tools,代码行数:20,代码来源:mesh.py

示例10: dagPath

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [as 别名]
def dagPath(self):
        """Return a om.MDagPath for this node

        Example:
            >>> _ = cmds.file(new=True, force=True)
            >>> parent = createNode("transform", name="Parent")
            >>> child = createNode("transform", name="Child", parent=parent)
            >>> path = child.dagPath()
            >>> str(path)
            'Child'
            >>> str(path.pop())
            'Parent'

        """

        return om.MDagPath.getAPathTo(self._mobject) 
开发者ID:mottosso,项目名称:cmdx,代码行数:18,代码来源:cmdx.py

示例11: _encodedagpath1

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [as 别名]
def _encodedagpath1(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)

    dagpath = om1.MDagPath()
    selectionList.getDagPath(0, dagpath)
    return dagpath 
开发者ID:mottosso,项目名称:cmdx,代码行数:23,代码来源:cmdx.py

示例12: sortKey

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [as 别名]
def sortKey(self):
		"""
		Computed property that builds a sort key based on a 
		combination of attributes. 
		Allows sorting to consider multiple keys. 
		"""
		if self.dagObj:
			self.apiType = self.dagObj.apiType()

			dagCopy = om.MDagPath(self.dagObj)
			try:
				dagCopy.extendToShape()
				self.shapeApiType = dagCopy.apiType()
			except RuntimeError:
				self.shapeApiType = om.MFn.kInvalid

		key = '%s%s%s' % (self.apiType, self.shapeApiType, self.name)
		return key 
开发者ID:justinfx,项目名称:tutorials,代码行数:20,代码来源:outliner3.py

示例13: sortKey

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [as 别名]
def sortKey(self):
		"""
		Computed property that builds a sort key based on a 
		combination of attributes. 
		Allows sorting to consider multiple keys. 
		"""
		if self.dagObj:
			dagCopy = om.MDagPath(self.dagObj)

			try:
				dagCopy.extendToShape()
				self.apiType = dagCopy.apiType()
			
			except RuntimeError:
				self.apiType = self.dagObj.apiType()

		key = '{0}{1}'.format(self.apiType, self.name)
		return key 
开发者ID:justinfx,项目名称:tutorials,代码行数:20,代码来源:outliner2.py

示例14: getCurveFn

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [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

示例15: gather_influence_weights

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDagPath [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.MDagPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。