relative and absolute path issue #23726

Closed
opened 2010-09-08 13:12:17 +02:00 by Kalle-Samuli Riihikoski · 9 comments

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

%%%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.%%%
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'

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

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

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Author
Member

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

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

Added subscriber: @SebastianRothlisberger

Added subscriber: @SebastianRothlisberger

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/'
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/' ```

Added subscriber: @brecht

Added subscriber: @brecht

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.

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.

Hmm, this works, thanks. This then simply means i don't understand what i'm doing ;-) Thanks again brecht, have a nice evening.
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#23726
No description provided.