[Bf-python] Extending Blender's Python API: expandpath(), GetAbsolutePath(), Get('scenefile'), Get('scenefiledir'), image.filenameAbsolute
diresu at web.de
Tue Jul 17 06:25:10 CEST 2007
I needed some functionality to get the absolute path of a texture
image - and as I couldn't find anything and nobody responded to my
posting ( http://www.blender.org/forum/viewtopic.php?p=62764#62764 )
I finally implemented my own method:
the scene file is '/home/dietrich/blender/scene/cube.blend'
Today by chance I found the function `Blender.sys.expandpath()'
which more or less does what I want - but not as nice as my
function, as the returned path is not brought into the
canonical form (/.//foo/../bar/./ --> /bar/):
I thought to create a patch with my new function but now don't know
how to proceed...
Different ideas are:
- leave my new function as it is (`Blender.GetAbsolutePath()')
probably not a good idea as there would be two similar functions
at different places
- rename my function to `Blender.sys.expandpathSimplify()'
- put my function into `expandpath()'
- give the function `expandpath()' a second facultative argument
which might be 'raw' or 'simplify' with one of the two the default
- make a third function `simplify()' which could be used to simplify
whatever path there is
- other ideas?
What do you think would be best?
* second question
I implemented two new setting keys usable with Blender.Get() as I
couldn't find anything similar in the documentation:
The first returnes the path of the scenefile, the second its
I this usable for others also and should I make it a patch?
* third question
My first solution to my problem - obtaining the absolute path of an
image - was to implement `image.filenameAbsolute':
with the scene file: '/home/dietrich/blender/scene/cube.blend'
and the image: '//../tex/stone.png'
which would result in the same as:
Is this worth a path? Or should people just use something like the
* a last question
When loading a new image into a texture with:
>>> image.filenameAbsolute = '/home/dietrich/blender/tex/stone.png'
and redrawing the windows with
The image preview window still shows the old image. Only hitting the
[Reload] button on the GUI or reselecting the images in the outliner
etc. redraws the preview window.
Is this a bug? Is there some other redraw function?
Sorry for too many subjects in one mail and thanks for your help :)
More information about the Bf-python