constructors (Re: [Bf-python] More Proposed API changes.)

Willian Padovani Germano wgermano at superig.com.br
Tue Mar 13 17:01:09 CET 2007


Hi guys,

Again, let's remember what this development is. We are not right now 
developing a new API. For months we waited and discussed and so on and 
finally saw, a few months ago, that it was not time to redo BPy and that 
we actually didn't even have a clue about when the time would come. This 
came from discussions in Sunday meetings, etc., based on plans for 
Blender itself.

So we are updating the current API with nicer, simpler, safer ways to do 
things.

Joseph Gilbert wrote:
(...)
> Why not:
> o = Object(bpy.scenes.active)
> instead of
> bpy.scenes.active.objects.new() ?

The problem here is that BPy uses Object, Mesh, Lamp, etc. etc. as 
module names. Making them become constructors would break everything. 
And using Object.Object(), Mesh.Mesh(), etc. is not that friendly at all 
and it's just adding aliases (Mesh() vs. New()) to our old way of doing 
things.

We could then put the constructors in the new bpy module: bpy.object(), 
bpy.mesh(), etc. But "object", "mesh" and so on are very common var 
names used in lots of scripts out there. Upper case wouldn't work 
either, because of the problem with module names, again.

I'm not ruling out anything, just pointing some problems. If someone has 
a better suggestion than bpy.meshes.new() and so on, we still have time 
to reconsider it. We also disliked adding things to iterators, but it's 
at least easy to work with and it's there in case we don't have 
something better.

One of the alternatives considered (updated here to use the bpy module) 
was addXXX(): bpy.addObject(), bpy.addMesh(), etc., but this doesn't 
look that nice either.

-- 
Willian



More information about the Bf-python mailing list