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


Python OpenMaya.MFnDagNode方法代码示例

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


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

示例1: get_instancer

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFnDagNode [as 别名]
def get_instancer(spore_node, as_string=True):
    """ return the instancer node connected to a given spore node
    :param spore_node:
    :param as_string: if true return node name else return mObject """

    node_fn = get_dgfn_from_dagpath(spore_node)
    instance_plug = node_fn.findPlug('instanceData')
    plugs = om.MPlugArray()
    instancer_plugs = om.MPlugArray()
    instance_geo = []

    if not instance_plug.isNull():
        if instance_plug.connectedTo(plugs, False, True):
            node = plugs[0].node()
            node_fn = om.MFnDagNode(node)
            if as_string:
                return node_fn.fullPathName()
            else:
                return node 
开发者ID:wiremas,项目名称:spore,代码行数:21,代码来源:node_utils.py

示例2: connect_to_instancer

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFnDagNode [as 别名]
def connect_to_instancer(transform_node, spore_node):
    """ connect a transform's matrix attribute to a instancer node
    that is connected to the given spore node """

    # get instancer's inputHierarchy plug
    instancer_node = get_instancer(spore_node, False)
    dg_fn = om.MFnDependencyNode(instancer_node)
    in_plug = dg_fn.findPlug('inputHierarchy')

    # get transform's matrix plug
    transform_node = get_mobject_from_name(transform_node)
    dag_fn = om.MFnDagNode(transform_node)
    matrix_plug = dag_fn.findPlug('matrix')

    # get first free plug and connect
    plug_id = in_plug.numElements() + 1
    dag_mod = om.MDagModifier()
    dag_mod.connect(matrix_plug, in_plug.elementByLogicalIndex(plug_id))
    dag_mod.doIt() 
开发者ID:wiremas,项目名称:spore,代码行数:21,代码来源:node_utils.py

示例3: createCallbacks

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFnDagNode [as 别名]
def createCallbacks(self):
        # frame changed callback
        # needed for changing the relative keyframe display
        self.mTimeCallbackId = om.MEventMessage.addEventCallback('timeChanged', self.setRelativeFrames)
        # iterate over all cameras add the callback
        # using old api because new doesn't include iterator over dep nodes
        dgit = oldOm.MItDependencyNodes(oldOm.MFn.kCamera)

        while not dgit.isDone():
            t = oldOm.MFnDagNode(dgit.thisNode()).parent(0)
            if t is not None:
                self.mCameraMovedCallbackIds.append(
                    oldOm.MNodeMessage.addAttributeChangedCallback(t, self.cameraMovedCB))
            dgit.next()


    # removing them when the ui is closed 
开发者ID:Viele,项目名称:onionSkinRenderer,代码行数:19,代码来源:onionSkinRendererCore.py

示例4: getCurveFn

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

示例5: getFnFromPlug

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFnDagNode [as 别名]
def getFnFromPlug(plug, fnType):
    node = getSingleSourceObjectFromPlug(plug)

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

        path.extendToShape()

        if path.node().hasFn(fnType):
            return path

    return None

# TODO: cache this data to prevent recalculating when there is no manipulator being updated 
开发者ID:mmerchante,项目名称:instanceAlongCurve,代码行数:19,代码来源:instanceAlongCurve.py

示例6: voxelize

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFnDagNode [as 别名]
def voxelize(self, cell_size):
        """ partition the spatial domain with the given cellsize.
        than assign each point to the cell is spatialy belongs to.
        :return dict: where:
                      key == the cell index
                      value == list of points indexes from the point_data obj """

        partition = {}

        in_mesh = node_utils.get_connected_in_mesh(self.target, False)
        bb = om.MFnDagNode(in_mesh).boundingBox()

        self.w_count = int(math.ceil(bb.width() / cell_size))
        self.h_count = int(math.ceil(bb.height() / cell_size))
        self.d_count = int(math.ceil(bb.depth() / cell_size))

        bb_min = bb.min()
        for i in xrange(self.point_data.position.length()):
            p_normalized = self.point_data.position[i] - bb_min
            p_x = int(p_normalized.x / cell_size)
            p_y = int(p_normalized.y / cell_size)
            p_z = int(p_normalized.z / cell_size)

            index = p_x + p_y * self.w_count + p_z * self.w_count * self.h_count


            partition.setdefault(index, []).append(i)

        return partition 
开发者ID:wiremas,项目名称:spore,代码行数:31,代码来源:spore_sampler.py

示例7: altitude_filter

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFnDagNode [as 别名]
def altitude_filter(self, min_altitude, max_altitude, min_fuzziness, max_fuzziness):
        """ filter points based on y position relative to bounding box """

        in_mesh = node_utils.get_connected_in_mesh(self.target, False)
        dag_fn = om.MFnDagNode(in_mesh)

        bb = dag_fn.boundingBox()
        bb_y_min = bb.min().y
        height = bb.height()

        invalid_ids = []
        for i, (position, _, _, _, _) in enumerate(self.point_data):
            y_normalized = position[1] - bb_y_min
            pos_rel = y_normalized / height

            if pos_rel < min_altitude:
                if pos_rel < min_altitude - min_fuzziness:
                    invalid_ids.append(i)

                elif min_altitude - pos_rel > random.uniform(0, min_fuzziness):
                    invalid_ids.append(i)

            elif pos_rel > max_altitude:
                if pos_rel > max_altitude + max_fuzziness:
                    invalid_ids.append(i)

                elif abs(max_altitude - pos_rel) > random.uniform(0, max_fuzziness):
                    invalid_ids.append(i)

        invalid_ids = sorted(invalid_ids, reverse=True)
        [self.point_data.remove(index) for index in invalid_ids] 
开发者ID:wiremas,项目名称:spore,代码行数:33,代码来源:spore_sampler.py

示例8: redoIt

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

        self.dag_mod_transform.doIt()
        self.dag_mod_spore.doIt()
        self.dag_mod_instancer.doIt()

        # get result
        result = []
        dg_fn = om.MFnDependencyNode(self.spore)
        result.append(dg_fn.name())
        dag_fn = om.MFnDagNode(self.instancer)
        result.append(dag_fn.fullPathName())
        self.clearResult()
        self.setResult(result) 
开发者ID:wiremas,项目名称:spore,代码行数:17,代码来源:spore_command.py

示例9: get_dagfn_from_dagpath

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFnDagNode [as 别名]
def get_dagfn_from_dagpath(dagpath):
    """ return a dag-node functionset to a given dag-path """

    m_dagpath = get_dagpath_from_name(dagpath)
    return om.MFnDagNode(m_dagpath) 
开发者ID:wiremas,项目名称:spore,代码行数:7,代码来源:node_utils.py

示例10: get_instanced_geo

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFnDagNode [as 别名]
def get_instanced_geo(spore_node):
    """ return a list of dag pathes of geometry transformes that
    are connected to the spore node's instancer
    @param spore_node str: the name of the spore node
    @return: list of string or None if no instancer is connected """

    node_fn = get_dgfn_from_dagpath(spore_node)
    instance_plug = node_fn.findPlug('instanceData')
    plugs = om.MPlugArray()
    instancer_plugs = om.MPlugArray()
    instance_geo = []

    if not instance_plug.isNull():
        if instance_plug.connectedTo(plugs, False, True):
            node = plugs[0].node()
            node_fn = om.MFnDagNode(node)
            inst_geo_plug = node_fn.findPlug('inputHierarchy')

            if not inst_geo_plug.isNull():
                for i in xrange(inst_geo_plug.numConnectedElements()):
                    input_plug = inst_geo_plug.elementByPhysicalIndex(i)

                    if input_plug.connectedTo(instancer_plugs, True, True):
                        geo_plug = instancer_plugs[0]
                        geo_node = geo_plug.node()
                        instance_geo.append(om.MFnDagNode(geo_node).fullPathName())

            dg_node_fn = om.MFnDependencyNode(node)
            instancer_node = dg_node_fn.name()

    return instance_geo 
开发者ID:wiremas,项目名称:spore,代码行数:33,代码来源:node_utils.py

示例11: test_createNode_performance

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFnDagNode [as 别名]
def test_createNode_performance():
    """createNode cmdx vs cmds > 2x"""

    versions = (
        ("mel", lambda: mel.eval("createNode \"transform\"")),
        ("cmds", lambda: cmds.createNode("transform")),
        ("cmdx", lambda: cmdx.createNode(cmdx.tTransform)),
        # ("PyMEL", lambda: pm.createNode("transform")),
        ("API 1.0", lambda: om1.MFnDagNode().create("transform")),
        ("API 2.0", lambda: om2.MFnDagNode().create("transform")),
    )

    for contender, test in versions:
        Compare(contender, "createNode", test, setup=New)

    cmdx_vs_cmds = (
        timings["createNode"]["cmds"]["percall"] /
        timings["createNode"]["cmdx"]["percall"]
    )

    cmdx_vs_api = (
        timings["createNode"]["API 2.0"]["percall"] /
        timings["createNode"]["cmdx"]["percall"]
    )

    assert_greater(cmdx_vs_cmds, 0.5)  # at most 2x slower than cmds
    assert_greater(cmdx_vs_api, 0.20)  # at most 5x slower than API 2.0 
开发者ID:mottosso,项目名称:cmdx,代码行数:29,代码来源:test_performance.py

示例12: editCurve

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFnDagNode [as 别名]
def editCurve(parent, points, degree=1, form=kOpen):
    assert isinstance(parent, DagNode), (
        "parent must be of type cmdx.DagNode"
    )

    degree = min(3, max(1, degree))

    cvs = om1.MPointArray()
    curveFn = om1.MFnNurbsCurve()

    for point in points:
        cvs.append(om1.MPoint(*point))

    mobj = curveFn.createWithEditPoints(cvs,
                                        degree,
                                        form,
                                        False,
                                        False,
                                        True,
                                        _encode1(parent.path()))

    mod = om1.MDagModifier()
    mod.renameNode(mobj, parent.name(namespace=True) + "Shape")
    mod.doIt()

    def undo():
        mod.deleteNode(mobj)
        mod.doIt()

    def redo():
        mod.undoIt()

    commit(undo, redo)

    shapeFn = om1.MFnDagNode(mobj)
    return encode(shapeFn.fullPathName()) 
开发者ID:mottosso,项目名称:cmdx,代码行数:38,代码来源:cmdx.py

示例13: getNodeTransformFn

# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFnDagNode [as 别名]
def getNodeTransformFn(self):
        dagNode = OpenMaya.MFnDagNode(self.thisMObject())
        dagPath = OpenMaya.MDagPath()
        dagNode.getPath(dagPath)
        return OpenMaya.MFnDagNode(dagPath.transform()) 
开发者ID:mmerchante,项目名称:instanceAlongCurve,代码行数:7,代码来源:instanceAlongCurve.py

示例14: getInputTransformFn

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

        inputTransformPlug = self.getInputTransformPlug()
        transform = getSingleSourceObjectFromPlug(inputTransformPlug)

        # Get Fn from a DAG path to get the world transformations correctly
        if transform is not None and transform.hasFn(OpenMaya.MFn.kTransform):
                path = OpenMaya.MDagPath()
                trFn = OpenMaya.MFnDagNode(transform)
                trFn.getPath(path)
                return OpenMaya.MFnTransform(path)

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

示例15: findShadingGroup

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

        # Search in children first before extending to shape
        for child in xrange(dagPath.childCount()):
            childDagPath = OpenMaya.MDagPath()
            fnDagNode = OpenMaya.MFnDagNode(dagPath.child(child))
            fnDagNode.getPath(childDagPath)

            fnSet = self.findShadingGroup(childDagPath)

            if fnSet is not None:
                return fnSet

        if self.hasShapeBelow(dagPath):
            dagPath.extendToShape()
            fnDepNode = OpenMaya.MFnDependencyNode(dagPath.node())

            instPlugArray = fnDepNode.findPlug("instObjGroups")
            instPlugArrayElem = instPlugArray.elementByLogicalIndex(dagPath.instanceNumber())

            if instPlugArrayElem.isConnected():
                connectedPlugs = OpenMaya.MPlugArray()      
                instPlugArrayElem.connectedTo(connectedPlugs, False, True)

                if connectedPlugs.length() == 1:
                    sgNode = connectedPlugs[0].node()

                    if sgNode.hasFn(OpenMaya.MFn.kSet):
                        return OpenMaya.MFnSet(sgNode)

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


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