[Bf-python] Extending python

Campbell Barton cbarton at metavr.com
Sun Aug 22 07:09:36 CEST 2004


Hi All, Matt- I like your naming convention, I dont think theres any 
resion to be Picky with this-

There are some issues with Intergrating Python into blender, mainly to 
do with file i/o
1)
I added the getMatrix('worldspace'), this is good for getting the 
absolute matrix but you still have to pass each vert through the Matrix- 
this takes up processor time and  adds unneeded functions to apply a 
patrix to X/Y/Z

I think ||NMesh.GetRawFromObject| 
<cid:part1.03090900.01080701 at metavr.com>(name)
could be modified to include the optional parm.
|||NMesh.GetRawFromObject| 
<cid:part1.03090900.01080701 at metavr.com>(name, 'worldspace')

Then the vert coords and normals could be exported as is without any 
processing of there locations and the speed of exporters would improve.

2) - More Python functions that wrap BpyFunctions ()
These need to be distributed with blender so the Coder can rely on them 
being there- They should also be documented in the EpyDocs.
Could be Called BPyWrapper...
EG
from BPyWrapper import BPyMaterial, BPyNMesh.... etc

resions for wrapping some functions are that somtimes its nicer if error 
handling and logic that can be a bit fuzy (fuzzy logic) can be handled 
better py wrappers writtin in Python.

Wrappers that could be written are...

||BPyWrapper.addMaterial(mat) # adds the material to the mesh and 
returns the material index, it the material is alredy on teh mesh then 
just return the index.

||BPyWrapper.getLights() # returns all light objects in the scene, 
||getMeshs would be cool too.|
|



3)
Generic Image Load/Write functions - again for importers and exporters,
The writer of the file I/O can just simply load the image and handle the 
image path.

||BPyWrapper.ImageLoad()|
|* Return an image object, only load if the image is not alredy loaded.
* Handle case mismatch with file names (vert important for importing 
windows files into linux)
* Varying levels of strength for file searching (
  0=None,
  ||1=Return None and raise an error menu
  ||2=Recursively look in all subdirs of the path given as well as the 
existing .blend path
  3=Perform a full search... mabe not, but it could be done.)

* What to do if the image inst found (
  0=Return None,
  1=Return None and raise an error menu,
  2=Ask the user to select the image,
  3=Create a dummy image in the same path is the file asked for)

* If an image is in an unreadable format (
  0=Return None;
  1=Return None and Raise an error menu,
  2=Make a dummy image in a format Blender can read,
  3=Convert the image to a format Blender can read (will require PIL or 
ImageMagick))


4) Import/Export
* Standardize file I/O- Export only Selected?... Names.... re-use any 
error handling and add these functions to the generic BPyWrapper (As I 
have called it but it could be any name)
* Mabe even have a style Guite for naming- Non essential but would make 
it easier to read  other ppls code.
* Have a way to Show the user what Data is Exported.
  eg The exporter name could be modified for this
  Wavefront (.OBJ) : ME|UV|MA
||   Vrml (.WRL) : ME|UV|VCOL|LA|ANI
  ... I think there must be a better way to do this but Im not sure, 
Mabe the extra Info could be stored in the Tooltip.
  ... Multiline tooltips would be good for this.
* Make i/o scripts Regester themselves with Blender so you can use 
Blender.Save() to save files of different formats.
 This would also be very usefull because you could assosiate OBJ files 
with blender for EG
 then you could type
 # blender /home/me/myfile.obj
 .. thsi is non essentual but would be cool.

I can code most of this, certanly the python related stuff.
So Its more a proposal then a request.
- Cam
  || 



. I can code these, just interested in Feedback


||

-- 
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