[Bf-python] memo + new MetaBall
guignot
guignot at wanadoo.fr
Wed May 21 03:07:19 CEST 2003
hi !
This short memo concerns the homogeneity of the interface.
The python API gives user access to most of the internals of Blender.
To access a data, the user will have two functions :
objid->getData()
objid->setData( value)
For instance, in the module Camera, we access the ClipStart value with
the functions :
cam_id->getClipStart()
and cam_id->setClipStart(value)
The function get data returns an error if the identifier does not
correspond to a valid C object (typically an instance of a class) or if
the syntax of the call is not correct.
If everything is allright, it will of course return the data (maybe a
list containing the data for vectors or coordinates )
The function setdata returns an error for the same reasons and the data
in case of success (NOT PyNone, returning the data allows the user to
perform a security check)
(for vectors or coordinates, we can use (Python point of view) set(list)
or set(val1,val2,val3). Or both. I choosed the latter but it can be
easily changed.
Access to compound data :
So far, so good...
Many classes have lists of hmmm... things...
To access these data, two possibilities :
we can use : obid->getTypeObjectData1nameData2name(position)
or : obid->getTypeObjectData1name(Data2name,position)
A little example with the MetaBall module.
The MetaBall class contains a list of Metaelem, which are the balls of
the metaball.
These Metaelems contain 17 fields, for instance the fields
'rad',rad2','x','y','z'
The access to the field 'x' of the third metaelem of the metaball mb can
be granted with
mb->getMetaElemx(2) (2 because begins at 0)
or by mb->getMetaElem('x',2)
Same thing for set.
The new MetaBall implements both possibilities.
What's your opinion :
a) implement both
b) implement first only
c) implement second only ?
d) implement another one ?
If you feel concerned by these issues, please answer asap, the longer we
wait, the more code will have to be modified to follow the guidelines...
jms : what do you mean by "implement Alt-C "? convert MBall to Mesh ?
Why not, if you think it's useful.
-->Willian : tried to follow nan cod. guidelines! but 80cols is WAY TOO
SHORT!!!!!!!!!!!!!!!!!!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mball2.tgz
Type: application/octet-stream
Size: 5264 bytes
Desc: not available
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20030521/faaab1d2/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: testMB.py
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20030521/faaab1d2/attachment.ksh>
More information about the Bf-python
mailing list