def publish_fbx_anim_file(versionUp=True, origScene=None, *args):
    # THIS IS FOR ANIM EXPORTING

    # save current scene
    # check whether gameexport plug in is loaded
    mel.eval("gameFbxExporter;")
    # version up
    if versionUp:
        verUpFile = get_version_up_name(origScene)
        copy2(origScene, verUpFile)
        print "===== Versioned up {0} to {1}!".format(origScene, verUpFile)
    else:
        print "===== Not versioning up publish of {0}".format(origScene)

    if not origScene:
        cmds.warning(
            "assetPublish.publish_fbx_anim_file: You haven't passed in a scene path!"
        )
        return (False)

# assuming references
    refs = cmds.file(q=True, r=True)
    if not refs:
        cmds.warning("There are no references in this scene. . .")
        return (False)
    if len(refs) > 1:
        cmds.warning("There are too many references in this scene. . .")
        return (False)


# below would all be under a for loop for each reference in the stages?
    pp = uf.PathParser(origScene)

    # assuming a namespace
    geoGrp = cmds.ls("*:GEO")
    jntGrp = cmds.ls("*:EXPORT_JNT_Grp")

    # check for geo grps
    if not geoGrp or len(geoGrp) > 1:
        cmds.warning(
            "AssetPublish.publish_fbx_anim_file:You either have no grp called 'GEO' -IN A NAMESPACE-, or too many objects called 'GEO'.\n fbx export aborted!"
        )
        return (False)
    geos = child_match_check(geoGrp[0], "*_Geo_Grp")
    if not geos:
        return (False)

    # check for jnt grps
    if not jntGrp or len(jntGrp) > 1:
        cmds.warning(
            "AssetPublish.publish_fbx_anim_file:You either have no grp called 'EXPORT_JNT_Grp' -IN A NAMESPACE-, or too many objects called 'EXPORT_JNT_Grp'.\n fbx export aborted!"
        )
        return (False)
    roots = child_match_check(jntGrp[0], "*_Root_Jnt")
    if not roots:
        return (False)

    # check correspondence of geo and root jnts
    correspond = check_correspondence(geos, roots)
    if not correspond:
        return (False)

    cmds.file(refs[0], ir=True)

    pubFbxPath = uf.fix_path(os.path.join(pp.phasePath, "Publish/FBX/"))
    tokens = pp.fileName.split("_")
    tokens[-2] = "Publish"
    pubFileName = "_".join(tokens)[:-3] + ".fbx"
    pubFilePath = uf.fix_path(os.path.join(pubFbxPath, pubFileName))

    start, end = uf.get_frame_range()

    # bake joints
    for r in roots:
        # get child roots if joints
        allD = cmds.listRelatives(r, allDescendents=True)
        jnts = [x for x in allD if cmds.objectType(x, isa="joint")]
        # function to bake selected on all jnts under this root
        bake_selected(jnts, start, end)

    namespace = cmds.file(refs[0], q=True, ns=True)
    uf.remove_namespaces()

    # delete constraints
    cmds.delete(cmds.ls(type="constraint"))
    cmds.select(cl=True)
    # move jnts and geo into world parent
    for root in roots:
        rootremove = "{0}:".format(namespace)
        basename = root.split(":")[1].split("_Root_Jnt")[0]
        geo = "{0}_Geo_Grp".format(basename)
        root = "{0}_Root_Jnt".format(basename)
        cmds.parent([geo, root], w=True)
        tokens[-2] = basename
        pubFileName = "_".join(tokens)[:-3]
        pubFilePath = uf.fix_path(os.path.join(pubFbxPath, pubFileName))
        rootremove = "{0}:".format(namespace)
        cmds.select([root, geo], r=True)
        # do this the cmds way
        nodes = mel.eval("gameExp_GetGameFbxExporterNodeList()")
        cmds.select(nodes, add=True)

        keep = [root, geo]
        for node in nodes:
            keep.append(node)

        # delete all other top level nodes
        delete_other_top_level_nodes(keep)

        # if this exists, should we overwrite?
        if os.path.isfile(pubFilePath):
            overwrite = cmds.confirmDialog(
                title="Overwrite Confirmation",
                message=
                "A publish FBX already exists for this file.\nShould we overwrite?",
                button=("Overwrite", "Cancel"),
                defaultButton="Overwrite",
                cancelButton="Cancel",
                dismissString="Cancel")

            if overwrite == "Cancel":
                print "Publish skipped for FBX file (.fbx) called {0}".format(
                    pubFilePath)
                return (True)

        # get path for maya publish
        pubsplits = pubFilePath.split("/")
        pubsplits[-2] = "MB"
        mayapubpath = "/".join(pubsplits)

        # just export maya scene here. . . to publish (need to get mb path)
        # get the latest "gameExporterPreset*" for export (not sure if latest what we want?)
        if not nodes:
            cmds.warning(
                "You don't have any game export nodes in your scene. Just exporting a straight fbx clip!"
            )
            mel.eval('FBXLoadExportPresetFile -f "{0}";'.format(anmPreset))
            mel.eval('FBXExport -f "{0}" -s'.format(pubFilePath + ".fbx"))

        else:
            print "===== anim publish:\n- saving {0}".format(mayapubpath +
                                                             ".mb")
            cmds.file(mayapubpath + ".mb", es=True, f=True, type="mayaBinary")
            print "- opening {0}".format(mayapubpath + ".mb")
            hold = cmds.file(mayapubpath + ".mb", o=True, f=True)
            print "-formatting and exporting"
            # check that we're doing all we can here. . . .
            # uf.set_gameExport_info(gnodes[-1], filepath, filename)
            ge.set_and_export(pubFilePath + ".fbx")

    return (True)
Пример #2
0
def publish_fbx_anim_file(versionUp=True, origScene=None, references=None, *args):
    """
    Assumes we're in an anim assembly scene that contains referenced rigs (only one namespace)
    This will spit out maya scenes that are ready for fbx export. One maya scene per reference object in the current scene, each of which contains only the mesh and joint groups that need to be exported. These scenes contain all available 'rigs' from that asset.
    Args:
        versionup (bool): whether we should version up the current scene
        origscene (string): the full path to the original scene we're trying to publish
        references (list): list of the reference paths in the scene to deal with
    Returns:
        bool: whether we've run through all successfully
    """
    cmds.file(s=True)

    # check whether game exporter plugin is loaded, load if not
    uf.plugin_load("gameFbxExporter")

# check if there are any gmae export nodes, bail if not? or bail in the later stage - calling function

    # version up
    if versionUp:
        verUpFile = get_version_up_name(origScene)
        copy2(origScene, verUpFile)
        print "===== Versioned up {0} to {1}!".format(origScene, verUpFile)
    else:
        print "===== Not versioning up publish of {0}".format(origScene) 

    if not origScene:
        cmds.warning("assetPublish.publish_fbx_anim_file: You haven't passed in a scene path!")
        publishState = False
        return()

    # assuming references
    refs = references
    if not refs:
        cmds.warning("There are no references in this scene. . .")
        publishState = False
        return()

    # cull out the bad references from our input list
    goodRefs = cull_bad_references(refs)


# bake all jnts THEN do all the rest
    for ref in goodRefs:
        namespace = cmds.file(ref, q=True, ns=True)
        print "BAKING JOINTS FOR: {0}".format(namespace)        
        geoGrp = cmds.ls("{0}:GEO".format(namespace))
        jntGrp = cmds.ls("{0}:EXPORT_JNT_Grp".format(namespace))        
        
        geos = child_match_check(geoGrp[0], "*_Geo_Grp")
        roots = child_match_check(jntGrp[0], "*_Root_Jnt")

        start, end = uf.get_frame_range()

       # bake joints
        for r in roots:
            # get child roots if joints
            allD = cmds.listRelatives(r, allDescendents=True)
            jnts = [x for x in allD if cmds.objectType(x, isa="joint")]
            # function to bake selected on all jnts under this root
            bake_selected(jnts, start, end)

    for ref in goodRefs:
        pp = uf.PathParser(origScene)
        
        namespace = cmds.file(ref, q=True, ns=True)
        
        geoGrp = cmds.ls("{0}:GEO".format(namespace))
        jntGrp = cmds.ls("{0}:EXPORT_JNT_Grp".format(namespace))        
        
        # imports the reference
        cmds.file(ref, ir=True)

        geos = child_match_check(geoGrp[0], "*_Geo_Grp")
        roots = child_match_check(jntGrp[0], "*_Root_Jnt")

        # here's where we'd do the folder (figure out path stuff) - add the variant name
        pubFbxPath = uf.fix_path(os.path.join(pp.phasePath, "Publish/MB/{0}_v{1}".format(pp.variant, pp.versionString)))
        print "------- trying to make directory: {0}".format(pubFbxPath)
        if not os.path.exists(pubFbxPath):
            os.makedirs(pubFbxPath)
        tokens = pp.fileName.split("_")
        tokens[-2] = namespace

        start, end = uf.get_frame_range()

        # delete constraints
        cmds.delete(cmds.ls("{0}:*".format(namespace), type="constraint"))
        cmds.select(cl=True)

        # get list of roots in this ref
        fullKeepList = []
        for root in roots:
            basename = root.split(":")[1].split("_Root_Jnt")[0]
            geo = "{0}:{1}_Geo_Grp".format(namespace, basename)
            root = "{0}:{1}_Root_Jnt".format(namespace, basename)
            cmds.parent([geo, root], w=True)
            fullKeepList.append(geo)
            fullKeepList.append(root)
        cmds.select(fullKeepList, r=True)
        delete_other_top_level_nodes(cmds.ls(sl=True))

        try:
            cmds.namespace(mv=[namespace, ":"], f=True)
            cmds.namespace(rm=namespace)
        except:
            cmds.warning("NAMESPACE PROBLEM!", namespace)

        # collect the roots to export
        for root in roots:
            exportList = []
            basename = root.split(":")[1].split("_Root_Jnt")[0]
            geo = "{0}_Geo_Grp".format(basename)
            root = "{0}_Root_Jnt".format(basename)
            nodes = cmds.ls(type="gameFbxExporter")
            exportList.append(root)
            exportList.append(geo)
            for node in nodes:
                exportList.append(node)

            cmds.select(exportList, r=True)
            print "multiRefAnimExport.publish_fbx_anim_file: exporting -- \n {0}".format(exportList)
            # strip away namespace (if it's there)
            tokens[2] = basename
            pubFileName = "_".join(tokens)
            pubFilePath = uf.fix_path(os.path.join(pubFbxPath, pubFileName))

            # if this exists, should we overwrite?
            if os.path.isfile(pubFilePath):
                overwrite = cmds.confirmDialog(title="Overwrite Confirmation", message = "A publish FBX already exists for this file.\nShould we overwrite?", button = ("Overwrite", "Cancel"), defaultButton = "Overwrite", cancelButton = "Cancel", dismissString = "Cancel")

                if overwrite == "Cancel":
                    print "multiRefAnimExport.publish_fbx_anim_file:Publish skipped for FBX file (.fbx) called {0}".format(pubFilePath)
                    return() 

            print "===== anim publish:\n- saving {0}".format(pubFilePath)
            cmds.file(pubFilePath + ".mb", es=True, f=True, type="mayaBinary")

    return(True)
Пример #3
0
def publish_fbx_anim_file(versionUp=True, origScene=None, *args):
    """
    This is for asset anim exporting. File requires ONE AND ONLY ONE reference
    """
    # save current scene
    # check whether gameexport plug in is loaded
    mel.eval("gameFbxExporter;")
    # version up
    if versionUp:
        verUpFile = get_version_up_name(origScene)
        copy2(origScene, verUpFile)
        print "===== Versioned up {0} to {1}!".format(origScene, verUpFile)
    else:
        print "===== Not versioning up publish of {0}".format(origScene)

    if not origScene:
        cmds.warning(
            "assetPublish.publish_fbx_anim_file: You haven't passed in a scene path!"
        )
        return (False)

    refs = cmds.file(q=True, r=True)
    if not refs:
        cmds.warning("There are no references in this scene. . .")
        return (False)
    if len(refs) > 1:
        cmds.warning("There are too many references in this scene. . .")
        return (False)
    pp = uf.PathParser(origScene)

    # assuming a namespace
    geoGrp = cmds.ls("*:GEO")
    jntGrp = cmds.ls("*:EXPORT_JNT_Grp")

    # check for geo grps
    if not geoGrp or len(geoGrp) > 1:
        cmds.warning(
            "AssetPublish.publish_fbx_anim_file:You either have no grp called 'GEO' -IN A NAMESPACE-, or too many objects called 'GEO'.\n fbx export aborted!"
        )
        return (False)
    geos = child_match_check(geoGrp[0], "*_Geo_Grp")
    if not geos:
        return (False)

    # check for jnt grps
    if not jntGrp or len(jntGrp) > 1:
        cmds.warning(
            "AssetPublish.publish_fbx_anim_file:You either have no grp called 'EXPORT_JNT_Grp' -IN A NAMESPACE-, or too many objects called 'EXPORT_JNT_Grp'.\n fbx export aborted!"
        )
        return (False)
    roots = child_match_check(jntGrp[0], "*_Root_Jnt")
    if not roots:
        return (False)

    # check correspondence of geo and root jnts
    correspond = check_correspondence(geos, roots)
    if not correspond:
        return (False)

    cmds.file(refs[0], ir=True)

    pubFbxPath = uf.fix_path(
        os.path.join(
            pp.phasePath,
            "Publish/FBX/{0}_v{1}".format(pp.variant, pp.versionString)))
    print pubFbxPath

    if not os.path.isdir(pubFbxPath):
        os.makedirs(pubFbxPath)

    tokens = pp.fileName.split("_")[:3]
    pubFileName = "_".join(tokens) + ".fbx"
    pubFilePath = uf.fix_path(os.path.join(pubFbxPath, pubFileName))

    start, end = uf.get_frame_range()

    # bake joints
    for r in roots:
        # get child roots if joints
        allD = cmds.listRelatives(r, allDescendents=True)
        jnts = [x for x in allD if cmds.objectType(x, isa="joint")]
        # function to bake selected on all jnts under this root
        bake_selected(jnts, start, end)

    namespace = cmds.file(refs[0], q=True, ns=True)
    uf.remove_namespaces()

    # delete constraints
    cmds.delete(cmds.ls(type="constraint"))
    cmds.select(cl=True)
    # move jnts and geo into world parent
    for root in roots:
        rootremove = "{0}:".format(namespace)
        basename = root.split(":")[1].split("_Root_Jnt")[0]
        geo = "{0}_Geo_Grp".format(basename)
        root = "{0}_Root_Jnt".format(basename)
        cmds.parent([geo, root], w=True)
        tokens[-1] = basename
        pubFileName = "_".join(tokens)
        pubFilePath = uf.fix_path(os.path.join(pubFbxPath, pubFileName))
        rootremove = "{0}:".format(namespace)
        cmds.select([root, geo], r=True)

        nodes = cmds.ls(type="gameFbxExporter")
        if not nodes:
            cmds.warning(
                "AssetPublish.publish_fbx_anim_files: You don't have any game exporter nodes in your scene! Aborting!"
            )
            return ()
        cmds.select(nodes, add=True)

        keep = [root, geo]
        for node in nodes:
            keep.append(node)

        # delete all other top level nodes
        delete_other_top_level_nodes(keep)

        # if this exists, should we overwrite?
        if os.path.isfile(pubFilePath):
            overwrite = cmds.confirmDialog(
                title="Overwrite Confirmation",
                message=
                "A publish FBX already exists for this file.\nShould we overwrite?",
                button=("Overwrite", "Cancel"),
                defaultButton="Overwrite",
                cancelButton="Cancel",
                dismissString="Cancel")

            if overwrite == "Cancel":
                print "Publish skipped for FBX file (.fbx) called {0}".format(
                    pubFilePath)
                return (True)

        # get path for maya publish
        pubsplits = pubFilePath.split("/")
        pubsplits[-3] = "MB"
        mayapubpath = "/".join(pubsplits)

        # if there's not a game export node, just export an fbx, otherwise do the game export all to one clip
        if not nodes:
            cmds.warning(
                "You don't have any game export nodes in your scene. Just exporting a straight fbx animation!"
            )
            mel.eval('FBXLoadExportPresetFile -f "{0}";'.format(anmPreset))
            mel.eval('FBXExport -f "{0}" -s'.format(pubFilePath + ".fbx"))

        else:
            print "===== anim publish:\n- saving {0}".format(mayapubpath +
                                                             ".mb")
            cmds.file(mayapubpath + ".mb", es=True, f=True, type="mayaBinary")
            print "multiRefAnimExport.publish_fbx_anim_file: opening {0}".format(
                mayapubpath + ".mb")
            hold = cmds.file(mayapubpath + ".mb", o=True, f=True)
            # set the export parameters
            uf.set_gameExport_info(nodes[-1], pubFbxPath, pubFileName)
            print "========= multiRefAnimExport.publish_fbx_anim_file: trying to publish FBX {0}/{1}".format(
                pubFbxPath, pubFileName + ".fbx")
            #game export
            mel.eval("gameExp_DoExport;")

    return (True)
def publish_fbx_anim_file(versionUp=True, origScene=None, *args):
    # THIS IS FOR ANIM EXPORTING

    # save current scene
    # move this to end and use Zed's script to version up afterwards? ? maybe?
    # version up
    if versionUp:
        verUpFile = get_version_up_name(origScene)
        copy2(origScene, verUpFile)
        print "===== Versioned up {0} to {1}!".format(origScene, verUpFile)
    else:
        print "===== Not versioning up publish of {0}".format(origScene)

    if not origScene:
        cmds.warning(
            "assetPublish.publish_fbx_anim_file: You haven't passed in a scene path!"
        )
        return (False)

# assuming references
    refs = cmds.file(q=True, r=True)
    if not refs:
        cmds.warning("There are no references in this scene. . .")
        return (False)
    if len(refs) > 1:
        cmds.warning("There are too many references in this scene. . .")
        return (False)


# below would all be under a for loop for each reference in the stages?
    pp = uf.PathParser(origScene)

    # assuming a namespace
    geoGrp = cmds.ls("*:GEO")
    jntGrp = cmds.ls("*:EXPORT_JNT_Grp")

    # check for geo grps
    if not geoGrp or len(geoGrp) > 1:
        cmds.warning(
            "AssetPublish.publish_fbx_anim_file:You either have no grp called 'GEO' -IN A NAMESPACE-, or too many objects called 'GEO'.\n fbx export aborted!"
        )
        return (False)
    geos = child_match_check(geoGrp[0], "*_Geo_Grp")
    if not geos:
        return (False)

    # check for jnt grps
    if not jntGrp or len(jntGrp) > 1:
        cmds.warning(
            "AssetPublish.publish_fbx_anim_file:You either have no grp called 'EXPORT_JNT_Grp' -IN A NAMESPACE-, or too many objects called 'EXPORT_JNT_Grp'.\n fbx export aborted!"
        )
        return (False)
    roots = child_match_check(jntGrp[0], "*_Root_Jnt")
    if not roots:
        return (False)

    cmds.file(refs[0], ir=True)

    # check correspondence of geo and root jnts
    correspond = check_correspondence(geos, roots)
    if not correspond:
        return (False)

    pubFbxPath = uf.fix_path(os.path.join(pp.phasePath, "Publish/FBX/"))
    tokens = pp.fileName.split("_")
    tokens[-2] = "Publish"
    pubFileName = "_".join(tokens)[:-3] + ".fbx"
    pubFilePath = uf.fix_path(os.path.join(pubFbxPath, pubFileName))

    start, end = uf.get_frame_range()

    # bake joints
    for r in roots:
        # get child roots if joints
        allD = cmds.listRelatives(r, allDescendents=True)
        jnts = [x for x in allD if cmds.objectType(x, isa="joint")]
        # function to bake selected on all jnts under this root
        bake_selected(jnts, start, end)

    namespace = cmds.file(refs[0], q=True, ns=True)
    uf.remove_namespaces()

    # delete constraints
    cmds.delete(cmds.ls(type="constraint"))
    cmds.select(cl=True)
    # move jnts and geo into world parent
    for root in roots:
        rootremove = "{0}:".format(namespace)
        basename = root.split(":")[1].split("_Root_Jnt")[0]
        geo = "{0}_Geo_Grp".format(basename)
        root = "{0}_Root_Jnt".format(basename)
        cmds.parent([geo, root], w=True)
        tokens[-2] = basename
        pubFileName = "_".join(tokens)[:-3] + ".fbx"
        pubFilePath = uf.fix_path(os.path.join(pubFbxPath, pubFileName))
        rootremove = "{0}:".format(namespace)
        cmds.select([root, geo], r=True)

        # if this exists, should we overwrite?
        if os.path.isfile(pubFilePath):
            overwrite = cmds.confirmDialog(
                title="Overwrite Confirmation",
                message=
                "A publish FBX already exists for this file.\nShould we overwrite?",
                button=("Overwrite", "Cancel"),
                defaultButton="Overwrite",
                cancelButton="Cancel",
                dismissString="Cancel")

            if overwrite == "Cancel":
                print "Publish skipped for FBX file (.fbx) called {0}".format(
                    pubFilePath)
                return (True)

        mel.eval('FBXLoadExportPresetFile -f "{0}";'.format(anmPreset))
        mel.eval('FBXExport -f "{0}" -s'.format(pubFilePath))

    return (True)
def publish_fbx_anim_file(versionUp=True, origScene=None, *args):
    """
    Assumes we're in an anim assembly scene that contains referenced rigs (only one namespace)
    This will spit out maya scenes that are ready for fbx export. One maya scene per reference object in the current scene, each of which contains only the mesh and joint groups that need to be exported. These scenes contain all available 'rigs' from that asset.
    Args:
        versionup (bool): whether we should version up the current scene
        origscene (string): the full path to the original scene we're trying to publish
    Returns:
        bool: whether we've run through all successfully
    """
    cmds.file(s=True)

    # check whether game exporter plugin is loaded, load if not
    uf.plugin_load("gameFbxExporter")

    # version up
    if versionUp:
        verUpFile = get_version_up_name(origScene)
        copy2(origScene, verUpFile)
        print "===== Versioned up {0} to {1}!".format(origScene, verUpFile)
    else:
        print "===== Not versioning up publish of {0}".format(origScene)

    if not origScene:
        cmds.warning(
            "assetPublish.publish_fbx_anim_file: You haven't passed in a scene path!"
        )
        return (False)

    # assuming references
    refs = cmds.file(q=True, r=True)
    if not refs:
        cmds.warning("There are no references in this scene. . .")
        return (False)

    for ref in refs:
        pp = uf.PathParser(origScene)
        namespace = cmds.file(ref, q=True, ns=True)

        # assuming a namespace
        geoGrp = cmds.ls("{0}:GEO".format(namespace))
        jntGrp = cmds.ls("{0}:EXPORT_JNT_Grp".format(namespace))

        # check for geo grps
        if not geoGrp:
            cmds.warning(
                "AssetPublish.publish_fbx_anim_file:You have no grp called 'GEO' -IN A NAMESPACE-.\n fbx export aborted!"
            )
            return (False)
        geos = child_match_check(geoGrp[0], "*_Geo_Grp")
        if not geos:
            return (False)

        # check for jnt grps
        if not jntGrp:
            cmds.warning(
                "AssetPublish.publish_fbx_anim_file:You either have no grp called 'EXPORT_JNT_Grp' -IN A NAMESPACE-.\n fbx export aborted!"
            )
            return (False)
        roots = child_match_check(jntGrp[0], "*_Root_Jnt")
        if not roots:
            return (False)

        # imports the reference
        cmds.file(ref, ir=True)

        # check correspondence of geo and root jnts
        correspond = check_correspondence(geos, roots)
        if not correspond:
            return (False)

        # here's where we'd do the folder (figure out path stuff) - add the variant name
        pubFbxPath = uf.fix_path(
            os.path.join(
                pp.phasePath,
                "Publish/MB/{0}_v{1}".format(pp.variant, pp.versionString)))
        print "------- trying to make dirctory: {0}".format(pubFbxPath)
        if not os.path.exists(pubFbxPath):
            os.mkdir(pubFbxPath)
        tokens = pp.fileName.split("_")
        tokens[-2] = namespace

        start, end = uf.get_frame_range()

        # bake joints
        for r in roots:
            # get child roots if joints
            allD = cmds.listRelatives(r, allDescendents=True)
            jnts = [x for x in allD if cmds.objectType(x, isa="joint")]
            # function to bake selected on all jnts under this root
            bake_selected(jnts, start, end)

        # delete constraints
        cmds.delete(cmds.ls("{0}:*".format(namespace), type="constraint"))
        cmds.select(cl=True)

        # list for what to keep in this reference
        keepList = []

        # parent each root to world
        for root in roots:
            basename = root.split(":")[1].split("_Root_Jnt")[0]
            geo = "{0}:{1}_Geo_Grp".format(namespace, basename)
            root = "{0}:{1}_Root_Jnt".format(namespace, basename)
            cmds.parent([geo, root], w=True)
            # make this a more generic way to get the game nodes!! (search for type)
            nodes = cmds.ls(type="gameFbxExporter")
            keepList.append(root)
            keepList.append(geo)
            for node in nodes:
                keepList.append(node)

        cmds.select(keepList, r=True)
        # strip away namespace
        cmds.namespace(mv=[namespace, ":"], f=True)
        cmds.namespace(rm=namespace)
        # delete all other top level nodes
        delete_other_top_level_nodes(cmds.ls(sl=True))
        pubFileName = "_".join(tokens)
        pubFilePath = uf.fix_path(os.path.join(pubFbxPath, pubFileName))

        # if this exists, should we overwrite?
        if os.path.isfile(pubFilePath):
            overwrite = cmds.confirmDialog(
                title="Overwrite Confirmation",
                message=
                "A publish FBX already exists for this file.\nShould we overwrite?",
                button=("Overwrite", "Cancel"),
                defaultButton="Overwrite",
                cancelButton="Cancel",
                dismissString="Cancel")

            if overwrite == "Cancel":
                print "Publish skipped for FBX file (.fbx) called {0}".format(
                    pubFilePath)
                return (True)

        # else:
        print "===== anim publish:\n- saving {0}".format(pubFilePath + ".mb")
        cmds.file(pubFilePath + ".mb", es=True, f=True, type="mayaBinary")

    return (True)