def listAttr_(sNode):
     return listForNone(mc.listAttr(sNode, k=True, ud=True))
Example #2
0
 def listAttr_(sNode):
     return listForNone(mc.listAttr(sNode, k=True, ud=True))
def importFile(sFilePath, **kwargs):

    if not isinstance(sFilePath, basestring):
        raise TypeError, 'Wrong type passed to file path argument: {0}'.format(type(sFilePath))

    if ("%" in sFilePath) or ("$" in sFilePath):
        sResolvedPath = pathResolve(sFilePath)
    else:
        sResolvedPath = sFilePath

    if not osp.isfile(sResolvedPath):
        raise ValueError, 'Import failed. No such file found : "{0}"'.format(sResolvedPath)

    kwargs.pop("defaultNamespace", kwargs.pop("dns", None))
    bReference = kwargs.pop("reference", kwargs.pop("r", False))
    bViewFit = kwargs.pop('viewFit', False)
    bOutNewNodes = kwargs.pop('returnNewNodes', kwargs.pop('rnn', True))
    bPreserveRefs = kwargs.pop('preserveReferences', kwargs.pop('pr', True))
    bNewScene = kwargs.pop('newScene', kwargs.pop('nsc', False))

    if bReference:
        bUseNamespaces = True
        bNewScene = False
    else:
        bUseNamespaces = kwargs.pop('useNamespaces', kwargs.pop('uns', False))

#    sNamespace = ""
    if bUseNamespaces:
        sNamespace = kwargs.pop("namespace", kwargs.pop("ns" , ""))
        if not sNamespace:
            sNamespace = osp.basename(sResolvedPath).rsplit(".", 1)[0]

    ##Three states kwarg:
    ##if newScene == True , importing NewScene is forced
    ##if newScene == False, importing in the CurrentScene
    ##if newScene == "NoEntry", so choose between NewScene and CurrentScene

    if bNewScene == "NoEntry":

        sConfirm = pm.confirmDialog(title="Import File",
                                    message='Import file into ... ?',
                                    button=["New Scene", "Current Scene", "Cancel"],
                                    defaultButton="New Scene",
                                    cancelButton="Cancel",
                                    dismissString="Cancel",
                                    )

        if sConfirm == "Cancel":
            logMsg("Cancelled !" , warning=True)
            return

        bNewScene = True if sConfirm == "New Scene" else False

    if bNewScene:
        if newScene(**kwargs):
            return

    if bReference:
        oNewNodeList = pm.createReference(sFilePath,
                                          namespace=sNamespace,
                                          returnNewNodes=bOutNewNodes,
                                          **kwargs)
    else:
        if bUseNamespaces:
            kwargs["namespace"] = sNamespace

        oNewNodeList = pm.importFile(sResolvedPath,
                                     returnNewNodes=bOutNewNodes,
                                     preserveReferences=bPreserveRefs,
                                     **kwargs)

    oNewNodeList = listForNone(oNewNodeList)

    if oNewNodeList and bViewFit:
        pm.viewFit(all=True)

    return oNewNodeList
Example #4
0
def importFile(sFilePath, **kwargs):

    if not isinstance(sFilePath, basestring):
        raise TypeError, 'Wrong type passed to file path argument: {0}'.format(
            type(sFilePath))

    if ("%" in sFilePath) or ("$" in sFilePath):
        sResolvedPath = pathResolve(sFilePath)
    else:
        sResolvedPath = sFilePath

    if not osp.isfile(sResolvedPath):
        raise ValueError, 'Import failed. No such file found : "{0}"'.format(
            sResolvedPath)

    kwargs.pop("defaultNamespace", kwargs.pop("dns", None))
    bReference = kwargs.pop("reference", kwargs.pop("r", False))
    bViewFit = kwargs.pop('viewFit', False)
    bOutNewNodes = kwargs.pop('returnNewNodes', kwargs.pop('rnn', True))
    bPreserveRefs = kwargs.pop('preserveReferences', kwargs.pop('pr', True))
    bNewScene = kwargs.pop('newScene', kwargs.pop('nsc', False))

    if bReference:
        bUseNamespaces = True
        bNewScene = False
    else:
        bUseNamespaces = kwargs.pop('useNamespaces', kwargs.pop('uns', False))


#    sNamespace = ""
    if bUseNamespaces:
        sNamespace = kwargs.pop("namespace", kwargs.pop("ns", ""))
        if not sNamespace:
            sNamespace = osp.basename(sResolvedPath).rsplit(".", 1)[0]

    ##Three states kwarg:
    ##if newScene == True , importing NewScene is forced
    ##if newScene == False, importing in the CurrentScene
    ##if newScene == "NoEntry", so choose between NewScene and CurrentScene

    if bNewScene == "NoEntry":

        sConfirm = pm.confirmDialog(
            title="Import File",
            message='Import file into ... ?',
            button=["New Scene", "Current Scene", "Cancel"],
            defaultButton="New Scene",
            cancelButton="Cancel",
            dismissString="Cancel",
        )

        if sConfirm == "Cancel":
            logMsg("Cancelled !", warning=True)
            return

        bNewScene = True if sConfirm == "New Scene" else False

    if bNewScene:
        if newScene(**kwargs):
            return

    if bReference:
        oNewNodeList = pm.createReference(sFilePath,
                                          namespace=sNamespace,
                                          returnNewNodes=bOutNewNodes,
                                          **kwargs)
    else:
        if bUseNamespaces:
            kwargs["namespace"] = sNamespace

        oNewNodeList = pm.importFile(sResolvedPath,
                                     returnNewNodes=bOutNewNodes,
                                     preserveReferences=bPreserveRefs,
                                     **kwargs)

    oNewNodeList = listForNone(oNewNodeList)

    if oNewNodeList and bViewFit:
        pm.viewFit(all=True)

    return oNewNodeList