![]() Registered Member ![]()
|
Good day everyone,
I am having a problem adding a transparency mask node to a paint layer. Here's my code sample:
The script runs fine up to the point where the script adds the 'paintLayer2' to the document. So in the end, we'll end up with, from top to bottom, 'paintLayer2', 'groupLayer1' with a child node 'paintLayer1', and then a 'Layer 1'. But if we were to remove the comment on the last line to add a transparency mask to our 'paintLayer2':
Krita will freeze up until we close the program down. Interestingly, if we do:
the output is: groupLayer1 effect Don't really know what's going on, can you guys help me? |
![]() Registered Member ![]()
|
I don't really know why it is crashing with that. I am not sure if it is a bug...or if there is another way you are supposed to be adding transparency layers. I simplified your script a bit and it still seems to crash
from krita import * doc = Krita.instance().activeDocument() root = doc.rootNode() newNode1 = doc.createNode('custom named layer', 'paintLayer') root.addChildNode(newNode1, None) newNode4 = doc.createNode('transparencyMask1', 'transparencyMask') # this line crashes things newNode1.addChildNode(newNode4, None) |
![]() Registered Member ![]()
|
Thank you very much for taking the time to look at this. That last line of code is really crashing things, really hard to understand why tho. What really mystifies me to no end is when running: newNode4.name() it returns 'effect' as a name instead of 'transparencyMask1', I think it is referencing a hidden node that's named 'effect' and is causing krita to crash as we attach the new node as a child. Really don't know if it's because I am using the transparency mask wrong or it's a bug. Also I am trying an alternative way:
but I can't seem to find the right action parameter for transparency mask in order for the last line to work. |
![]() Registered Member ![]()
|
You could try this...
Krita.instance().action('add_new_transparency_mask').trigger() I am not sure exactly how to find that ID in Python, but I know Krita stores most of its actions in .action files. If you search your krita installation or source code files you should see them all being defined. |
![]() Registered Member ![]()
|
Thanks a lot. I Did a google search for: list of Krita Actions "select_opaque" and found myself here: https://phabricator.kde.org/file/data/z ... dpmch/file Went to the ' <ActionCollection version="2" name="Krita">' section and found myself the treasures I've been looking for. It seems that the text() property just returns the textual content of the action based on the menus and what I am looking for is the name. Just collected the names and put it in a text file for safe keeping. Wish there was a print(action.name()) tho, so I can easily pull out a list anytime. |
![]() Registered Member ![]()
|
After doing a bit more playing around...it looks like you can access those names from Python. This is probably going to be a better approach then people scraping all those .action files.
|
![]() Registered Member ![]()
|
wow, this is way cooler, thanks a lot. |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]