Post Reply 

Polygon selection in script

May 20, 2014, 02:17
Post: #1
Polygon selection in script
Hello all- I am writing a short script that calls python-fu-heal-selection. It works when I call the rectangle selection script, like:

Code:
(gimp-image-select-rectangle     image CHANNEL-OP-ADD     0 0 50 50)

However when I instead call..
Code:
(path-points (list->vector points)
(gimp-image-select-polygon     image CHANNEL-OP-ADD  point_count     path-points)
(variable point_count and points are both passed into the script)

I get the message:
"Heal selection-Warning: You must first select a region to heal."
So I must have a flaw in my call to gimp-image-select-polygon, right?

My batch file:
Code:
"C:\\Program Files\\GIMP 2\\bin\\gimp-console-2.8" --verbose -d -i -b "(myScript '(0 0 0 50 50 50 50 0 0 0) 5)"

(The polygon should be a self-connecting square)
If anyone could point out what I'm doing wrong, I'd appreciate it. (full script attached)


Attached File(s)
.txt  bad polygon select.txt (Size: 735 bytes / Downloads: 54)
Find all posts by this user
Quote this message in a reply
May 20, 2014, 06:42 (This post was last modified: May 20, 2014 06:51 by ofnuts.)
Post: #2
RE: Polygon selection in script
In python this works (creates the expected square):
Code:
>>> points=[100.,100.,200.,100.,200.,200.,100.,200.]
>>> pdb.gimp_image_select_polygon(image, 2, 8, points)

So:
  • You don't need to go back to the origin, the rectangle is closed for you
  • contrary to what the documentation says, the "count" is not the number of points/segments but the number of coordinates (points * 2).
  • In practice I don't see many cases where I would want to use only the first points in an array, so I wouldn't make the count a parameter:
    Code:
    >>> pdb.gimp_image_select_polygon(image, 2, len(points), points)

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
May 21, 2014, 00:30
Post: #3
RE: Polygon selection in script
Thanks very much! It was my point count that was off.
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Request for script chlebna 1 101 Sep 13, 2017 09:35
Last Post: ythgilb
  Request for script - Guillotine + Watermark sunslick 1 166 Sep 4, 2017 08:51
Last Post: ythgilb
  Script-fu: How to create new, addressable layer using gimp-floating-sel-to-layer Bertholom√§us 2 152 Aug 31, 2017 14:32
Last Post: Bertholomäus
  How to modify this script-fu? Zakary81 1 123 Aug 23, 2017 12:48
Last Post: paynekj
  Cant get Heal Selection to work ianp5a 1 213 Oct 9, 2014 20:04
Last Post: rich2005

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS