Save USD stage

# The following is a scripting example of how to save a USD stage.
import ufe
import mayaUsd_createStageWithNewLayer
import mayaUsd.lib as mayaUsdLib

# Create a new stage and add a material.
stagePathString = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()
stageItem = ufe.Hierarchy.createItem(ufe.PathString.path(stagePathString))
ufe.ContextOps.contextOps(stageItem).doOp(['Add New Prim', 'Material'])

# Use the MayaUSD API to save the stage.
filepath = 'C:/dev/temp/some/path/to/usdFile.usda'
usdStage = mayaUsdLib.GetPrim(stagePathString).GetStage()
usdStage.GetRootLayer().Export(filepath)

print(f'Saved "{ufe.PathString.string(stageItem.path())}" to "{filepath}"')