Creating paint layers inside groups

I’d like to run this code (or code like it) in the plugin I’m making:

Krita.instance().action(‘add_new_paint_layer’).trigger()

When I run this as a script (i.e. through the scripter), I have no issues.
However, when I use this code in my plugin, and if the active node is a grouplayer, this code doesn’t work.

I found the exact same thing happen for this workaround I was trying:

application = Krita.instance()
currentDoc = application.activeDocument()
currentLayer = currentDoc.activeNode()
if currentLayer.type() == “grouplayer”:
currentLayer.setName(“I’m a groupy boi”)
else:
currentLayer.setName(“ew I’m not a group ew noo”)

When this code was running as a script, it all worked exactly as intended. However when it was in my plugin, and the active node was a group layer, the “if” part of the statement didn’t trigger at all, although the “else” still worked perfectly fine. I tried switching it to != “grouplayer”, but still the group layers weren’t affected by my code, even though paint layers were fine.

This has made me very suspicious of me getting the “grouplayer” reference correct, but I checked the API like hella lots. Or maybe did I miss something that I needed to import something in one of the plugin files?

I updated Krita literally yesterday, so I’m having this problem on todays version.

Is there a reason for this, or is it a bug? And does anyone know how I would be able to create paint layers when the active node is a group layer?

Please check to see if the “activationFlags” and “activationConditions” in the plugin’s .action file is set to 0. If it is set to a number other than 0, the behavior will change depending on the specific layer type.

Reference:

1 Like

Oh wow thanks.
I had the “activationFlags” set to like 100000.
Thanks so much for the help :slight_smile:

2 Likes

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.