Gui problem

Gui problems

1 - i use an existing GUI for buttons given as a tut
and modified it so that i can add many curves in the menu

see included file with script inside

the first problem with this GUI
is the fact that each functions called by the menu
seems to be executed 3 times?
at least that’s what i see on the console
but there seems to be only one object in blender on outliner!

how can it be executed only ounce ?

2 - problem with the Mesh and object definition

i defined in the main part the mesh and ob for the new object

create mesh data block

ob = B.Object.New(‘Mesh’, ‘MeshOb’)

create ObData

me = B.Mesh.New(‘moldingMesh’)

then in the function i can add the vertices and edges then
link it to the scene me )
scene = B.Scene.GetCurrent() ob )

now should i create a new mesh object each time i create a new shape
one per function
or is it possible to create one general mesh objet that can be used
or modified in each the functions?
but then how do you reset the mesh values ?

one of the problem is if i erase an added object then the script does not work anymore!

Happy blendering

anybody can help on that one


I think you are getting your multiple calls because you are calling your function inside your redraw. Try moving it out into the event section.

    elif evt == evtMenu:
        print " ########  Menu choice changed to", menu.val

You are only doing a print here, but you should be doing…

    elif evt == evtMenu:
        print " ########  Menu choice changed to", menu.val

This way your function is only called when the menu changes, not everytime a redraw is issued.

I came up with a function called “fectchIfObject”

def fetchIfObject (passedObjectName):
    # NOTE: Returns the object even if it is unlinked to the scene.
        tempObj = Blender.Object.Get(passedObjectName)
        return tempObj
        return None

What this allows you to do is to fetch the object if it already exists.

You could wrap your create OB, near the begining like this…

ob = fetchIfObject("MeshOb")
if ob == None:
    ob = B.Object.New('Mesh', 'MeshOb')

This way, if the object does not exist, a new one will be created, or an existing one in the scene will be fetched.

i got a PM with corrected file and now it’s not doing the multi call to each functions

but now the only problem left has to do with the fact that the functions is being called
i can see the print on the console
but i don’t see the mesh in blender

so that’s the last problem to solve before i can continu to code the differetn moldings
i need to do!

but also i like your idea bout checking for existing ob if not then create that ob

shoud i upload a new corrected file - might easier to check it out

anyway let me know


Can you cut my grass for me while I work on your code?