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<integral value, label>
    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()