[Bf-committers] Minor Restructure for python intergration.
Campbell Barton
bf-committers@blender.org
Mon, 31 May 2004 17:26:59 +1000
Hi, I have been looking at how best to impliment all blenders object
functions from python.
Such as ApplySizeRot, Join, CentreNew/Cursor(done), Select an
object(done), Boolean, Rotate around a point (the cursor)
Basicly a way that you can do the sort of things you do in the UI but do
them in python.
Though all these could be menualy dont in python its a lot of work, slow
to execute and why not hook onto the existing C functions.
The thing thats holding me up is that all these functions apply to
selected objects so there isnt any good way of applying them to a
spesific object.
One way would be to....
record all select objects
select None exept for the object where dealing with
run function such as apply_object()
revert to previous selection state.
This looks to me like a very bad way of doing things- way too much
looping... but if for some resion its ok sombody let me know.
Another option is to accept that these functions only operate on
selected data and make it the Python programmers responibility to select
the objects they need to operate on.
This is an interestion option (apart from the fact it makes all these
functions dead easy to impliment) because It would be like using python
to replicate user input.
Python code cold look like this
_____
Object.SelectNone()
ob1 = Object.Get('Sphere')
ob2 = Object.Get('Box')
ob1.sel = 1 # Select the object
ob2.sel = 1 # ...
Object.Join() # Joins all selected objects
Object.ApplySizeRot()
newObjects = Object.DupLinked() # Just like Alt+D, operates on selected
objects of course, could return a list of all the new Linked duplicates.
_____
Is this acceptable?
The resion Im posting on bf-committers too is that for all these to be
usefull all need to seperate all the GUI spesific redraws and menus from
these functions, this isnt a large task, I just dont want to tread an
anybodys toes.
At the moment apply_object has a menu call and a redraw, these could be
moved to a function called apply_object_ui
Pardon the psudo code :-)
void apply_object_ui()
{
if (okee('Apply size/Rot?'))
{
apply_object()
Queredraw()
}
}
Most of the function would need the menus and redraws removed, but thats
about it.
Then python could accsess the non-UI functions and it would be dead
simple to impliment all the object functions in python (a desireable
thing IMHO)
- Im interested in doing this and I dont want my time spent to be a
waisted effort so Im interested to see feedback.
- cam