層堆疊選擇

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(stack: Stack) -> List[LayerNode |GroupLayerNode |PaintLayerNode |InstanceLayerNode |FillLayerNode |GeneratorEffectNode |PaintEffectNode |FillEffectNode |LevelsEffectNode |CompareMaskEffectNode |FilterEffectNode |ColorSelectionEffectNode |AnchorPointEffectNode] substance_painter.layerstack.get_selected_nodes

取得堆疊中選定的節點,順序排列得像層堆疊一樣。

參數:​stack (Stack) – 從 Stack 查詢。

返回: 堆疊中被選中的節點。

回傳類型: ListLayerNode *|* GroupLayerNode *|* PaintLayerNode *|* InstanceLayerNode *|* FillLayerNode *|* GeneratorEffectNode *|* PaintEffectNode *|* FillEffectNode *|* LevelsEffectNode *|* 比較遮罩效果節點​*|* FilterEffectNode *|[***ColorSelectionEffectNode | AnchorPointEffectNode]

substance_painter.layerstack.get_selection_type(layer: LayerNode) -> SelectionType substance_painter.layerstack.get_selection_type

回傳選取圖層的哪部分(內容、遮罩等)。

參數:​ 層( ​LayerNode)– 從層查詢。

Raises:​ValueError – 如果該圖層不屬於目前選取的材質集。

返回: 被選取的圖層部分。

回傳類型:​SelectionType

組合選擇

substance_painter.layerstack.set_selected_nodes(節點:List[GeneratorEffectNode |PaintEffectNode |FillEffectNode |LevelsEffectNode |CompareMaskEffectNode |FilterEffectNode |ColorSelectionEffectNode |AnchorPointEffectNode] |List[LayerNode]) substance_painter.layerstack.set_selected_nodes

在層堆疊介面中選擇指定的節點。

Pararm 節點: 選擇節點。

加薪:

  • ValueError – 如果節點不屬於目前選取的材質集。
  • RuntimeError – 若從某 ScopedModification 個區段呼叫

參數:​節點(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

選擇你想選擇的圖層區域。

參數:

  • 層 (LayerNode)– 選擇圖層。
  • layer_selection_type (SelectionType) – 你想選取的圖層部分(內容、遮罩等)。

加薪:

  • ValueError – 如果該圖層不屬於目前選取的材質集。
  • RuntimeError – 若從某 ScopedModification 個區段呼叫

枚舉

class 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