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

"Wrong parameter type" using Map object (Solved)

Sat Sep 05, 2020 12:40 pm

Hi guys! I'm writing a plugin using Map object and is giving me this error. What i'm I missing?

Image


I'm using the procedure code sample by Graechan here: viewtopic.php?f=9&t=10856 post #3
Code:
pdb.plug_in_map_object(img, pumLayer,
                                   1,    # Type of mapping (0=plane,1=sphere,2=box,3=cylinder)
                       0.5, 0.5, 2.0,    # viewpoint
                       0.5, 0.5, 0.0,    # object pos
                       1.0, 0.0, 0.0,    # first axis
                       0.0, 1.0, 0.0,    # 2nd axis
                      0.0, 0.0, 15.0,    # axis rotation
                                0,    # Type of lightsource (0=point,1=directional,2=none)
                     (255, 255, 255),    # Lightsource color (r,g,b)
                        0.5, 0.5, 2,    # light position
                     -1.0, -1.0, 1.0,    # light direction
            0.8, 0.5, 0.4, 0.0, 27.0,    # material (amb, diff, refl, spec, high)
                           TRUE,    # antialias
                           FALSE,    # tile
                           FALSE,    # new image
                           TRUE,    # transparency
                           1.00,    # Sphere/cylinder radius (only used when maptype=1 or 3)
                     0.5, 0.5, 0.5,    # box size
                           1.00,    # unused parameter Cylinder length
                             -1,    # Box front face (set these to -1 if not used)
                             -1,    # Box back face
                             -1,    # Box top face                           
                              -1,    # Box bottom face
                             -1,    # Box left face
                              -1,    # Box right face
                             -1,    # Cylinder top face (unused parameter)
                             -1)    # Cylinder bottom face (unused parameter)

Re: "Wrong parameter type" using Map object

Sat Sep 05, 2020 2:50 pm

Hi Pocholo.

Right now, the only plugin I can remember that works fine with plug_in_map_object is "Planet_wire_frame_model.py" by TinTran:
https://gimplearn.net/viewtopic.php?f=3&t=535
Code:
pdb.plug_in_map_object(image, drawable,1,0.5,0.5,2.0,0.5,0.5,0.0,1.0,0.0,0.0,0.0,1.0,0.0,-1.5,70,45,2,(255,255,255),1.0,1.0,1.0,1.0,1.0,1.0,0.3,1,0.5,0,27,True,False,False,True,0.25,0.25,0.25,0.25,1.00,None,None,None,None,None,None,None,None)

Re: "Wrong parameter type" using Map object

Sat Sep 05, 2020 9:24 pm

Thank you so much for your help, MararoQ. I will try that. :yes

Re: "Wrong parameter type" using Map object

Sat Sep 05, 2020 9:48 pm

Pocholo Please post your pumpkin pattern or xcf file so I can run map object on it

Re: "Wrong parameter type" using Map object

Sun Sep 06, 2020 12:48 am

Graechan wrote:
Pocholo Please post your pumpkin pattern or xcf file so I can run map object on it


Graechan, I got the Map object fixed and working with MareroQ sample from one of Tin Tran plugin "Planet_wire_frame_model.py".

The only difference a I see on the code is that some parameters were written in lowercase (True, False) and the last 8 parameters were written as None instead of -1.

Code:
pdb.plug_in_map_object(img, pumLayer,
                                       1,    # Type of mapping (0=plane,1=sphere,2=box,3=cylinder)
                           0.5, 0.5, 2.0,    # viewpoint
                           0.5, 0.5, 0.0,    # object pos
                           1.0, 0.0, 0.0,    # first axis
                           0.0, 1.0, 0.0,    # 2nd axis
                          0.0, 0.0, 20.0,    # axis rotation
                                       0,    # Type of lightsource (0=point,1=directional,2=none)
                         (255, 255, 255),    # Lightsource color (r,g,b)
                           0.5, 0.5, 2.0,    # light position
                         -1.0, -1.0, 1.0,    # light direction
             0.80, 0.50, 0.40, 0.0, 27.0,    # material (amb, diff, refl, spec, high)
                                    True,    # antialias
                                   False,    # tile
                                   False,    # new image
                                    True,    # transparency
                                    0.25,    # Sphere/cylinder radius (only used when maptype=1 or 3)
                           0.5, 0.5, 0.5,    # box size
                                    1.00,    # unused parameter Cylinder length
                                    None,    # Box front face (set these to -1 if not used)
                                    None,    # Box back face
                                    None,    # Box top face                           
                                    None,    # Box bottom face
                                    None,    # Box left face
                                    None,    # Box right face
                                    None,    # Cylinder top face (unused parameter)
                                    None)    # Cylinder bottom face (unused parameter)



This is the result using Map object and G'MIC:
Image

Thank you anyway, you guys are being great in my coding learning journey.

Re: "Wrong parameter type" using Map object

Sun Sep 06, 2020 1:51 am

That was just reflecting the difference between Python and Scheme
by the way great looking Pumpkin

Re: "Wrong parameter type" using Map object

Sun Sep 06, 2020 2:42 am

Pocholo wrote:The only difference a I see on the code is that some parameters were written in lowercase (True, False) and the last 8 parameters were written as None instead of -1.


Because:

1) in Python, the two boolean values are True and False, with an initial cap.
2) In Script-fu, you don't deal with Gimp objects (image, layers, paths...), directly but with a "handle" which is a positive integer number (more or less a sequence number of creation), so "no object" is the special "-1" handle. In Python-fu, the Gimp objects are wrapped in a Python object, so "no object" is "None", which is the reserved value for "nothing" in Python (most other programming languages use "null" instead).

Re: "Wrong parameter type" using Map object

Sun Sep 06, 2020 7:52 am

@Graechan, Thank you for the amiability to help! What I'm trying to archive is creating a carved pumpkin. By the way, I'm using the pumpkin gradient created by our latest friend Oregonian: viewtopic.php?f=23&t=622&p=6131&hilit=pumpkin+gradient#p6131

@Thanks for the explanation Ofnuts, I couldn't said it better myself. :hehe
Post a reply