Sign up now! · Forgot password?
gimpusers.com RSS feed
58 @ identi.ca
819 @ Twitter

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

ForumsFor GIMP users ► pdb.gimp_image_insert_vectors() in python-fu with gimp-2.7

Sent: 2012-02-03 06:36:28 UTC (3 months ago)

From: Mike Kazantsev

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.

Mike Kazantsev // fraggod.net

» Reply to this message