Page 1 of 1

Scripting - how to start [help needed] - diploma thesis

PostPosted: Sun Mar 21, 2021 3:02 pm
by morkaman
Hello I am student from Slovakia having diploma thesis called "Scripting in DaVinci Resolve Studio". I am intermediate user of DVR but total newbie in Python 3.6 (which I have chosen for scripts in thesis). My only scripting experience is in Adobe using Javascript which comes bit useless.

I am stuck on beginning - making Python 3.6 work with DVR. Let me explain situation:
DVR Studio 17.0 - installed and working
Python 3.6 - installed (default installation route)
Fusion settings → Script → Default Python version 2.7 (option greyed out) - unable to change
Preferences → System → General → External scripting → local

I tried Igor Riđanović way to start - using cmd prompt Python instead of console - which doesn´t work "Python standards" properly as he mentions but I cannot import DaVinciResolveScript - resulting in error.

I think I am stuck on connecting DVR API / library resources (whatever it is called) to Python. As a total newbie I have no idea how to continue.

Anyone could help me by writing step by step tutorial how to make this stuff working? Is it possible to use some IDE like PyCharm for scripting, checking errors (using DVR scripting API) and executing scripts or I have to prepare to work only inside Python Command prompt / DVR console?

Re: Scripting - how to start [help needed] - diploma thesis

PostPosted: Mon Mar 22, 2021 3:03 am
by Shrinivas Ramani
Hi

Can I check two things?
a. was Python 3.6 installed using the installer from python.org?
b. in the help menu, under examples, there is a python_get_resolve.py utility file that can be included in your projects. can you check if you can print(resolve) and query for properties using that script?

The python_get_resolve.py references the Modules/DaVinciResolveScript.py file - both of which have multiple fallbacks for different installation scenarios.

Regards
Shrinivas

Re: Scripting - how to start [help needed] - diploma thesis

PostPosted: Mon Mar 22, 2021 10:45 am
by morkaman
Meanwhile this post was approved I somehow luckily found something that seems to be a solution on some other forum.

If I include
Code: Select all
import imp
lib = r'C:\Program Files\Blackmagic Design\DaVinci Resolve\fusionscript.dll'
dvr_script = imp.load_dynamic('fusionscript', lib)
resolve = dvr_script.scriptapp("Resolve")
fusion = resolve.Fusion()
projectManager = resolve.GetProjectManager()


in the beginning of any Python file, I am able to script. That counts also for DaVinciResolveScript.py - code itself doesn´t work for me, but if I include code uphere at the beginning, it works and returns this:
Code: Select all
C:\Users\MADCAT\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/MADCAT/PycharmProjects/pythonProject/main.py
Resolve (0x00007FF66AEC0950) [App: 'Resolve' on 127.0.0.1, UUID: 9b740213-f197-4bbc-85bd-9e6efcdf4b9c]


I am not sure if this is correct way it should work, but from first testing, it does. Tried to create new project using script, new folder, etc.

Also funny thing to mention, while I was stuck I tried to install Python 2.7 aswell and that thing installed together with Python 3.6 enabled option "Fusion settings → Script → Default Python version 2.7" to be set on Python 3.6. No idea why I can´t just have Python 3.6 and Resolve recognizes it as default, not greying out option to choose it.

PyCharm editor also works using that "hack" code mentioned above.

Anyway I would like to know if this is correct way to continue, including code above in the beginning of every script or it´s just part solution and I will come to some problem using it later on.