[Bf-python] Object types as string

Ken Hughes khughes at pacific.edu
Wed Apr 4 21:01:02 CEST 2007


I actually proposed and partially implemented something similar last 
year, before a hard drive crash (no backups, my bad).  It was mainly for 
bitfields, but would have worked on constants also.

http://wiki.blender.org/index.php/BlenderDev/Bitfields

KH

Campbell Barton wrote:
> I like 2 also, just need to work out where we'll store types/constants.
> 
> Martin Poirier wrote:
>> --- Willian Padovani Germano <wgermano at superig.com.br>
>> wrote:
>>
>>> - Ken pointed months ago that he disliked how a user
>>> could write correct scripts using totally wrong constants, because
>>> internally their (int) values were the same. Something like lamp.type =
>>> Mesh.Modes.Twosided, for example. If we use strings instead of ints this
>>> can be prevented easily.
>>
>> This can also be fixed with non-string constants in
>> two different ways:
>>
>> 1- If constants are numeric, use an artificial number
>> instead of the internal constant and do the conversion
>> in BPy (then, parameters that accept constants can
>> check against specific constants vs specific values).
>>
>> 2- If constants are instances of an opaque Py types
>> (could even be an empty type), check against the
>> Python ID internally (the instance could have a
>> non-python accessible param that corresponds to its
>> numeric value). These instances could implement
>> __str__ and __repr__ for ease of use/debugging.
>>
>> Of those two, I prefer solution 2 because it opens the
>> door to abstracting the constant type (float, int,
>> ...) and doesn't have all the clunkiness of string
>> constants
>>
>> Martin
>>
>>
>>  
>> ____________________________________________________________________________________ 
>>
>> Finding fabulous fares is fun.  Let Yahoo! FareChase search your 
>> favorite travel sites to find flight and hotel bargains.
>> http://farechase.yahoo.com/promo-generic-14795097
>> _______________________________________________
>> Bf-python mailing list
>> Bf-python at projects.blender.org
>> http://projects.blender.org/mailman/listinfo/bf-python
>>
> 
> 


-- 
Prof Ken Hughes
Electrical and Computer Engr
University of the Pacific



More information about the Bf-python mailing list