[Wish] "Quick Clipping Group" feature, better auto-naming

Hi!
Recently, I started to experiment with splitting my artwork into silhouettes. I put them on separate layers, from the scratch, or more exactly just after the sketch is done. It has advantages: I can preserve firm edges for silhouettes while painting and it also has advantages to fine-tune shading and compositing of each element later on in the process.

And so, I’m using Quick Clipping Group a lot, but I’m spending a lot of time just renaming my layer stack. That’s why I wish it was possible to get better auto-naming out of the box to speed up my process.

Initial situation

I paint the silhouette and name the layer.


Initial situation: illustration.

The problem

I select each layer and press the Ctrl+Shift+G shortcut to start Clipping Groups (or right click on the layer in Layer Stack Docker → Group → Quick Clipping Group). The problem here is the naming of the result: I have now plenty of Clipping Group1, 2, 3 etc… as top-level groups (see picture under). Also, the clipping base is named after the original layer name.

My layer stack is now hard to read and, I have to rename all my groups manually, and clipping base as well. It is a lot of duplicate effort. It’s almost OK to do it manually on a picture like that with only 6 groups. But after doing the 4th picture this way, I start to be tired of this step. I also can’t imagine going through this process on a larger project (eg. a comic episode with many pages/panels).


The problem: this naming convention is not useful.

The wish

I wish the Clipping Group could inherit directly the name of the target layer. I also wish the “Clipping base” of the group to be named “Clipping base - <NameOfTheLayer>”.

Here is how it looks when I rename all manually. Really easier to work this way :smiling_face:


My layer stack manually renamed, I wish Ctrl+Shift+G could do that, out of the box.

Notes:

I inspired my “Clipping base - <NameOfTheLayer>” naming convention from @tiar 's screenshot here. And thanks to @freyalupen who solved my other wish about optional renaming “merged” suffix, merging top level Clipping Group (eg. “Dragon”) don’t auto end up anymore into “Dragon Merged”.

Definitely would use and appreciate this, as someone who is not good about naming their layers but wants to improve and get organized. I use hot keys on my tablet, so reaching for my keyboard to have to type new names is kind of a problem (particularly when on laptop, since my tablet lays over my keyboard entirely).

1 Like

Some thoughts on this:

What would happen in the case that a quick clipping group is made containing more than one layer? Implementation-wise it seems that inheriting the name of first selected layer (that is, first one clicked on) may be easier than from, say, the bottom layer.

Is this something that could be done with a script, one that could assign a hotkey to make a quick clipping group and rename the layers accordingly? (I don’t know whether it’s possible.)

And a technical question, is there a way to have layer renames as part of the “Quick Clipping Group” undo command? (In my investigation I’ve only gotten as far as using node->setName which isn’t even undoable at all.)

(Edit)
To answer my question of whether it’s doable with a script; running this in the Scripter will add renaming to the Quick Clipping Group action. It has the aforementioned issue of the renames not being undoable.

def rename():
    maskLayer = Krita.activeDocument().activeNode()
    clipGroup = maskLayer.parentNode()
    clipBases = clipGroup.childNodes()
    del clipBases[-1]
    inheritedName = clipBases[0].name()
    clipGroup.setName(inheritedName)
    for layer in clipBases:
        layer.setName("Clipping Base - "+layer.name())

Krita.action("create_quick_clipping_group").triggered.connect(rename)
2 Likes

@starsworne Ha yes, it might help users of Krita on mobile and pen displays. Thanks for the input.

@freyalupen

I checked what Krita does now, and it sounds like all layers selected are joining the Clipping Group.

I’m not sure about renaming all of them with a "clipping base - " prefix. I really plan to use Clipping Group on a single Paint Layer so for me, it’s ok, but for an eventual other user, I don’t know.

I understand if other want to use that on multiple shapes (Clipping Base) and use other later type (eg. vector). I’m open to ideas, very interesting question. I saw your script has a loop:

for layer in clipBases:
        layer.setName("Clipping Base - "+layer.name())

So, I’ll see when I’ll experiment with it. :+1:

That can work for me, yes.

I have zero skill with Python script, but it sounds like a good idea. Thank you very much for your script. I’ll play with it. I sort of can read the logic of it. Very interesting to see you can influence the behavior of the feature this way. Thanks for posting it.

@Deevad I like the idea!
Are you also proposing that you select the layers you want to have as quick clipping group and that a clipping group is created for each separately? So that each group contains only a base layer and the clip layer on top? That might also help you save time.

Hi @Hologram , thanks. Yes, for my specific case it might help, but I prefer the design where ‘every layers/groups selected ends into a clipping base for a single clipping group’.

On my side, going threw the stack and pressing Ctrl+Shift+G to ‘quick clipping group’ is not much effort. And I always prefer the modularity of a design instead of too much automatism.

Right now my main personal question I evaluate is, in case of multiple groups/layers selected, if they should just join a new created group named ‘clipping base’, and of course, placed at the root of the ‘quick clipping group’. This way, the group conserve only one node at the bottom (a group) and the layers/groups inside preserve their name.

I mean, there could be an automated option alongside the current one if that helps (and I’m sure it does). :wink:

And then also the rest of your proposal, which I very much agree with.

(Update 11 month later)

Thanks to Freyalupen option to disable the “merged” name suffix while merging a group (landed in 5.2 beta) and a Python script I share under, it is now possible for me to play with the Quick-Clipping-Group action I wanted to speed-up my workflow.

I put it here not as a solution to this ‘wish’ request, but as a proof-of-concept/workaround of what the behavior of ‘Quick-Clipping-Group’ should be, imo, to compete a little bit more with other software’s Clipping Mask in terms of fluidity of workflow and amount of click to perform a task.

To test, here is what you need to setup:

  1. Go to Settings > General > Misc (uncheck all Automatic Suffix options)
  2. Save the code under in a empty text file named quick-clipping-group.py, give it execution permissions.
  3. In “Ten Scripts” ( Tool > Script > Ten Scripts), bind the script to a keyboard shortcut (I replaced my “Ctrl+Shift+G” here).
"""
    @File    : quick-clipping-group.py
    @Desc    : Create a new group named after the selected layer, encapsule the layer, and create a
               new paint layer on the top with inherit alpha.
    @Usage   : Save this script somewhere on your disk. Give the file execution permissions. Use the
               "ten scripts" plugin of Krita (built-in) to associate the script execution to a
               key. ( Tool > Script > Ten Scripts)
               Note: this script is meant for usage with setting in General > Misc (no Automatic Suffix, uncheck all).
    @Version : 1.0
    @Author  : David Revoy
    @Links   : https://www.davidrevoy.com/
    @Date    : September 2023
    @License : GPL v.3
               Copyright (C) 2023, David Revoy
               This program is free software: you can redistribute it and/or modify
               it under the terms of the GNU General Public License as published by
               the Free Software Foundation, either version 3 of the License, or
               (at your option) any later version.
               This program is distributed in the hope that it will be useful,
               but WITHOUT ANY WARRANTY; without even the implied warranty of
               MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
               GNU General Public License for more details. A full copy of the 
               license is here: https://www.gnu.org/licenses/gpl-3.0.html
    @Credits : Inspiration from a thread made by Bhit[1], and help from Freyalupen[2] thanks!
    [1] https://krita-artists.org/t/setactivenode-does-not-change-active-node/47753
    [2] https://krita-artists.org/t/wish-quick-clipping-group-feature-better-auto-naming/50436/3?u=deevad
"""

from krita import *

inst = Krita.instance()
doc = inst.activeDocument()
currentLayer = doc.activeNode()
TargetName = currentLayer.name()
currentLayer.setName("clipping base - "+TargetName)

group = doc.createGroupLayer(TargetName)
currentLayer.parentNode().addChildNode(group, currentLayer)

nodes = [currentLayer.clone()]

for node in nodes:
   group.addChildNode(node, None)

currentLayer.remove()

newLayer = doc.createNode("layer", "paintLayer")
group.addChildNode(newLayer, None)
doc.waitForDone()
newLayer.setInheritAlpha(1)

Usage:

  1. Paint silhouettes or grounds on layers, name the layers (eg. characters, foreground, clouds, etc).
  2. Clip them on demand with the tool above: the group will preserve their name.
  3. When your edit/painting is done, you can merge the group with Ctrl+E; the name will be preserved.

The advantage here is being able to make as many step (2) <> (3) as desired while keeping a layer stack clean and named, even when managing over 10 clipping groups.

2 Likes

Demo:

Very fluid :star_struck:

5 Likes