Last updated on
May 24, 2023
- Substance 3D home
- Home
- Command Line Tools
- Command Line overview
- sbsbaker
- sbscooker
- sbsmtools
- sbsmutator
- sbsrender
- sbsupdater
- Command Line overview
- Pysbs - Python API
- Pysbs - Python API overview
- Getting started
- General topics
- Examples
- API Content
- API Content overview
- Substance definitions
- Common interfaces
- compnode
- context projectmgr
- graph
- mdl
- modelgraphindex
- modelannotationnames
- modelgraph
- modelgraphgenerator
- modelgraphimplementation
- modelnodenames
- modeloperand
- modulegraphindex
- moduleannotation
- moduleconnection
- modulegraph
- modulegraphgenerator
- modulegraphimplementation
- modulegraphlibrary
- modulegraphregister
- modulenode
- modulenodeimplementation
- modulenodeinstance
- moduleoperand
- moduleoutputbridging
- moduleparaminput
- params
- projectmgrdoc
- sbsarchive
- sbscommon
- sbspreset
- sbsproject
- substance
- Libraries
- sbsenum
- sbslibrary
- sbsbakerslibrary
- Helpers
- Execution context
- API Change log
- Samples
- Setup and Getting Started
- Integrations
- Substance Maya toolset
- Changelog overview
SAT Cookbook
The purpose of this page is to gather tips and best practices through several snippets and common pieces of code that do not necessarily have their place in the docstring.
It is intended to evolve over time.
Create a Dropdown graph input parameter
The encoding for the `WidgetOptionEnum.PARAMETERS` is a collection following those rules :
- 1st item is the integral value for the default value
- Follow a list a tuple
Exemple: `'1;0;Custom;1;Metallic Roughness;2;Specular Glossiness'`
NOTE: we use a compact string representation in the API to pass the collection
input_workflow_type = sbs_graph.addInputParameter( aIdentifier = 'workflow_type', aLabel = 'Workflow Type', aDescription = 'Define the workflow type', aUserData = 'workflow', aWidget = WidgetEnum.DROPDOWN_INT1, aOptions = { WidgetOptionEnum.PARAMETERS: "1;0;Custom;1;Metallic Roughness;2;Specular Glossiness" } )
Render sbs outputs for each preset of a specific instance node
# get instance node implementation from a compositing node instance_node = comp_node.getCompImplementation() # get the preset list from the graph referenced by the instance node presets = instance_node.mRefGraph().mPresets # each preset is apply, sbs file saved then cooked and then rendered for preset in presets: node.applyPreset(preset.mLabel) # save the doc doc.writeDoc(f"Substance_graph_{preset.mLabel}.sbs") # cook the sbs as sbsar, note use wait() to wait the end of process p = batchtools.sbscooker(f"Substance_graph_{preset.mLabel}.sbs", output_path=f"sbsar") p.wait() # render maps with sbsrender, note use wait() to wait the end of process p = batchtools.sbsrender_render(f"Substance_graph_{preset.mLabel}.sbsar", output_path=f"render") p.wait()