Python export: no texture filenames

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

blackie
Posts: 16
Joined: Mon Apr 28, 2003 5:15 pm

Python export: no texture filenames

Postby blackie » Sat Jul 19, 2003 8:07 pm

Hi,

i have a problem with blender 2.27.
blender does not export the texturefilenames. it does not work when using
the intern vrml exporter ( or dxf, videoscape, but i don't know if they even save it) and it does not work with the python api.

in the c source (exotic.c) texturefilenames are referenced through Mesh::TFace::Image.name

with python you can get the filename with mesh.face.image.name, or similar :wink:

did anybody else experience this problem ?

blackie

badcheese
Posts: 15
Joined: Wed Jul 23, 2003 6:41 pm

Postby badcheese » Wed Jul 23, 2003 8:25 pm

Blender has never exported texture filenames. It only exported texture datablock names. Blender.Image.Get() would return a list of texture datablocks. Those datablocks have a .name attribute which usually looks like a filename, but it isn't. A datablock name like "mytexture.tga" could be using a texture file called "mytexture.jpg" or "foo.bar". By default the datablock gets the name of the file, but there might already be a datablock with that name, in which case the datablock name gets ".001" added to it. This happens if the image datablock gets copied, if the image file gets linked twice, or if images in different directories but with the same filename get linked. The user can also decide to simply rename the image datablock, so the name could have no resemblance to the file name.

In other words the datablock name has no connection with the file name. Even if it did, the name wouldn't tell you the directory where it's located.

We really need the image datablock to have more attributes. We need something like ".filename" or ".imagefile" for the path to the original image file on disk. We also need ".imagedata" or ".imbuf" or something for a buffer with the image data itself. That way we could use PIL to write it to disk in the format supported by the program we export to or we could use BGL to draw it in the script window.

willian
Posts: 20
Joined: Mon Jan 13, 2003 3:50 am

Postby willian » Sat Jul 26, 2003 9:45 pm

Hi,

Blender 2.28 has this feature: Image objects (check the Image module) have a .filename member var and a .getFilename() method to retrieve it, so both

var = my_img.filename
#and
var = my_img.getFilename()

can give you what you want.

--
Willian

blackie
Posts: 16
Joined: Mon Apr 28, 2003 5:15 pm

Postby blackie » Sun Jul 27, 2003 10:24 pm

willian wrote:Hi,

Blender 2.28 has this feature: Image objects (check the Image module) have a .filename member var and a .getFilename() method to retrieve it, so both

var = my_img.filename
#and
var = my_img.getFilename()

can give you what you want.

--
Willian


yes, thanks a lot. in the meantime i figured it out by the new python doc in blender 2.28, but thanks anyway !

now, the blender python api is getting really useable ...


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests