This page describes the main concepts of the API.
For more detailed information please refer to the documentation shipped with Substance Designer that is accessible in the 'Help > Python API Documentation...' menu. In this documentation, do a Quick Search for the module names (in parentheses below) to easily find their definition.
The context (Context) object is the main entry point to the API. It is created the first time the user get it by using the method 'getContext()' from the 'sd' module.
This object allows to essentially retrieve the application (SDApplication) object.
The application (SDApplication) is the object that allows access to the main API managers such as:
- the Package Manager (SDPackageMgr) that manages all of the application's packages;
- the Module Manager (SDModuleMgr) that manages all of the application's modules;
- the UI Manager (SDUIMgr) that can create menus and docks in the application's window.
You can register callbacks with the application that will be called when certain events happen.
Package Manager (SDPackageMgr)
This object manages all the application's packages. In Substance Designer the packages are displayed in the 'Explorer' component.
It allows you to:
- create a new package;
- load/unload a package;
- save a package;
- find a package.
A package (SDPackage) is a collection of resources (SDResource).
The content of a package can be stored to a file with the .sbs extension through the 'SDPackageMgr' object. This object allows you to retrieve specific resources.
To create a specific resource, see the related object static methods (Ex: 'SDSBSCompGraph.sNew()').
A package also contains a metadata dictionary (). You can find more info on metadatas here.
A resource (SDResource) is an object that can be referenced by another resource.
There are multiple resource types:
- Folders (SDResourceFolder);
- Graphs (SDGraph);
- Bitmaps (SDResourceBitmap);
- SVG Images (SDResourceSVG);
- Fonts (SDResourceFont);
- Scenes (SDResourceScene);
- BSDF Measurements (SDResourceBSDFMeasurement);
- Light Profiles (SDResourceLightProfile).
A resource can be created from static method 'sNew()' under:
- a package;
- a folder.
A resource can have several properties (SDProperty).
UI Manager (SDUIMgr)
The UI manager allows creating user interface elements in Substance Designer's main window, such as menus, docks and allows registering callbacks to be called when user interface related events happen.
Additionally, the UI manager has access to the current active graph and the selection of the active graph.
A graph (SDGraph) is an object that contains:
There are 4 different graph types:
- Substance compositing graph (SDSBSCompGraph)
- Substance function graph (SDSBSFunctionGraph)
- Substance FXMap graph (SDSBSFxMapGraph)
- MDL graph (SDMDLGraph)
A graph can have one or multiple output nodes. The output nodes represent the results of the graph.
All the available nodes for a graph can be retrieved with the method 'getNodeDefinitions()'.
A new node can be created with the method 'newNode()'.
A new instance node can be created from a resource (SDResource) with the method 'newInstanceNode()'.
A node (SDNode) represents an operation carried out on an object.
It can be created from:
- a definition (SDDefinition) (see 'SDGraph.newNode()');
- a resource (SDResource) (see 'SDGraph.newInstanceNode()').
A node can have multiple properties.
There are multiple types of node:
- SDSBSCompNode: A node of the Substance Compositing Graph (SDSBSCompGraph);
- SDSBSFunctionNode: A node of the Substance Function Graph (SDSBSFunctionGraph);
- SDSBSFxMapNode: A node of the Substance FXMap Graph (SDSBSFxMapGraph);
- SDMDLNode: A node of the MDL Graph (SDMDLGraph). Note: Many other specific nodes inherit from this node.
Graph Objects (SDGraphObjects)
A graph object (SDGraphObject) is an object that adds additional information to the graph, but that is not taken into account during the graph evaluation process.
There are 3 types of graph objects:
- Pin (SDGraphObjectPin)
- Comment (SDGraphObjectComment)
- Frame (SDGraphObjectFrame)
See the static method 'sNew()' on these objects for more information regarding how to create them.
A property (SDProperty) is an object that describes a property of another object (a graph, a node, a resource, and so on).
It belongs to a specific category (SDPropertyCategory):
- Input: classifies an object's input properties, which usually impact the operation carried out by the current object;
- Ex: the property 'color' of a Uniform Color node in a Substance compositing graph is an input property;
- Output: classifies an object's output properties. It is used to identify a result of an object;
- Annotation: classifies properties that do not impact the operation carried out by an object;
- Ex: the 'label' of a graph is an annotation property, because it does not impact the graph computation.
It contains the following members:
- Id: The identifier of the property in the context of his category;
- Types: The types supported by the current property. Some properties can support multiple types: 'int', 'float', etc.;
- Ex: the input properties of an 'sbs::function::add' node can support different types: 'int', 'int2', 'int3', 'int4', 'float', 'float2', 'float3', 'float4', etc.;
- Category: The category the property belongs to (input, output, annotation);
- Label: The label of the property, used for display only;
- Description: The description of the property;
- DefaultValue: The default value;
- IsConnectable: Indicates if a connection (SDConnection) can be carried out on this property;
- isReadyOnly: Indicates if the property is read-only. If true, the value associated to it will not be modifiable;
- isVariadic: If true, this property will be represented as multiple properties on the object;
- isPrimary: Indicates whether the specified property is the principal property that controls some other properties. Note: this is specific to Substance Compositing Nodes (SDSBSCompNode)).
- Properties of the 'sbs::compositing::input' node:
- Properties of the 'sbs::compositing::blend' node:
A type (SDType) contains information of a value type, such as:
- Id: The identifier of the type;
- Modifier: The type modifier that can be one of the 'SDTypeModifier' enum values:
- Uniform: The value is evaluated once per operation;
- Varying: The value is evaluated multiple times per operation (ex: for each texel).
Multiple types are defined, such as:
- enums (SDTypeEnum): describes an enumeration type with all its properties;
- structures (SDTypeStruct): describes a structure type with all its properties;
- array (SDTypeArray): describes an array.
See Substance Designer's Python API Documentation for the exhaustive list.
A value (SDValue) is an object that encapsulates a base type value.
- a 'SDValueInt' object encapsulates an 'int' value;
- a 'SDValueFloat4' object encapsulates a 'float4' value;
The base type value can usually be retrieved with the 'get()' method, but this can depend on the type of 'SDValue' that has been returned.
A connection (SDConnection) represents a link between two different properties of two different nodes.
- The target node;
- The target property of the target node;
All connection operations are carried out on a node:
- creating a new connection, see 'SDNode.newPropertyConnection()'
- deleting an existing connection, see 'SDNode.deletePropertyConnection()'
- retrieving the connections of a property, see 'SDNode.getPropertyConnections()'
A module is a collection of definitions and types.
It allows easy retrieval of all the information on the nodes that can be created, as well as on enumerations and structures.
- an identifier (Id) that is unique in the context of the module manager (SDModuleMgr);
- a list of definitions (SDDefinition);
- a list of types (SDType).
A definition (SDDefinition) object contains information on the definition of a particular object based on properties ('SDNode', etc.).
- Id: the identifier of the definition;
- Label: The label of the definition;
- Description: The description of the definition;
- Properties: The properties of all the available property categories (SDPropertyCategory).