# 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.

// 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.

# Accessing Simplygon UI

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

Function table:

Function Argument Description
LoadPipelineFromFile string filePath Loads specified pipeline into Simplygon UI
SavePipelineToFile string filePath Saves pipeline loaded in the Simplygon UI to specified file

Script examples:

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

// save pipeline
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: