RSS/Atom feed Twitter
Site is read-only, email is disabled

pdb.gimp_image_insert_vectors() in python-fu with gimp-2.7

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

1 of 1 message available
Toggle history

Please log in to manage your subscriptions.

pdb.gimp_image_insert_vectors() in python-fu with gimp-2.7 Mike Kazantsev 03 Feb 06:36
Mike Kazantsev
2012-02-03 06:36:28 UTC (almost 13 years ago)

pdb.gimp_image_insert_vectors() in python-fu with gimp-2.7

Hi, list!

With new wave of deprecations coming with gimp-2.7, I thought to port a part of a gimp-using project to the new API, but I've encountered an issue with "pdb.gimp_image_insert_vectors()" function.

pdb.gimp_image_insert_vectors() takes "image", "vectors", "parent vectors" and "position" as a parameters, which differs from pdb.gimp_image_add_vectors() in "parent vectors" parameter.

Function doc says "Since vectors groups are not currently supported, the parent argument must always be 0".

Problem (maybe python-fu specific) is that you must pass the instance of gimp.Vectors class (passing "int" 0 just gives "wrong type" error) to "parent vectors" argument, and there doesn't seem to be a way to get gimp.Vectors with ID=0.

Passing random other Vectors objects there fails. gimp.Vectors.ID (for some arbitrary Vectors object) can't be set via conventional means in python, as it's read-only attribute. gimp.Vectors.from_id(0) returns None, and passing None object also raises "wrong type" error.

Is this a bug or is there some way to make this function happy that I've missed?
Maybe some general convention on how to pass id=0 objects?

Short example:

#!/usr/bin/env python

from gimpfu import * import gimp

def demo(path):
image = pdb.gimp_file_load(path, path) vectors = gimp.Vectors(image, "vectors") pdb.gimp_image_insert_vectors(image, vectors, None, -1)

register( 'test', '', '', '', '',
'', 'problem_demo', 'RGB*',
[(PF_FILE, 'file_name', 'src', '')], [], demo )
main()

(cat >~/.gimp-2.7/plug-ins/test.py, chmod +x ~/.gimp-2.7/plug-ins/test.py, gimp -ib '(python-fu-test RUN-NONINTERACTIVE "/path/to/any/image.jpg")')

"None" is passed as a "parent vectors" here.