Skip to content
On this page

Getting started - Scripting

Using Blenders Scripting workspace you can use the Simplygon python API to run your own custom processings.

The easiest way is to use Blenders glTF exporter to export the parts of the scene you want to process, feed those to a Simplygon pipeline object to process, and then import it back.

Launch Simplygon UI.
Launch Simplygon UI.

For a more detailed overview of the Simplygon python API, check the Simplygon API documentation.

Here's an example script that can be run to reduce the selected meshes by 50%.

python
import os
import bpy
from simplygon10 import simplygon_loader
from simplygon10 import Simplygon

def reduce_selection(sg, ratio):
    file_path = 'c:/tmp/_intermediate.glb'
    bpy.ops.export_scene.gltf(filepath = file_path, use_selection=True)
    pipeline = sg.CreateReductionPipeline()
    pipeline.GetReductionSettings().SetReductionTargetTriangleRatio(ratio)
    pipeline.RunSceneFromFile(file_path, file_path, Simplygon.EPipelineRunMode_RunInThisProcess) 
    bpy.ops.import_scene.gltf(filepath=file_path)
    os.remove(file_path)
    
    
sg = simplygon_loader.init_simplygon()
reduce_selection(sg, 0.5)
sg = None