Storeroom of scripts

This is a script that adds the specified layer to the selection. This allows you, for example, to add layers with the same color labels to the selection and make them the target of free transformations.
However, this may be useful in limited situations…

from krita import *

application = Krita.instance()
activeDoc = application.activeDocument()
activeNode = activeDoc.activeNode()

qwin = application.activeWindow().qwindow()
layerBox = qwin.findChild(QDockWidget, "KisLayerBox")
layerList = layerBox.findChild(QTreeView,"listLayers")

layerListSM = layerList.selectionModel()
selectList = layerListSM.selectedIndexes()

# input layer name into "X"
targetNode = activeDoc.nodeByName("X")

# activate the target node temporarily
activeDoc.setActiveNode(targetNode)
index = layerList.currentIndex()# QModelIndex
selectList.append(index)

# back to ActiveNode
activeDoc.setActiveNode(activeNode)

for target in selectList:
    layerListSM.select(target, QItemSelectionModel.Toggle)
    # layerListSM.select(target, QItemSelectionModel.Clear)
    # layerListSM.select(target, QItemSelectionModel.Select)
    # layerListSM.select(target, QItemSelectionModel.Deselect)
1 Like