It is currently Thu Jul 25, 2024 8:05 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: understanding a bit of paths (bug to fix?)
PostPosted: Thu Dec 15, 2016 8:34 am  (#1) 
Offline
GimpChat Member
User avatar

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



As many of you know, I'm quite ignorant on paths.
So, I have a little question for the experts on paths:
assuming there is an image with a path already created and I want to access the path, set it visible (and active, later).

First I tried the pdb procedure:
nr,paths = pdb.gimp_image_get_vectors (img)
supposing to get in paths the list of vectors, I then entered:
newpath = paths[0]
pdb.gimp_item_set_visible (newpath, True)
I get an error : wrong parameter type

Then I tried the object procedure:
paths = img.vectors
which is supposed to give the list of vectors in the image img. I then entered as before:
newpath = paths[0]
pdb.gimp_item_set_visible (newpath, True)
That works.

Hence my question:
why does the pdb method return a different "list" with respect to the object method?

_________________
"Where am I ?"


Last edited by dinasset on Thu Dec 15, 2016 10:05 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: understanding a bit of paths
PostPosted: Thu Dec 15, 2016 9:26 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
addendum:
I know that python "works" on objects and not on ids, and that the pdb.gimp_image_get_vectors returns ids, but AFAIK all PDB functions return/get ids.
Is this a special case because of paths?

Edit: pdb python interface SHOULD return always objects and not ids
Is this a bug for the pdb to python interface?

_________________
"Where am I ?"


Last edited by dinasset on Thu Dec 15, 2016 10:08 am, edited 1 time in total.

Top
 Post subject: Re: understanding a bit of paths
PostPosted: Thu Dec 15, 2016 10:04 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
by googling I found a solution for the method using PDB.
The sequence:
nr,paths = pdb.gimp_image_get_vectors (img)
newpathid = paths[0]
newpath=gimp._id2vectors(newpathid)    #### internal special gimp function
pdb.gimp_item_set_visible (newpath, True)

works, but the one who suggested this said also that could be a bug to be fixed in the interface PDB for python

_________________
"Where am I ?"


Top
 Post subject: Re: understanding a bit of paths
PostPosted: Thu Dec 15, 2016 10:19 am  (#4) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4758
dinasset wrote:
by googling I found a solution for the method using PDB.
The sequence:
nr,paths = pdb.gimp_image_get_vectors (img)
newpathid = paths[0]
newpath=gimp._id2vectors(newpathid)    #### internal special gimp function
pdb.gimp_item_set_visible (newpath, True)

works, but the one who suggested this said also that could be a bug to be fixed in the interface PDB for python


Ninja'ed for this. However, I usually don't worry about that because I use:

img.vectors[0].visible=True

_________________
Image


Top
 Post subject: Re: understanding a bit of paths (bug to fix?)
PostPosted: Thu Dec 15, 2016 10:20 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
...which is much simpler!
(Do you think too that it's an error in the PDB interface for Python?)

_________________
"Where am I ?"


Top
 Post subject: Re: understanding a bit of paths (bug to fix?)
PostPosted: Thu Dec 15, 2016 11:25 am  (#6) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4758
dinasset wrote:
...which is much simpler!
(Do you think too that it's an error in the PDB interface for Python?)


yes, likely a bug.

For the record, there are several attributes that are read/write: name, linked, and visible.

And I just found that instead if using the obscure gimp._id2vectors() (which isn't for general public use as implied by the leading underscore) you can use the more official looking:

path=gimp.Vectors.from_id(some_id)

_________________
Image


Top
 Post subject: Re: understanding a bit of paths (bug to fix?)
PostPosted: Thu Dec 15, 2016 11:31 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
many thanks, ofnuts

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Understanding where and how to get GIMP plugins

10

No new posts Find and fill paths if closed, convert closed paths to transparent

1

No new posts Paths Tool Help

1

No new posts Attachment(s) Users' Paths

2

No new posts Juxtapose exactly duplicate paths

2



* Login  



Powered by phpBB3 © phpBB Group