Gimp-Forum.net
Script-fu: How to create new, addressable layer using gimp-floating-sel-to-layer - 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)
+--- Thread: Script-fu: How to create new, addressable layer using gimp-floating-sel-to-layer (/Thread-Script-fu-How-to-create-new-addressable-layer-using-gimp-floating-sel-to-layer)



Script-fu: How to create new, addressable layer using gimp-floating-sel-to-layer - Bertholomäus - 08-31-2017

Hi!

I'm working for the first time with script-fu. I have an image from which I want to cut several parts and past them subsequently as new layers. Afterwards I'd like to manipulate those newly pasted layers but I cannot address them. I tried it in the  following way
Code:
(gimp-rect-select IMAGE 360 0 730 145 2 0 0)
(gimp-edit-cut LAYER1)
(set! VARIABLE1 (car ( gimp-edit-paste LAYER1 0 ) ) )
(set! VARIABLE2 ( car (gimp-floating-sel-to-layer VARIABLE1 ) ) )

 I expected VARIABLE2 to be a new layer that I can refer to as "VARIABLE2" but when I call a function like
Code:
(gimp-layer-scale VARIABLE2 1245 1113 0 )

I get an error message saying that  VARIABLE2 is not a valid input parameter.

Another strange thing that's happening, is that upon repeating the code block above, say 4 times to cut and paste different regions off LAYER1, the creation of the new layers works well up to the 3rd one. On the contrary the creation of the last layer gives just an empty layer instead of the area that should be cut from LAYER1. If I add an additional dummy layer the 4th layer is fine since now the dummy layer became the weird one,.

Can somebody explain to me what's going on and what I'm doing wrong?

You can find the original and complete code in the attachment.


RE: Script-fu: How to create new, addressable layer using gimp-floating-sel-to-layer - Kevin - 08-31-2017

A quick observation is that the procedure browser entry for gimp-floating-sel-to-layer shows that it doesn't return the id of the new layer - but just makes it the active layer, so you will have to set VARIABLE2 to the currently active layer using gimp-image-get-active-layer


RE: Script-fu: How to create new, addressable layer using gimp-floating-sel-to-layer - Ofnuts - 08-31-2017

It is also faster to duplicate the layer and do a gimp-resize-layer on it.