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

Selection of a path component

Fri Mar 05, 2021 3:17 pm

An existing vector path consists of more than one component. I would now like to make a selection of, for example, the first and third components.

With the method
Code:
pdb.gimp_image_select_item(image, CHANNEL_OP_REPLACE, vector_id)
a selection can unfortunately only be made from the entire path.

Can I convert a stroke ID into an item ID?

Re: Selection of a path component

Sat Mar 06, 2021 5:45 am

No, you have to make a new path with the strokes (the "components") you want and then make a selection on the result path. Not that hard. For instance the code to split a path into its constituents (one path per stroke):

Code:
    for stroke in path.strokes:
        strokePath=gimp.Vectors(image,'%s [%d]' % (path.name,stroke.ID))
        points,closed=stroke.points
        gimp.VectorsBezierStroke(strokePath,points,closed)
        pdb.gimp_image_insert_vectors(image, strokePath, None,-1) 
        strokePath.visible=True
Post a reply