Gimp-Forum.net

Full Version: Unbound variable floating-sel Help!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi fellow GIMP users. I posted the same question @gimpchat.com. I been having an error on the line (gimp-floating-sel-anchor floating-sel) "eval: unbound variable: floating-sel". what should I do. Please explain how can I avoid this error when I write other scripts. Thank you in advanced.


Code:
(define (script-fu-create-heart)
   (let* (
       (img  (car (gimp-image-new 500 500 RGB)))
       (layer (car (gimp-layer-new img 500 500 RGB-IMAGE "Background" 100 LAYER-MODE-NORMAL)))
        (theheart (car (gimp-layer-new img 500 500 RGB "Heart" 100 LAYER-MODE-NORMAL)))
        
        
        )


        ;Create the Background
       (gimp-image-undo-disable img)              ; Disable undo during the image creation
       (gimp-image-insert-layer img layer 0 0)
        (gimp-context-set-foreground '(000 000 00))
        (gimp-drawable-fill layer FILL-FOREGROUND)
        
        ;Create the heart layer
        (gimp-image-add-layer img theheart -1)
        (gimp-layer-add-alpha theheart)
        (gimp-drawable-fill theheart FILL-TRANSPARENT)
        
        ;Create the heart image
        (gimp-image-select-ellipse img  2 60 105 385 285)
        (gimp-image-select-rectangle img  1  30  50  440  200)
        (gimp-image-select-ellipse img  0 58 143 385  215)
        (gimp-context-set-foreground '(221 0 0))
        (gimp-drawable-edit-fill theheart FILL-FOREGROUND)
        (gimp-item-transform-rotate theheart  45.00  TRUE   250.50  268.00)
        (gimp-floating-sel-anchor floating-sel)
        
        
        
        
        
        
        
        (gimp-image-undo-enable img)
        
        
        
        
        
        (gimp-display-new img)
Hello, Smile

I suppose "floating-sel" was in the copy/paste from console.

Replace "floating-sel" by the name of layer you are using in this part of script... probably "theheart".

Have fun. Smile
@+++
(gimp-floating-sel-anchor floating-sel) is a bit weird at that point, floating-sel would be the floating selection drawable returned by a paste operation initiated from the script, and I don't see any in your code. In other words, there is no value in floating-sel but there is no code likely to put an adequate value in it either.
Thank ofnuts for the explanation. I took a second look and I found what I did wrong. When I created a "selection" on the image and I filled the selection, I forgot to "Select> None". Somehow when I rotated the image without getting rid of the selection, it created a floating selection that I could not got rid off. I manage to do (gimp-selection-none img) and then rotate the image and that worked.