[Bf-python] comments on writing an exporter

Willian Padovani Germano wgermano at ig.com.br
Thu May 29 06:03:12 CEST 2003


Hi, Peter

On Wed, 2003-05-28 at 05:25, Peter Amstutz wrote:
(...)
> These only apply to 2.26, so please tell me if something has/has not
> changed in 2.27:
The Blender Python API in 2.25, 2.26 and 2.27 is the same, no change. 
We refer to it as bpython or 2.25.  The new implementation we're working
on is exppython, not usable yet, but already with more modules and
features.

> * There is no way to access texture data.
Yes, I had problems with that, too.  That's why in exppython the Image
module has both attributes: the name (as seen on the Image Window in
Blender) and the complete filename are there.

> * No file dialog for getting a filename from the user.  I understand this
> has already been fixed?  I'd also like to be able to prompt for arbitrary
> text and/or numerical entry.
Draw has widgets for text/number entry.  BGL, the OpenGL wrapper is also
available.  Both the old and new implementations have them.  About the
file selector, yes, it's back. Now in the Window module in exppython.

> * To export the camera orientation I am calling obj.getMatrix() on the
> camera object.  This matrix seems to be garbage, as the exported
> orientation simply does not match up with the way the camera was oriented
> in blender.
Blender script writers suffer! ; ), you've mentioned exactly the three
problems I had, the texture filenames, the file selector (had to write
my own with BGL and Draw) and the .matrix attribute.

I just checked the current matrix (btw, it's an Object attribute,
relating to all data objects, like mesh, camera, lamp, etc.).  Seems to
be working fine, though it spits some weird zeroes, things like
2.788543254-07, sort of.  Better round matrix values in your script.

>From what I remember, the trouble in understanding the matrix was
because Blender increases angles clockwise.  So to confirm "on paper",
stick a minus sign there (remembering this affects only the sin: sin(-x)
= -sin(x); cos(-x) = cos(x)) and things should eventually make sense.

> * Is there a way to find out how a texture is applied to a polygon other
> than in terms UV coordinates?  I would like to support all the various
> ways of applying textures supported by blender but to do so I need to get
> the raw texture matrix from blender.
Not yet, as far as I know.  That'll change when module Texture gets
done, it wasn't part of bpython, though some work had been done towards
it.

> * From a convenience point of view, I'd like to be able to bind the python
> script to a menu item so that I don't need to open the text editor and
> type alt-p every time in order to run the export script.j
That's the plan.  Getting to the point where to the user it doesn't
matter whether some blender functionality was done in C or Python.  But
this will come later, not in Blender 2.28.

> Overall I have found the Python API to be fairly reasonable (once I
> figured out how to do what I needed) and I'm very glad to be using Blender
> - -- there's just a few things that need to happen before using my export
> script is seamless :-)
Fine : ).  Yes, the API is good indeed, it just needed people working to
fix, update and extend it.  BTW, later (think a few months from now)
we'll also consider cleaning the API, so script writers will obviously
be important in the discussion.

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list