Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 4:59 am

I wonder if you could actually write a script that creates a selection from user placed guides?

1) User creates a grid of guides. Then runs the filter.
2) The filter creates a selection from those guides and a path from that selection. The user could then stroke the path as they see fit. Or stroke the selection. Or perhaps the filter could allow a toggle for either choice?

Re: Python or Scheme script request

Sun Sep 18, 2016 5:56 am

Have a look here:
http://www.arakne.es/en/dessign/gimp-guideslab-edit-guides-numerically/
There you can set and change guides ... very very nice!

What you then want after having a lot of (more then 4) guides is not clear to me.
Explain, maybe with a picture?

Re: Python or Scheme script request

Sun Sep 18, 2016 6:37 am

PKHG wrote:Have a look here:
http://www.arakne.es/en/dessign/gimp-guideslab-edit-guides-numerically/
There you can set and change guides ... very very nice!

What you then want after having a lot of (more then 4) guides is not clear to me.
Explain, maybe with a picture?

I do have Guide Labs and it is a great filter to add extra guides. But it doesn't create a selection from those guides.
Actually i am trying to automate somewhat a grid for a printable document say for an office table grid.
see - viewtopic.php?f=8&t=14563

The user would possibly use "Guide Labs" to create the guides and the filter would create a selection from those guides. OR maybe the "Guide Labs" PDB functions could be called as part of the new filter dialog?

Then you could do it all from one filter.
1) Create your doc you want any size (possibly the filter could do this also)
2) run the filter which gives the user a way to add guides
3) and then creates a selection from those guides
4) allowing the user to stroke the selection as they see fit.

I am basically asking is there a way to select from guides?

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 8:44 am

Good idea Rod, I've thought about something along those lines as well. The Guillotine command slices guides into separate images and all guides can be removed at once so you would think there is a way to select guides?

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 8:58 am

Odinbc wrote:Good idea Rod, I've thought about something along those lines as well. The Guillotine command slices guides into separate images and all guides can be removed at once so you would think there is a way to select guides?

Yes and Filters>Web>Slice will slice images into pieces using guides also. So there must be a way to select guides.

Maybe only in C as an executable?

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 9:19 am

Rod wrote:
Odinbc wrote:Good idea Rod, I've thought about something along those lines as well. The Guillotine command slices guides into separate images and all guides can be removed at once so you would think there is a way to select guides?

Yes and Filters>Web>Slice will slice images into pieces using guides also. So there must be a way to select guides.

Maybe only in C as an executable?
Wouldn't most of that be in PDB?
I found a few of interest.
Code:
gimp-image-get-guide-orientation
gimp-image-get-guide-position
gimp-image-find-next-guide

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 10:01 am

I honestly think that in some cases, because of rows or columns having different cell containers, it might be more beneficial to utilize (rectangular) paths. Not to say that a guide selection script doesn't have its advantages, just that tables are a different beast for guidelines (unless everything is symmetrical). Two rows with different dimensioned cell sizes would pose a problem for selecting as a table. Just a thought.

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 10:34 am

mahvin wrote:I honestly think that in some cases, because of rows or columns having different cell containers, it might be more beneficial to utilize (rectangular) paths. Not to say that a guide selection script doesn't have its advantages, just that tables are a different beast for guidelines (unless everything is symmetrical). Two rows with different dimensioned cell sizes would pose a problem for selecting as a table. Just a thought.

Yes.

Furthermore I don't see the point in going into the trouble of positioning 4 guides (4 things to drag around) to create a rectangle selection when the same can be done with one drag using rectangle select directly. And if you need guides and selection, you can get the guides from the selection (Image>Guides>New guides from selection).

Re: Python or Scheme script request

Sun Sep 18, 2016 10:48 am

Rod wrote:
PKHG wrote:Have a look here:
http://www.arakne.es/en/dessign/gimp-guideslab-edit-guides-numerically/
There you can set and change guides ... very very nice!

What you then want after having a lot of (more then 4) guides is not clear to me.
Explain, maybe with a picture?

I do have Guide Labs and it is a great filter to add extra guides. But it doesn't create a selection from those guides.
Actually i am trying to automate somewhat a grid for a printable document say for an office table grid.
see - viewtopic.php?f=8&t=14563

The user would possibly use "Guide Labs" to create the guides and the filter would create a selection from those guides. OR maybe the "Guide Labs" PDB functions could be called as part of the new filter dialog?

Then you could do it all from one filter.
1) Create your doc you want any size (possibly the filter could do this also)
2) run the filter which gives the user a way to add guides
3) and then creates a selection from those guides
4) allowing the user to stroke the selection as they see fit.

I am basically asking is there a way to select from guides?


Grrr I answered some hours ago and saving did not work? OK Again:

In principle you can do it, because as the guide-lab shows all guide info is easily available AND there is a method to create selections out of a list of points (x,y) ...
All intersections of guides are so to say known and could be used either one for one or all at once to create out of the guides selections (all rectangular or polygons of other type!) .

Maybe it is a good idea to extend the guide-lab a bit, to suit your wishes (which are not yet 100% clear to me).
Why? Because the guide-lab window is a GTK-window and independent in some sence from the Gimp-window. Means use and or change/add guides with guide-lab select in the Gimp-window some part of your wish and let the extended plugin do what you want; the guide-lab still active ...

So some more explanation needed , the pictures and the xcf of the link (above) make it a bit clear but yet not 100% ... Try ;) a bit more ...

Re: Python or Scheme script request

Sun Sep 18, 2016 12:45 pm

PKHG wrote:In principle you can do it, because as the guide-lab shows all guide info is easily available AND there is a method to create selections out of a list of points (x,y)


Then there is a way to get x,x (horizontal guide) OR x,y (vertical guide) coordinates from a SET of guides and from that create a selection that can be stroked?
Seems like you could use the brush to stroke between these coordinates then.

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 1:28 pm

sorry, Rod, not to offer my help, but whenever the word "path" comes into the game I fly away:
paths "non sono nelle mie corde" as we say in Italy...
(maybe you say "I'm not in my comfort zone with paths", if Google translates correctly the Italian motto)

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 5:32 pm

Check here for latest version -> Guides to Path (scheme script)
Here it is. Will be available under Image/Guides/Guide to path
Image

Create your guides however you like, run script and a path will be created at which point you can use to stroke however you like.

To stroke just a selection, just make your selection then stroke the created path and it'll only stroke where the selection is present..that is already built-in.

If you wanted to select from guides just uncheck snap to grid and check snap to guides under /View/ and it's easy to select (rectangle select) from guides.

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 6:06 pm

Wow, Tran! Did you write that script that fast?

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 6:07 pm

well it's not very complex once you know which methods to call.

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 6:08 pm

Great script! There is just one small nuisance for me:

I tried to enter intersecting path points on each row and column so that I could essentially cut the paths out where I didn't want them stroked, and it keeps cutting the whole path. Going to revisit the Path manual and see what I am doing wrong.

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 6:11 pm

i think it's much faster if you choose snap to guides and then rectangle select the area you want stroked and then stroke it using the whole path.

i could never remember how to insert a point to delete other parts of the path either... i always mess aroudn with it for like tens of minutes before figuring it out and then instantly forget again. :hehe

EDIT: This spawns another idea...which is if there is selection (defined by a bounding box).... only draw paths within this bounding box.
So that you can rectangle select the first row, then it'll only draw paths within this rectangle then you can move on to the second row by rectangle selecting it and redefine the guides and then run script to create path for the 2nd row and so on.

Re: Python or Scheme script request (selection from guides)

Sun Sep 18, 2016 8:40 pm

Just added release 2 which will only create path within bounding box of selection (if there is a selection).

as it's own thread.
Guides to Path (scheme script)

Please have a look. ;)

Re: Python or Scheme script request

Mon Sep 19, 2016 1:04 am

Rod wrote:
PKHG wrote:In principle you can do it, because as the guide-lab shows all guide info is easily available AND there is a method to create selections out of a list of points (x,y)


Then there is a way to get x,x (horizontal guide) OR x,y (vertical guide) coordinates from a SET of guides and from that create a selection that can be stroked?
Seems like you could use the brush to stroke between these coordinates then.


Sure ;)

Re: Python or Scheme script request

Mon Sep 19, 2016 6:15 am

PKHG wrote:
Rod wrote:
PKHG wrote:In principle you can do it, because as the guide-lab shows all guide info is easily available AND there is a method to create selections out of a list of points (x,y)


Then there is a way to get x,x (horizontal guide) OR x,y (vertical guide) coordinates from a SET of guides and from that create a selection that can be stroked?
Seems like you could use the brush to stroke between these coordinates then.


Sure ;)


Am on the way
arakne_extra_01.jpg
arakne_extra_01.jpg (196.43 KiB) Viewed 2669 times


There is a new button: Your whish! ..

And your real wish is not yet 100% explained!
That 'must' be mathematically precise! Example you could wish to select TRIANGLES ? :hehe
Look into Error Console after L322 there is the info hidden about what
guides I had in the picture ...

Re: Python or Scheme script request

Mon Sep 19, 2016 6:32 am

PKHG wrote:
Am on the way
arakne_extra_01.jpg


There is a new button: Your whish! ..

And your real wish is not yet 100% explained!
That 'must' be mathematically precise! Example you could wish to select TRIANGLES ? :hehe
Look into Error Console after L322 there is the info hidden about what
guides I had in the picture ...

You lost me here, sorry. :(
So what does the "Your Wish. Let Us Go" button do?
Post a reply