图层栈叠选择
layerstack模块允许选择图层和效果。
示例
特定渠道激活
# 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)
获取选区
substance_painter.layerstack.get_selected_nodes(堆叠:堆叠) -> List[LayerNode | GroupLayerNode | PaintLayerNode | InstanceLayerNode | FillLayerNode | GeneratorEffectNode | PaintEffectNode | FillEffectNode | LevelsEffectNode | CompareMaskEffectNode | FilterEffectNode | ColorSelectionEffectNode | AnchorPointEffectNode] substance_painter.layerstack.get_selected_nodes
获取堆叠的选定节点,在图层堆叠中按顺序排列。
参数: 堆叠 (堆叠) — 查询堆叠。
返回:堆叠的选定节点。
返回类型: 列表[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
返回选择的图层部分(内容、蒙版等……)。
参数: 图层 (LayerNode) — 要查询的图层。
引发: ValueError — 如果图层不属于当前所选纹理集。
返回:所选图层的部分。
返回类型: SelectionType
设置选区
substance_painter.layerstack.set_selected_nodes(nodes: List[GeneratorEffectNode | PaintEffectNode | FillEffectNode | LevelsEffectNode | CompareMaskEffectNode | FilterEffectNode | ColorSelectionEffectNode | AnchorPointEffectNode] |列表[LayerNode]) substance_painter.layerstack.set_selected_nodes
在图层堆叠UI中选择给定节点。
Pararm节点:要选择的节点。
引发:
- ValueError — 如果节点不属于当前选定的纹理集。
- RuntimeError — 如果从
ScopedModification节调用
参数: 节点 (列表**[GeneratorEffectNode | PaintEffectNode | FillEffectNode | LevelsEffectNode | CompareMaskEffectNode | FilterEffectNode | ColorSelectionEffectNode | *AnchorPointEffectNode *] | 列表*[*LayerNode *]*)
substance_painter.layerstack.set_selection_type(layer: LayerNode, layer_selection_type: SelectionType) substance_painter.layerstack.set_selection_type
选择要选择的图层部分。
参数:
- 图层 (LayerNode) — 要选择的图层。
- layer_selection_type (SelectionType) — 要选择的图层的一部分(内容、蒙版等)。
引发:
- ValueError — 如果图层不属于当前所选纹理集。
- RuntimeError — 如果从
ScopedModification节调用
枚举
类substance_painter.layerstack.SelectionType(value) substance_painter.layerstack.SelectionType
成员:
名称
描述
Content选择图层内容。
Mask选择图层蒙版。
GeometryMask选择图层几何蒙版。
Properties选择图层属性。 仅适用于实例。
NOTE
用于定义成员的名称可通过.name属性以字符串形式提供(请参见python enum.Enum)。
recommendation-more-help
substance-3d-dev-help-painter-python-guide