Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Troubles with porting a script to Gimp3
#16
(03-08-2025, 05:14 PM)teapot Wrote: alvk, Thank you for your updated code and explanation, it's going to be a useful template.

Have you tried running it on, for example, a layer group to check you're getting your cannot add label message. I think the (< 1 layer-type) is never true. You checked for = 1 before.

(03-08-2025, 10:14 AM)alvk Wrote:
Code:
   (if (< 1 layer-type)
     (begin (gimp-message "Cannot add the label to the selected layer"))
     (begin (set! text-layer (gimp-text-font image -1 text-layer-position-x
                                             text-layer-position-y user-text 0 #t
                                             font-size font))
            (gimp-text-layer-set-color text-layer font-color)
            (gimp-item-set-lock-position text-layer #t)))
Yes, I did. It works as expected. Well, almost as I expect. I just check it and found that if a layer has a mask and the mask is selected, i.e., the border around the layer is green, the script actually inserts the text into the mask. Probably I misunderstand what a layer mask is and how to work with them. I need to read about this. Other types of drawables, i.e., text layer, layer group, path, and selection works as expected.

The idea behind (< 1 layer-type) is to extend the script messaging by providing different messages depending on the selected type of drawable. This is a kind of preliminary code to be extended later. But even in its current form, it works.
Reply


Messages In This Thread
Troubles with porting a script to Gimp3 - by alvk - 03-03-2025, 10:42 AM
RE: Troubles with porting a script to Gimp3 - by alvk - 03-09-2025, 01:02 AM

Forum Jump: