[Bf-committers] OOPS in Python

Campbell Barton bf-committers@blender.org
Sat, 07 Aug 2004 03:13:37 +1000


Hi All, I have been tinkering with the OOps for a while now and recently 
had the idea to impliment all the tricky stuff in python while giving 
python accsess to the oops data.

This is more simple then it sounds.

All we need as accsess to the oops x/y coords and weather the data its 
selected or not, blender alredy provides us with the rest.
object alredy have the .sel class var but Im adding it to all other 
datablocks. allong with the oopsloc class var (both can be read and written)

People often say thed like t be able to link materials to objects from 
the oops view (or similar things)
well if we can tell in python what materials are selected by: if 
Material.sel == 1..... then all we need to do is write a script that 
links all the selected materials with the actve object. Viola.
Similar methods could be used to unlink textures. or deleate datablocks 
other then objects.

These scripts could be added to a slot in the oops header menu- there is 
a lot of free space and general scene management scripts coudl be added 
there as well as plugins that manage the relationship between objects 
like the example above.

Other scripts could be made very quickly that:
* Arrange oops boxes into colums and sort an alphabetical order.
* Rename Selected datablocks (Not just objects)
* Modify the relationship of datablocks based on the selection.
* Layout the oops boxes using the objects worlspace X/Y X/Z etc as a basis.
* Better arrange oops boxes.
* Select groups of oops blocks that are clustered together.

so each datablock will have the added class vars (ipo for eg)
ipo.sel
ipo.oopsloc

Tuhopuu2 alredy has these vars for objects and the mesh, if the OOPs 
window is not initialized NONE will return for both these vars, (as 
opposed to crashing)
and the same with new NMesh objects that havent been Put yet.

Try thin in Tuhopuu2, animates a mesh and an object datablock on the 
oops view.


from Blender import *
ob = Object.GetSelected()[0]
m = ob.getData()

print m.oopsloc
print ob.oopsloc

m.sel = 1

for x in range(100):
  Window.Redraw(Window.Types['OOPS'])
  m.oopsloc = (0.2 * x, 0.2 *x )

for x in range(100):
  Window.Redraw(Window.Types['OOPS'])
  ob.oopsloc = (0.2 * x, 0.2 *x )