deric / DaVinciResolve-API-Docs

57 stars 10 forks source link

Where do enviroment variable live? #1

Open Goldthing opened 3 years ago

Goldthing commented 3 years ago

Hi, First thank you for taking the time to make this helpful resource. The big thing missing from all the documentation I have found is where in OSX do the enviroment variable live? I have been trying unsucessfully to make them persistent. The only reliable method to get scripts working that I've found so far is to import sys then use sys.path.append() directly at the start of a script. Obviously this is not persistent, but at least it works. Any help in this would be much appreciated.

deric commented 3 years ago

I guess I'd have to see some code, in order to help. I've tried using DaVinciResolve from Python and after several desperate attempts I ended up rewriting the whole thing into Lua which appears to be more consistent.

IgorRidanovic commented 3 years ago

https://support.apple.com/guide/terminal/use-environment-variables-apd382cc5fa-4f58-4449-b20a-41c53c006f8f/mac

Goldthing commented 3 years ago

Thanks for taking the time to reply, while setting the enviroment variables works for scripts called from outside Resolve using terminal it doesn't appear to work for any being called from within (i.e. located in the Fusion/Scripts/Comp folder). Unfortunatley I've still been completely unable to get this persistent, but I do have a workaround which has proved stable and working across V16 and V17 both Studio and regaular so far. For anyone stumbling on this thread here is my default starting template. @deric if you wish to include this in the main wiki please feel free to.

import sys

# some setup is required before we can start importing from Resolve
if sys.platform.startswith("darwin"):
    sys.path.append("/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Examples")
    sys.path.append("/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules")
else:
    print("Platform specific sys path not yet implemented")

from python_get_resolve import GetResolve

# Setup all the Resolve objects we'll need
resolve = app.GetResolve()      # No idea where 'app' comes from, but it works!
pm = resolve.GetProjectManager()
project = pm.GetCurrentProject()