Gimp-Forum.net
Layer Group set active - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: Layer Group set active (/Thread-Layer-Group-set-active)



Layer Group set active - david - 05-17-2023

What is the syntax to set a layergroup (and possibly a layer within it) as active?

I have looked through the console and searched the web without success.

If, for instance, I wish to insert a layer it is straight forward - I can specify parent and position.
Should not the same syntax apply to other layer commands, or is it that the console has not been updated?


RE: Layer Group set active - Ofnuts - 05-17-2023

In script-fu you can use (gimp-image-set-active-layer image active-layer), in Python pdb.gimp_image_set_active_layer(image, active_layer), but the active_layer attribute of a gimp.Image object is writable: image.active_layer=image.layers[1].

However the "active layer" is a human user thing. All the functions that apply to a layer take an explicit layer parameter so there is little point in changing the active layer. The only thing I would use this for is to change the active layer before returning control to the user, assuming it is not what the user would expect.


RE: Layer Group set active - teapot - 05-17-2023

(05-17-2023, 09:17 PM)Ofnuts Wrote: In script-fu you can use (gimp-image-set-active-layer image active-layer), in Python pdb.gimp_image_set_active_layer(image, active_layer), but the active_layer attribute of a gimp.Image object is writable: image.active_layer=image.layers[1].

However the "active layer" is a human user thing. All the functions that apply to a layer take an explicit layer parameter so there is little point in changing the active layer. The only thing I would use this for is to change the active layer before returning control to the user, assuming it is not what the user would expect.

Indeed so, but I've come across some exceptions that reply on the active layer so they would need it setting to the one that's wanted if not already it e.g.

pdb.plug_in_autocrop_layer (that caught me out)
pdb.script_fu_perspective_shadow (strangely)
pdb.plug_in_gmic_qt (maybe)

Of course it's a long shot david wants to use one of these so I guess that raises the question, david what do you want the active layer set for?


RE: Layer Group set active - david - 05-18-2023

Thanks for the replies.

The reason I wished to set the active layer was, having copied a layer to the buffer, I then wanted to paste it to the mask of a layer in a layer-group.

However, if I understand the reply from Ofnuts correctly, I can address the layer-group numerically like any other layer.

At 76 years of age it takes me a long time to get my brain around these concepts!


RE: Layer Group set active - Ofnuts - 05-18-2023

the paste operation take a target "drawable" parameter, which can be a layer or a mask (or a channel). This doesn't need to be the "active" one.