pythonpathabsolute-pathnuke

python convert path to absolute in nuke


I have a filepath that is something like

relPath = '../assets/image_sequences/scan/SPA_0180_scan.1082.exr'

I am reading it within an app (Nuke in my case) and I need to convert it to an absolute path. The problem is that when I use os.path.realpath(relPath) or any other conversion to absolute, it completes the parent folders as if it was the application's files

/Applications/Nuke12.2v3/Nuke12.2v3.app/Contents/

rather than the script where I am working

script_folder = nuke.script_directory() #/Users/ale/Documents/YEOA/folder_structure/SPA_0180/scripts

I also tried using join, but I get the '../' in the middle of the connection point.

Is there a way to pass an argument to the absolute path, with the starting point to be the script rather than the app?

Thanks!


Solution

  • I found it!!

    os.path.normpath(os.path.join(nuke.script_directory(), relPath))