3
$\begingroup$

I need to get full, absolute path to the image that has been rendered. Unfortunately bpy.path.abspath() returns only the folder path and not the disk. Same with all the other path functions - no disk.

$\endgroup$
  • $\begingroup$ Could it be something like os.path.abspath(os.path.join(bpy.path.abspath("//"), bpy.context.scene.render.filepath)). I'm just no sure of what you get with that function alone. $\endgroup$ – Flavio Aug 11 '14 at 14:14
  • $\begingroup$ Your code appends the D disk to the path (probably because my Blender is running from D) instead of C, to which the render is saved (specifically to C:\tmp\render.png) $\endgroup$ – Val Aug 11 '14 at 14:43
5
$\begingroup$

There's a utility function:

frame_path()
RenderSettings.frame_path(frame=1)
Return the absolute path to the filename to be written for a given frame

scene = bpy.context.scene
path = scene.render.frame_path(scene.frame_current)
| improve this answer | |
$\endgroup$
  • $\begingroup$ Still not 100% correct. For some reason shows me a slightly different file name. My script generates a render filename and then puts it in bpy.context.scene.render.filepath (just before rendering). The name contains a "#" but when I call scene.render.frame_path(scene.frame_current), it changes the "#" to "1" for some reason. But at least, I guess, I can get the folder path (with the disk) and then manually append the filename. Will try that $\endgroup$ – Val Aug 12 '14 at 6:58
  • 2
    $\begingroup$ Blender fills in '#' in the output filename with the frame number that was rendered. To get a specific file you will need to know the frame number that you are after. $\endgroup$ – sambler Aug 12 '14 at 7:05
  • $\begingroup$ I only render one frame at a time (it's not an animation). The "#" has to be there as it is because the images will be later on fed to another application which requires this character in filename $\endgroup$ – Val Aug 12 '14 at 7:18
  • $\begingroup$ OK, I got the absolute folder path from that scene.render.frame_path(scene.frame_current) and then managed to replace the filename with the one I'm generating and now I have the full, correct path! $\endgroup$ – Val Aug 12 '14 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.