Skip to content
On this page

Getting started - Scripting

Simplygon will start the optimization once the Simplygon command is executed in combination with a Pipeline object or a Pipeline file-path. Execute either the MEL- or Python version of the script by pressing the double-arrow in the script windows's menu-bar to start the processing, the optimized scene will be returned to Maya automatically once the processing has completed.

MEL script

MEL
// select objects in scene
select -all;

// create a reduction Pipeline using the SimplygonPipeline command
$reductionPipeline = `SimplygonPipeline -c "ReductionPipeline"`;

// set the reduction Pipeline's triangle ratio to 50%
$bResult = `SimplygonPipeline -ss "ReductionProcessor/ReductionSettings/ReductionTargetTriangleRatio" -v 0.5 $reductionPipeline`;

// execute Simplygon with the given Pipeline
Simplygon -so $reductionPipeline;

// clear all loaded / created Pipelines
SimplygonPipeline -cl;

Maya script window - MEL

Run Simplygon through MEL-script.
Run Simplygon through MEL-script.

Python script

Python
import maya.cmds as cmds

# select objects in scene
cmds.select(all = True)

# create a reduction Pipeline using the SimplygonPipeline command
reductionPipeline = cmds.SimplygonPipeline(c = 'ReductionPipeline')

# set the reduction Pipeline's triangle ratio to 50%
bResult = cmds.SimplygonPipeline(reductionPipeline, ss = 'ReductionProcessor/ReductionSettings/ReductionTargetTriangleRatio', v = 0.5)

# execute Simplygon with the given Pipeline
cmds.Simplygon(so = reductionPipeline)

# clear all loaded / created Pipelines
cmds.SimplygonPipeline(cl = True)

Maya script window - Python

Run Simplygon through Python-script.
Run Simplygon through Python-script.

Accessing Simplygon UI

The Simplygon UI exposes a set of functions that can be accessed through script.

Function table:

FunctionArgumentDescription
LoadPipelineFromFilestring filePathLoads specified pipeline into Simplygon UI
SavePipelineToFilestring filePathSaves pipeline loaded in the Simplygon UI to specified file

Script examples:

MEL
// load pipeline
SimplygonUI -LoadPipelineFromFile "D:/Pipelines/ReductionPipeline.json";

// save pipeline
SimplygonUI -SavePipelineToFile "D:/Pipelines/ReductionPipeline_Copy.json";
Python
import maya.cmds as cmds

# load pipeline
cmds.SimplygonUI(LoadPipelineFromFile='D:/Pipelines/ReductionPipeline.json')

# save pipeline
cmds.SimplygonUI(SavePipelineToFile='D:/Pipelines/ReductionPipeline_Copy.json')

IMPORTANT NOTE - Scripting and UI modules

The Simplygon Maya scripting - and UI modules are separate plug-ins. The scripting module encapsulates the import and export logic as well as scripting capabilities. The UI module is a separate layer that communicates with the scripting layer. Communication between these modules require both modules to be loaded.

Dependencies:

  • The scripting module can be used without other dependencies (through script functions)
  • The UI module must be used in combination with the scripting module

Next steps

Get to know how to use the Simplygon Maya plug-in: