[Bf-python] new python development path

Campbell Barton cbarton at metavr.com
Thu Feb 9 22:53:21 CET 2006


IFDEFS would be in the python Module creation code. could use 2 seperate 
directories for all other code, so would not make things hard to read.
would allow development and backporting anything that was needed into 
orange.
People can always keep a slightly older blender building, afterall you 
not SUPPOSED to use CVS for real work :)

I propose we Dont even have Object.Get() since it ignores that objects 
exist within a scene(s). (Many python scripts alredy ignore scenes and 
operate on all Objects, Python scripts not being scene aware is one of 
the reasons I have to check other peoples code before using there scripts.)
Because I have had files messed up that modify objects in non active 
scenes without me knowing.

Instead we should access objects by there scene.
eg.
scn = Scene.GetCurrent()
ob= scn.objects['"MeshOb"] # use getItem for this, scn.objects replaces 
scn.children, dont use word children since its misleading. objects can 
exist in many scenes and have other object parents.
data = ob.data

# Also could do some tricks with scn.objects
del scn.objects['MeshOb'] # instead of unlink
scn.activeObject= ob
ob.data= somedata

for ob in scn.objects: # objects can be an iterator. saves us making a 
big list up front. fits in with linked list well also.
  ...


Removing direct access to objects and data is a bad idea.
What if you make a new object, link a new datablock from a scene? it 
will initialy have no users. and be hard to get at..
I have a mesh library that operates on mesh data by name, porting to a 
new system that couldent operate this way wouuld be hard and counter 
productive.

Library.Open('foobar.blend')
Library.Link('Mesh', 'SomeMesh') # cant recall the syntax...
Library.Close()
# New we need a way to get the mesh, we know what its called and its not 
a part of a scene..
me= Blender.Mesh['SomeMesh'] # probably nobody will like, but dict like 
access from the module could be kind a cool.
me= Blender.Datablocks('Mesh', 'SomeMesh') # Have a datablocks module 
for Get/New.
me= Blender.Mesh.datablocks['SomeMesh'] # something inbetween the 2 
above. iterator acces as described with scn.objects

Options are
1) remove direct name access (not IDeal IMHO)
2) Keep existing access, not ideal either...
3) Somehow make existing access different. Blender.Datablock.Get('Mesh', 
'SomeMesh') - and document that its only to be used when using the 
scene/object/data contexts dont work.
4) Just document how not use use direct access in each direct access.




Toni Alatalo wrote:
> On Thursday 09 February 2006 17:27, Willian Padovani Germano wrote:
>   
>>> sourcearm = Blender.armatures['armature']
>>>       
>> for this we'd need our own special dict type that only accesses data on
>> demand, right? Consider a scene with hundreds of objects, it'd be a
>>     
>
> ['spam'] has nothing to do with dicts, it is just a call to __getitem__(self, 
> name) :)
>
>   
>> Anyway, only with an actual API written somewhere we can go on
>> discussing, we need a general picture.
>>     
>
> yah.
>
>   
>> Willian
>>     
>
> ~Toni
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
>
>   


-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-python mailing list