Layerstack selection
The layerstack module allows the selection of layers and effects.
Examples
Specific channel activation
# This example shows how to activate specific channels on selected nodes in the layerstack.
# Before running this example, open a project and select some layers/effects from the UI
import substance_painter as sp
# Get the active stack
stack = sp.textureset.get_active_stack()
# Get the selected nodes in the layerstack
selected_nodes = sp.layerstack.get_selected_nodes(stack)
updated_nodes = []
# Iterate over the selected nodes
for node in selected_nodes:
if type(node) is sp.layerstack.FillLayerNode or type(node) is sp.layerstack.FillEffectNode:
# Set the active channels of the Fill to BaseColor
node.active_channels = {sp.layerstack.ChannelType.BaseColor}
updated_nodes.append(node)
# Select the edited nodes
sp.layerstack.set_selected_nodes(updated_nodes)
Get selection
substance_painter.layerstack.get_selected_nodes(stack: Stack) -> List[LayerNode | GroupLayerNode | PaintLayerNode | InstanceLayerNode | FillLayerNode | GeneratorEffectNode | PaintEffectNode | FillEffectNode | LevelsEffectNode | CompareMaskEffectNode | FilterEffectNode | ColorSelectionEffectNode | AnchorPointEffectNode] substance_painter.layerstack.get_selected_nodes
Get the selected nodes of a Stack, ordered like in the layer stack.
Parameters: stack (Stack) – Stack to query.
Returns: The selected nodes of the stack.
Return type: List[LayerNode | GroupLayerNode | PaintLayerNode | InstanceLayerNode | FillLayerNode | GeneratorEffectNode | PaintEffectNode | FillEffectNode | LevelsEffectNode | CompareMaskEffectNode | FilterEffectNode | ColorSelectionEffectNode | AnchorPointEffectNode]
substance_painter.layerstack.get_selection_type(layer: LayerNode) -> SelectionType substance_painter.layerstack.get_selection_type
Return which part of a layer is selected (content, mask, etc…).
Parameters: layer (LayerNode) – Layer to query.
Raises: ValueError – If the layer doesn’t belong to the currently selected texture set.
Returns: The part of the layer that is selected.
Return type: SelectionType
Set selection
substance_painter.layerstack.set_selected_nodes(nodes: List[GeneratorEffectNode | PaintEffectNode | FillEffectNode | LevelsEffectNode | CompareMaskEffectNode | FilterEffectNode | ColorSelectionEffectNode | AnchorPointEffectNode] | List[LayerNode]) substance_painter.layerstack.set_selected_nodes
Select the given nodes in the layer stack UI.
Pararm nodes: Nodes to select.
Raises:
- ValueError – If the nodes doesn’t belong to the currently selected texture set.
- RuntimeError – If called from a
ScopedModificationsection
Parameters: nodes (List*[GeneratorEffectNode* | PaintEffectNode | FillEffectNode | LevelsEffectNode | CompareMaskEffectNode | FilterEffectNode | ColorSelectionEffectNode | *AnchorPointEffectNode]* | List*[LayerNode]*)
substance_painter.layerstack.set_selection_type(layer: LayerNode, layer_selection_type: SelectionType) substance_painter.layerstack.set_selection_type
Select which part of the layer you want to select.
Parameters:
- layer (LayerNode) – Layer to select.
- layer_selection_type (SelectionType) – Part of the layer you want to select (content, mask, etc…).
Raises:
- ValueError – If the layer doesn’t belong to the currently selected texture set.
- RuntimeError – If called from a
ScopedModificationsection
Enums
class substance_painter.layerstack.SelectionType(value) substance_painter.layerstack.SelectionType
Members:
ContentMaskGeometryMaskProperties