Page MenuHome

relative and absolute path issue
Closed, InvalidPublic

Description

Here is a video about the issue:

http://www.vimeo.com/14794857

The problem is that I can't change relative path into absolute path
using os.path.abspath(path) but if I change the filepath from
"//..\\Desktop\\' into '/..\\Desktop\\' then the command os.path.abspath(path)
works. Thanks.

Details

Type
Bug

Event Timeline

the // prefix is a blender only convention
use: bpy.path.abspath()

bpy.path.abspath() dosen't work. I would expect it will give something like c:\tmp\ for example. It dosen't change relative path into absolute.

Abspath is not working on own StringProperty:

I have a String Property as Filepath:

bpy.types.Scene.pg_root = bpy.props.StringProperty(
            name="Root Folder",
            description="Select the Folder containing the Images",
            subtype="DIR_PATH")

When i have relative Path in Preferences - File active, The Filebrowser opens with Relative Path checked.

This results in the StringProperty saved as:

//../../../../Grafiken/Vorlagen/PhotogrammetrySamples/NEW_Munster/

Using Abspath on this gives either:

bpy.path.abspath(bpy.context.scene.pg_root)
'/Volumes/space/BlenderStuff/Python/Own/Photogrammetry/../../../../Grafiken/Vorlagen/PhotogrammetrySamples/NEW_Munster/'

or:

os.path.abspath(bpy.context.scene.pg_root)
'//Grafiken/Vorlagen/PhotogrammetrySamples/NEW_Munster'

removing the first / so the path looks like:

/../../../../Grafiken/Vorlagen/PhotogrammetrySamples/NEW_Munster/

gives this:

bpy.path.abspath(path)
'/../../../../Grafiken/Vorlagen/PhotogrammetrySamples/NEW_Munster/'

I don't see the bug? You probably want to do this:

os.path.abspath(bpy.path.abspath(bpy.context.scene.pg_root))

bpy.path.abspath will replace the // Blender specific prefix, but it will not 'clean' the ..'s from the path.

Hmm, this works, thanks.

This then simply means i don't understand what i'm doing ;-) Thanks again brecht, have a nice evening.