CODE Request: Node.users() – Get All Clone Layers which are USING the active layer

As both an artist and addon developer, I’m requesting a small but essential addition to the Krita Python API.

To improve what developers can do with non-destructive layer/file structure and interchange solutions; as well as for using Krita in more professional VFX pipelines. - This one API hook will unlock a lot of possibilities:

Node.users() – return a list of all CloneLayer nodes that reference this node as their source.


Why This Matters

Currently, you can call clone.sourceNode() to find what a clone points to — but you cannot ask the source what is cloning it. That means:

  • Artists can’t safely delete or modify a layer without risking breaking dependent clones.
  • Developers have to manually scan the entire layer tree, checking every node to see if it’s a clone and if it matches a given source.
  • Complex scenes with clone hierarchies are hard to reverse engineer (e.g., for export, asset cleanup, or prefab detection).

Real Problems This Solves

  • :magnifying_glass_tilted_left: Find all instances of a reused object in a scene.
  • :broom: Clean up unreferenced sources or detect risky deletions.
  • :gear: Speed up exporters or plugins by avoiding full document scans.
  • :brain: Understand how a file is structured, especially when dealing with templates, prefabs, or multi-scene illustrations.

Performance & Practicality

For larger Krita files, especially production-ready ones, iterating all nodes just to find clone dependencies is:

  • Inefficient (cost grows with document complexity)
  • Redundant (Krita already tracks this internally)
  • Error-prone (clone links can be broken, silent, or deferred)

Adding a simple users() method or signal would drastically reduce script overhead and let tooling be more intelligent — immediately.


Proposal Summary

Add:

python

clone_list = source_node.users()  # returns all clone layers pointing to this node

Would make both artist workflows and plugin development faster, safer, and more intuitive.

Thanks for considering!

—Simon

1 Like

Method for finding out clones of node, would be nice addition.

Here is my utility script for finding clones of node.

from krita import Krita


def find_clones(source_document, source_node):
    """
    Notes:
    - source_document is needed, as Node has no method for getting owning Document.
    - Node.findChildNodes() returns nodes as instances of Node,
      and NOT as instance of correct subclass.  (also keyword arguments are broken?)
    """
    source_root = source_document.rootNode()
    for clone in source_root.findChildNodes(None, True, False, 'clonelayer'):
        if clone.sourceNode().uniqueId() == source_node.uniqueId():
            yield clone


# testing
app = Krita.instance()
doc = app.activeDocument()
root = doc.rootNode()

for node in root.findChildNodes(None, True):
    clone_names = ", ".join(c.name() for c in find_clones(doc, node))
    print(f'node name = {node.name()}, clone names = {clone_names}')

/AkiR

3 Likes