[Bf-python] Python, C funcs that Python can use.

Campbell Barton cbarton at metavr.com
Sun May 30 13:04:41 CEST 2004


Hi,
While looking at existing C functions to re-impliment in Python I have 
found that it needs some restructuring.

Ok- Looking at apply_object() - It calls a GUI menu and looks for keys 
to be pressed down.
It also applys to all selected objects in the scene, so python calling 
it cant be set to a spesific object.


A few options are available-
1: Copy and paste the code into a python function and modify it to work.
Pro- No code restructure
Con- Not reusing code.
Con- Can only operate on selected objects.

2: Add the GUI spesific code to the butons or menuitems (QueRedraw and 
okee() functions could be moved here)
Pro- Not much code modification, just moving calls to the gui
Con- A bit Messy- Makes the Gui a bit cludgy with all the sily redraw calls,
Con- Can still only operate on selected objects.

3: Seperate each function into 2.
eg-
apply_object(ob) // Rather then applying to all selected objects, only 
apply to 1 object.
                           // This means python could easely have a hook 
to this: ob.ApplyObject()
The Gui could call

apply_object_gui()
    if (okee("Apply size/rot")==0) break;
    (loop through sel;ected objects)
    {
          apply_object(ob) // The real function that does all the work
    }
    QueRedraw()


Im sure 3 is the best option. but It would involve me (a C noob) going 
through and seperation each function into 2 parts though I consider 
myself capable of this.

I think this is needed for ApplySizeRot, Centre, Join, Boolean etc...

Any Comments :-)

- Cam






More information about the Bf-python mailing list