Search code examples
pythonmayamel

Merge UV changes from .fbx file back into Maya


I am trying to export a FBX model from Maya, modify some of the UVs externally, and then reimporting it back to Maya, replacing just the portions that have been changed.

To export:

cmds.file(myFile, type='FBX', exportSelected=True, lf=False, f=True)

To import:

cmds.file(myFile, i=True, type='FBX', ra=True, mnc=True, pr=True, lf=False, f=True)

However, after running the commands, nothing changed within the scene. How do I merge and overwrite the current scene with the new changes?


Solution

  • Instead of this:

    import maya.cmds as cmds
    
    cmds.file(myFile, typ='FBX', es=True, lf=False, f=True)
    

    Your options need to be passed via MEL evals if you’re using Python:

    import maya.mel as mel
    
    mel.eval('FBXResetExport; 
              FBXExportInputConnections -v false; 
              FBXExportBakeComplexAnimation -v true; 
              FBXExportLights -v false; 
              FBXExportCameras -v false; 
              FBXExportInAscii -v true; 
              FBXExportFileVersion FBX201200; 
              FBXExportSmoothingGroups -v false; 
              FBXExportSmoothMesh -v false; 
              FBXExportApplyConstantKeyReducer -v false; 
              FBXExportBakeComplexAnimation -v true;  
              FBXExportBakeComplexStep -v 1;  
              FBXExportCameras -v false;’
            )
    

    P.S. This is an example how your code might look like.