Gimptalk - Premier Gimp Community: Python-fu plug_in_map_object - Gimptalk - Premier Gimp Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Python-fu plug_in_map_object

#1 User is offline   portlandbob 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 28-April 08

Posted 28 April 2008 - 10:41 PM

I've been banging my head on this one for awhile and I can't get past "TypeError: wrong parameter type". I've set all the values to integers since I figured it could automagically convert them to floats if it needed to. I realize I shouldn't have tangled with a function that has 40+ arguments, but it's what I need. I got a colortoalpha plugin to work, but I've removed it for clarity.

I'm new to python so I suspect I'm indenting wrong or some such thing. Please set me straight.

Here's my code:

#!/usr/bin/env python

import math
from gimpfu import *

def create_spherical_animation(img, drw):
img.disable_undo()
layer_ovoid = drw.copy(True)
layer_ovoid.mode = NORMAL_MODE
layer_ovoid.name = "Ovoid"
img.add_layer(layer_ovoid, -1)
pdb.plug_in_map_object(img, layer_ovoid, 1,
#viewpoint x, y, z
1, 1, 2,
#position x, y, z
1, 1, 1,
#first-axis x, y, z
1, 0, 0,
#second-axis x, y, z
0, 1, 0,
#rotation-angle x, y, z
0, 0, 5,
#light type = directional
1,
#light color (r,g,b)
(255,255,255),
#light position
-5,-5,2,
#light direction
-1,-1,1,
#intensity levels
1,1,
#reflectivity
1,0,27,
#general options
1,0,0,1,
#sphere radius
1,
#scale
0,0,0,
#cylinder
0,
-1,-1,-1,-1,-1,-1,-1,-1)
img.enable_undo()
gimp.displays_flush


register(
"create_spherical_animation",
"Create a series of frames from a rotating sphere",
"HOW TO",
"Author",
"cc sa by",
"2008",
"/Filters/Animation/S_pherical",
"RGB*, GRAY*",
[],
[],
create_spherical_animation)

main()
0

#2 User is offline   0ion9 

  • Member
  • PipPip
  • Group: Members
  • Posts: 99
  • Joined: 16-February 08

Posted 29 April 2008 - 06:13 AM

Hi Bob,
Your mistake is not an indentation problem; almost every indentation problem causes a SyntaxError or IndentationError.
The TypeError comes from the drawables; you have given -1 for the drawables, however they need to be a drawable -1, not an integer -1.
if you do
na = gimp._id2drawable(-1)
and then replace the -1's with na, does that help?

Lastly, you are not calling gimp.displays_flush.
Instead, you are getting its value (and then discarding it). This is because you omitted the ()
0

#3 User is offline   portlandbob 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 28-April 08

Posted 29 April 2008 - 06:33 AM

I'm not sure how to repay your quick response. You nailed it. The -1 not being a drawable was it. I had no clue about the need to make the -1 a drawable even though it clearly shows that in the procedure browser.

If you want my avatar you only need ask.
0

#4 User is offline   0ion9 

  • Member
  • PipPip
  • Group: Members
  • Posts: 99
  • Joined: 16-February 08

Posted 30 April 2008 - 02:33 AM

My pleasure, really.
(I'm the same guy who talked to you elsewhere, recommending the spacing out across lines + commenting)
I had some trouble with -1 drawables myself, before, so it's good to know for me too.
0

#5 User is offline   Pau 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 01-August 11

Posted 01 August 2011 - 03:04 PM

Thank you very much! You've saved me from becoming psycothic -.-

It's very difficult to find any kind of documentation about python-fu... could you recommend me any site or book?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic