Customize Usd Export Settings (Maya)

Customize Usd Export Settings (Maya)#

This example plugin modifies the USD export command in Maya to set export settings, which are not exposed in the GUI.

See the section for Single File Plugins on how to load this example.

# CustomizeUsdExportSettings.py

name = "CustomizeUsdExportSettings"
classname = "CustomizeUsdExportSettings"


class CustomizeUsdExportSettings:
    def __init__(self, core):
        self.core = core
        self.version = "v1.0.0"

        self.core.registerCallback("preMayaUSDExport", self.preMayaUSDExport, plugin=self)

    def preMayaUSDExport(self, origin, options, outputPath):
        newVal = "exportComponentTags=0"
        if "exportComponentTags" in options:
            idx = options.find("exportComponentTags")
            rplStr = options[idx:idx+len("exportComponentTags")+2]
            options = options.replace(rplStr, newVal)
        else:
            options += newVal + ";"

        return {"options": options}