It is currently Wed Apr 24, 2024 10:03 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: filter to get list of gimp resources (SOLVED, thks Kevin)
PostPosted: Mon May 23, 2016 7:09 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
GIMP Version: 2.8.16
Operating System: Windows
GIMP Experience: Basic Level

List any relevant plug-ins or scripts:
pdb.gimp_gradients_get_list (names_filter)



Hi gurus.
So far I used sometimes the above statement to get a list of all gradients matching the "names_filter" as the beginning string.
For instance:
- I enter in the names_filter the string "MyGrad" and I get the whole list of all gradients with the name starting with "MyGrad" (MyGrad_01, MyGrad_02, MyGradwhatsoever, ..).
Assuming I want to select not based on the initial substring, but based on a substring inside the names, for instance, just to remain in the example, all gradients which contain in their name the substring "Grad", is there a way to put in front a "placeholder" character (like *Grad, or _Grad or I don't know...) to filter them?
(I mentioned those two characters because I did try and do not work: is there a way?)
Thanks a lot

_________________
"Where am I ?"


Last edited by dinasset on Mon May 23, 2016 8:23 am, edited 1 time in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: filter for getting the list of gimp resources (gradients e.g.)
PostPosted: Mon May 23, 2016 7:27 am  (#2) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
The filter is a "regular expression", so you can't just use *

> (gimp-gradients-get-list ".*tract")
(3 ("Abstract 1" "Abstract 2" "Abstract 3"))
Here I've specified I want to match zero or more characters in front of "tract"

Whereas here:
(gimp-gradients-get-list ".*tract [2-3]")
(2 ("Abstract 2" "Abstract 3"))
I'm matching the same as above, but only those with numbers in the range 2 -> 3

Good luck learning how to use regular expressions ;)

Kevin

More examples:

Containing the string "flag":
(gimp-gradients-get-list "flag")
(8 ("French flag" "French flag smooth" "German flag" "German flag smooth" "Mexican flag" "Mexican flag smooth" "Romanian flag" "Romanian flag smooth"))


"flag" must be the end of the name
(gimp-gradients-get-list "flag$")
(4 ("French flag" "German flag" "Mexican flag" "Romanian flag"))


Contains either "Yellow" or "Green":
(gimp-gradients-get-list "Yellow|Green")
(8 ("Yellow Orange copy" "Blue Green" "Greens" "Neon Green" "Neon Yellow" "Radial Eyeball Green" "Yellow Contrast" "Yellow Orange"))


Top
 Post subject: Re: filter for getting the list of gimp resources (gradients e.g.)
PostPosted: Mon May 23, 2016 7:36 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Thanks Kevin. Very quick and effective solution.
I didn't understand the term "regular expression" so far.
Where is this term defined?
Where can I learn "how to use regular expressions"?
Or even better what does "regular expression" mean? (in terms of Gimp?

_________________
"Where am I ?"


Top
 Post subject: Re: filter for getting the list of gimp resources (gradients e.g.)
PostPosted: Mon May 23, 2016 7:40 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
thanks for the examples...
so if I had used simply Grad not necessarily (as I tought) should "Grad" be the initial string....and I get what I want ! Excellent.

_________________
"Where am I ?"


Top
 Post subject: Re: filter for getting the list of gimp resources (gradients e.g.)
PostPosted: Mon May 23, 2016 7:42 am  (#5) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
Regular expression is a term used in most computer languages. It's used for pattern matching in strings.

Apparently in Italian it's Espressione regolare

Kevin


Top
 Post subject: Re: filter for getting the list of gimp resources (gradients e.g.)
PostPosted: Mon May 23, 2016 7:45 am  (#6) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
dinasset wrote:
thanks for the examples...
so if I had used simply Grad not necessarily (as I tought) should "Grad" be the initial string....and I get what I want ! Excellent.


If you want to force it to only match Grad at the start of the string, you prefix it with ^

Yellow only at the start:
(gimp-gradients-get-list "^Yellow")
(3 ("Yellow Orange copy" "Yellow Contrast" "Yellow Orange"))


Yellow anywhere:
> (gimp-gradients-get-list "Yellow")
(4 ("Yellow Orange copy" "Neon Yellow" "Yellow Contrast" "Yellow Orange"))


Also, rather unexpectedly, GIMP doesn't seem to be case-sensitive.

Kevin


Top
 Post subject: Re: filter for getting the list of gimp resources (gradients e.g.)
PostPosted: Mon May 23, 2016 8:00 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Thanks, I will have a look.
So far a regular expression for me was something like:
<xxx for less than xxx
>abc for greater than abc
=153 for equal to 153
etc.
Very basic arithmetical expressions....
I was used also to the wild character * to say any character...(or _ to say one char)
so that to search something containing the string "abcde" I would have tought at:
*abcde*
Never too old to learn....
Thanks

_________________
"Where am I ?"


Top
 Post subject: Re: filter for getting the list of gimp resources (gradients e.g.)
PostPosted: Mon May 23, 2016 8:00 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
oh, not case sensitive, interesting...

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Giiving my gimp resources

5

No new posts Attachment(s) Uzu's custom resources volume I

11

No new posts How to find a list of enums?

5

No new posts Attachment(s) cli345's cartoon filter as a native GEGL Filter.

10

No new posts Attachment(s) My last Aquarelle filter

21



* Login  



Powered by phpBB3 © phpBB Group