I’m currently using the function createFileLayer to import file layers in a script, it works really well. It would be nice to have the same for reference sets (and maybe assistant sets) but I’m unable to find the proper function to do this. Is there a way to do it?, I already searched the API and action documentation for a relevant function and could not find any.
Hi, I believe the options to do it are currently limited.
In Krita master (not in the public 5.2.6 release yet), there’s a new action create_reference_image_from_active_layer (you can see it in hotkeys list), which can be used to do just what it says.
I believe you can invoke an action from Python, so you could perhaps automate it this way:
- load an image into a new layer, activate it
- invoke the action → create reference image from active layer
- delete the layer
- repeat
Not sure if it will work in practice though.
I already have the image sets created (krf files) I just want to find and open them. The script that I’m currently using for file layers just opens (adds ) them, but to do this I need to use the “createFileLayer” function, I was hoping for a similar function for reference sets.
Here is the script (it requires rg and rofi installed):
def import_file_layer():
app = Krita.instance()
d = app.activeDocument()
filelayer = os.popen("rg -L --files -i -g '*.kra' ~/data/i | rofi -show -dmenu -fuzzy").read().rstrip()
if filelayer:
n = d.createFileLayer("File Layer", filelayer, "None", "Bicubic")
r = d.rootNode();
c = r.childNodes();
r.addChildNode(n, c[0])
d.refreshProjection()
There’s no way to do anything with the krf files currently. Expanding on the solution that I suggested, you can load your file layer, then create a reference image from it with the action.
If you want a cleaner solution, I’m afraid it requires a change to the Python interface, for example, adding a new function in Document to handle this use case.
Thank you, there does not seem to be any action or API function, I was just hoping that there was but with some other name (node or something).
Since your topic did not fit the requirements for Developer Questions, I had to move it to the better fitting (but not ideal either) About the plugins-development category. I can only hope that it is okay for you, sorry.
Michelist