Beispiel #1
0
def _makeDgModGhostObject(mayaType, dagMod, dgMod):
    # we create a dummy object of this type in a dgModifier (or dagModifier)
    # as the dgModifier.doIt() method is never called, the object
    # is never actually created in the scene

    # Note: at one point, if we didn't call the dgMod/dagMod.deleteNode method,
    # and we call this function while loading a scene (for instance, if the scene requires
    # a plugin that isn't loaded, and defines custom node types), then the nodes were still
    # somehow created, despite never explicitly calling doIt()...
    # ... however, this seems to no longer be the case, and the deleteNode calls are apparently
    # harmful
    if type(dagMod) is not api.MDagModifier or type(
            dgMod) is not api.MDGModifier:
        raise ValueError, "Need a valid MDagModifier and MDGModifier or cannot return a valid MObject"

    # Regardless of whether we're making a DG or DAG node, make a parent first -
    # for some reason, this ensures good cleanup (don't ask me why...??)
    parent = dagMod.createNode('transform', api.MObject())

    try:
        # DependNode
        obj = dgMod.createNode(mayaType)
    except RuntimeError:
        # DagNode
        try:
            obj = dagMod.createNode(mayaType, parent)
        except Exception, err:
            _logger.debug("Error trying to create ghost node for '%s': %s" %
                          (mayaType, err))
            return None
Beispiel #2
0
def _makeDgModGhostObject(mayaType, dagMod, dgMod):
    if versions.current() >= versions.v2012:
        # only time post-2012 when we should have to call this func is when
        # rebuilding caches - ie, running from inside ApiCache
        if not GhostObjsOkHere.OK():
            _logger.raiseLog(_logger.WARNING, '_makeDgModGhostObject should be unnecessary in maya versions past 2012 (except when rebuilding cache)')

    # we create a dummy object of this type in a dgModifier (or dagModifier)
    # as the dgModifier.doIt() method is never called, the object
    # is never actually created in the scene

    # Note: at one point, if we didn't call the dgMod/dagMod.deleteNode method,
    # and we call this function while loading a scene (for instance, if the scene requires
    # a plugin that isn't loaded, and defines custom node types), then the nodes were still
    # somehow created, despite never explicitly calling doIt()...
    # ... however, this seems to no longer be the case, and the deleteNode calls are apparently
    # harmful
    if type(dagMod) is not api.MDagModifier or type(dgMod) is not api.MDGModifier:
        raise ValueError, "Need a valid MDagModifier and MDGModifier or cannot return a valid MObject"

    # Regardless of whether we're making a DG or DAG node, make a parent first -
    # for some reason, this ensures good cleanup (don't ask me why...??)
    parent = dagMod.createNode('transform', api.MObject())

    try:
        # DependNode
        obj = dgMod.createNode(mayaType)
    except RuntimeError:
        # DagNode
        try:
            obj = dagMod.createNode(mayaType, parent)
        except Exception, err:
            _logger.debug("Error trying to create ghost node for '%s': %s" % (mayaType, err))
            return None