[Bf-committers] Re: [Bf-blender-cvs] CVS
Curve.c Scene.c matrix.c vector.c vector.h
cbarton at metavr.com
Sat Oct 7 21:02:44 CEST 2006
Tom M wrote:
>> removed some unused vars from Curve and matrix
>> scn.objects.new(None) - adds a new empty
> I'd prefer scn.objects.new(Empty) or such. The above just seems a
> misuse of None and counterintutive
>> - new objects are selected by default now
>> further stripped down the vector struct, the wrapped state was
>> being stored and 2 places.
This issue isnt realy limited to this case, but its a good example of
problems with the python API.
I thaught about a few ways before adding this and they all have their
some requirements are..
1) adding an empty object should be short and something you can memorize
if you use a few times.
2) adding a new object should be well defined - users should not add an
empty in by mistake or as a result of a request for some other data
3) it should be as consistent as possible with the existing operation of
IMHO This reads fairly well, as the only object type with no data, it
fits that None would create an object with no data, where data passed to
.new() would make new objects of their own kind,
its good on #1 ok for #3 and #2 not so well. esp if you define the data
ob_empty = scn.objects.new(None)
The alternative is to use a constant, Im resistant to adding 1 constant
just for this case, which would also make #1 a lot worse
ob_empty = scn.objects.new(Blender.Object.Types.EMPTY) # could of
course remove the Blender.
What you may be suggesting is not a popular soluton from an API
perspective but IMHO easier to use then constants, not so sloppy as
using None, 'Empty' is also the value of ob.getType() so thats no as
hard to remember.
ob_empty = scn.objects.new('Empty')
About constants also, the main reason I still use the Python docs a lot
is to look up constants- say you want to set the fases texface alpha
its something like
face.transp |= Blender.FaceTransp.ALPHA. other face settings are stored
in Blender.Mesh.FaceModes and Blender.Mesh.FaceFlags and it gets
confusing as to whats stored where. - Nothing wrong with having settings
in a constants Dict, but for common operations where there are only a
few options, Id prefer not to be forced to call on a constants dict.
Campbell J Barton
133 Hope Street
Geelong West, Victoria 3218 Australia
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241
More information about the Bf-committers