# Appendix

# Using the Maya Python interpreter

When executing Maya in batch mode via mayapy, make sure the Maya Python environment is initialized and the MultiverseForMaya plug-in is loaded before calling any Multiverse API function and doing any processing on the current scene:


# Initialize the Maya Python environment.
import maya.standalone
maya.standalone.initialize(name='python')

# Import the 'MultiverseForMaya' plug-in.
from maya import cmds
cmds.loadPlugin('MultiverseForMaya')

# Load a scene and export its content using 'multiverse' API.
cmds.file('/path/to/maya/scene/file', open=True, force=True)

import multiverse as mv
opts = mv.CompositionWriteOptions()
mv.WriteComposition(outputFile, 'scene', opts)

# Finally un-initialize the Maya Python environment.
maya.standalone.uninitialize()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Last Updated: 7/1/2020, 3:03:50 PM