Scripting in the free version?

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline

julian_b

  • Posts: 236
  • Joined: Sun Jan 22, 2017 1:45 pm
  • Real Name: Julian Böhme

Scripting in the free version?

PostFri May 08, 2020 9:45 pm

I have read in the forums by BMD staff that in the free version, you should be able to run scripts from the "Scripts" menu.
But when I do that, all I get is the message that resolve object was a NoneType:

Code: Select all
AttributeError: 'NoneType' object has no attribute 'OpenPage'

Here's the script I'm trying to run:
Code: Select all
from python_get_resolve import GetResolve
resolve = GetResolve()
resolve.OpenPage("Edit")


It's placed in the folder
Code: Select all
DaVinci Resolve\Support\Fusion\Scripts\Comp

The python_get_resolve.py file is located in the same folder.

The script is listed in the Script menu and dragging and dropping it from the explorer onto the Resolve console gives me the same result.

Edit:
Scripting works when I use
Code: Select all
app.GetResolve()


The questions is now:
Is that something we are not supposed to do and they might remove it?
What's the official word on the use of that variable?
I mean: Does that mean scripting is officially supported in the free version?
Or is it not and this is just a bug they will fix?

I would really appreciate some clear guidance and documentation by BMD on scripting in Resolve.

I think it would be very beneficial to allow scripting in the free version. We'll get many more scripts that way.
Heck, I'd be writing scripts for Nuke if they allowed it in the free version.
Last edited by julian_b on Sat May 09, 2020 12:49 pm, edited 5 times in total.
Offline
User avatar

roger.magnusson

  • Posts: 3398
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Scripting in the free version?

PostFri May 08, 2020 10:03 pm

They say it should work but it never has worked when using methods that connect to the application instance. Instead I use the undocumented "app" variable available in the scripting environment. It is a reference to the existing Fusion application instance. From there you can get a reference to Resolve as well: app.GetResolve()

This works in Lua, and as the variable is available in Python as well, I assume it will work there too.
Offline

julian_b

  • Posts: 236
  • Joined: Sun Jan 22, 2017 1:45 pm
  • Real Name: Julian Böhme

Re: Scripting in the free version?

PostSat May 09, 2020 12:44 pm

roger.magnusson wrote:They say it should work but it never has worked when using methods that connect to the application instance. Instead I use the undocumented "app" variable available in the scripting environment. It is a reference to the existing Fusion application instance. From there you can get a reference to Resolve as well: app.GetResolve()

This works in Lua, and as the variable is available in Python as well, I assume it will work there too.


THANK YOU! It's working!
That's awesome! Got my first script running!

The questions is now:
Is that something we are not supposed to do and they might remove it?
What's the official word on the use of that variable?
I mean: Does that mean scripting is officially supported in the free version?
Or is it not and this is just a bug they will fix?
Offline
User avatar

roger.magnusson

  • Posts: 3398
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Scripting in the free version?

PostSat May 09, 2020 1:57 pm

The only thing that isn't supported in the free version is running a script "outside" the running application, from the operating system command line using the fuscript application or external Python interpreter. This is usually used for automation between applications in larger workflows.

But I agree it's confusing since no script in the Scripts menu will work properly in the free version unless you use the existing connection via "app". Official word from BMD in a response here on the forum is that it works without using "app" (but, again, it doesn't).
Offline

Shrinivas Ramani

Blackmagic Design

  • Posts: 2729
  • Joined: Wed Sep 20, 2017 10:19 am

Re: Scripting in the free version?

PostSat May 09, 2020 4:19 pm

Roger, Julian,

Are you saying that this script works in Studio but does not in Free when invoked from the Scripts menu or executed in the console?
Code: Select all
from python_get_resolve import GetResolve
resolve = GetResolve()
resolve.OpenPage("Edit")

If not, would you provide me a snippet that does not work in Free?
Regards
Shrinivas
Offline

julian_b

  • Posts: 236
  • Joined: Sun Jan 22, 2017 1:45 pm
  • Real Name: Julian Böhme

Re: Scripting in the free version?

PostSat May 09, 2020 4:28 pm

Shrinivas Ramani wrote:Roger, Julian,

Are you saying that this script works in Studio but does not in Free when invoked from the Scripts menu or executed in the console?
Code: Select all
from python_get_resolve import GetResolve
resolve = GetResolve()
resolve.OpenPage("Edit")

If not, would you provide me a snippet that does not work in Free?
Regards
Shrinivas


Thank you so much for answering, because it is really important for me clear up what's supported and what's not and to get scripting to work.
And the fact that scripts are supported in the free version is just phenomenal! I'm thrilled!

This does not work in the free version:
Code: Select all
from python_get_resolve import GetResolve
resolve = GetResolve()
resolve.OpenPage("Edit")


The python_get_resolve.py file is in the same folder.
Dragging the script onto the Resolve console to execute it, results in the same error message.

This does work in the free version:
Code: Select all
from python_get_resolve import GetResolve
resolve = app.GetResolve()
resolve.OpenPage("Edit")


I've got a demo for you:
https://drive.google.com/open?id=1Dc9WY ... MR0XvwkTCU
Offline
User avatar

roger.magnusson

  • Posts: 3398
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Scripting in the free version?

PostSat May 09, 2020 6:46 pm

I need to point out that my experience is with Lua. In Lua we don't load an equivalent to the DaVinciResolveScript module. Maybe that module makes it work in Python. Doesn't work for Lua though. Any time you make a new connection to a scriptapp (via Fusion() or Resolve()) it won't work in the free version except when typed directly into the console. The only time I've got saved scripts working is when I reuse the existing connection via app. That makes sense to me given the limitation of the free version. But it's puzzling if Shrinivas has it working.

Julian, in your example, is python_get_resolve.py located in the same folder as the script? It's usually in the Examples folder and won't be found by the environment variables suggested in the API readme if your script is located somewhere else.
Offline

Tom Early

  • Posts: 2687
  • Joined: Wed Jul 17, 2013 11:01 am

Re: Scripting in the free version?

PostSun May 10, 2020 1:17 am

Shrinivas Ramani wrote:Roger, Julian,

Are you saying that this script works in Studio but does not in Free when invoked from the Scripts menu or executed in the console?
Code: Select all
from python_get_resolve import GetResolve
resolve = GetResolve()
resolve.OpenPage("Edit")

If not, would you provide me a snippet that does not work in Free?
Regards
Shrinivas


I can't get this work, nor using app.GetResolve, and I've checked the location of python_get_resolve. In fact I've never got any script to work, though I haven't tried much.
MBP2021 M1 Max 64GB, macOS 14.4, Resolve Studio 18.6.6 build 7
Output: UltraStudio 4K Mini, Desktop Video 12.7
Offline

julian_b

  • Posts: 236
  • Joined: Sun Jan 22, 2017 1:45 pm
  • Real Name: Julian Böhme

Re: Scripting in the free version?

PostSun May 10, 2020 2:35 pm

Tom Early wrote:
Shrinivas Ramani wrote:Roger, Julian,

Are you saying that this script works in Studio but does not in Free when invoked from the Scripts menu or executed in the console?
Code: Select all
from python_get_resolve import GetResolve
resolve = GetResolve()
resolve.OpenPage("Edit")

If not, would you provide me a snippet that does not work in Free?
Regards
Shrinivas


I can't get this work, nor using app.GetResolve, and I've checked the location of python_get_resolve. In fact I've never got any script to work, though I haven't tried much.


Did you try to run it from outside of Resolve?
Or did you do it like in my demo above?
Offline

Tom Early

  • Posts: 2687
  • Joined: Wed Jul 17, 2013 11:01 am

Re: Scripting in the free version?

PostSun May 10, 2020 4:47 pm

Julian Böhme wrote:Did you try to run it from outside of Resolve?
Or did you do it like in my demo above?


I wouldn't know how to run it from outside Resolve. I've had a look at the Readme document and what it says there about how to do so means absolutely nothing to me.

I have now got the script to work as per your video:

1. I noticed that you have python3 selected in the console. I don't have it so I downloaded the latest version, 3.8, because Resolve complained that it couldn't find python 3.6 installed (and I thought installing 3.8 would be fine).

2. Resolve still complained about not having Python 3.6, so I installed 3.6.8. (And yes, I did run the install SSL certificates program)

3. Somehow, Resolve STILL complains about python 3.6 not being found. WHAT EXACTLY DO I HAVE TO DO FOR IT TO RECOGNISE MY INSTALLATION?????? :evil: :evil: :evil:

4. Regardless of point 3, if I make a switch.py file like you have done in the video (with the change you make), and if I run it from the script menu, it does actually switch to the Edit page. The first time I've been able to execute a script successfully. But...

5. ...it STILL doesn't work if executed from the console (I've tried having both Lua and Python2 selected, and of course python3 isn't working for me). And none of the example scripts provided by BMD work form the menu or the console either.

Frankly, this situation with scripting just makes my blood boil trying to get it to work. Why the **** should we have to jump through all these hoops to get even BMD's own scripts to work?? It's like asking us to grade video using the command line and hoping we already know the mathematical formulae for lift/gamma/gain!
MBP2021 M1 Max 64GB, macOS 14.4, Resolve Studio 18.6.6 build 7
Output: UltraStudio 4K Mini, Desktop Video 12.7
Offline
User avatar

roger.magnusson

  • Posts: 3398
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Scripting in the free version?

PostSun May 10, 2020 6:09 pm

Julians example won't work from the console unless you have configured the environment variables correctly or have placed the module in the right place.

Environment variables in recent versions of macOS are a real pain. While it's not hard to have them accessible in a terminal window, it's another thing entirely to have them accessible within an application started from the desktop. Once you have it working you will soon realize that they aren't persisting after a reboot.

Maybe I'll throw together a complete guide for Resolve scripting at some point. But I wish we could solve the main question of this thread first.
Offline

Ibrahimjefout

  • Posts: 1
  • Joined: Mon Dec 21, 2020 12:21 pm
  • Real Name: Ibrahim Aljfout

Re: Scripting in the free version?

PostMon Dec 21, 2020 12:29 pm

Hello there, I'm pretty new to scripting and coding in general, and I would like to know how to set up these environmental variables on windows 10.

and also is there a place where I can learn how to script in the free version of dissolve?

I would appreciate any help I can get so Thanks in advance if anyone replies to this
Offline

Terry000

  • Posts: 5
  • Joined: Tue Sep 14, 2021 9:00 am
  • Real Name: Terry Born

Re: Scripting in the free version?

PostThu Sep 16, 2021 3:03 am

resolve = app.GetResolve() doesn't work
Offline
User avatar

Igor Riđanović

  • Posts: 1596
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Scripting in the free version?

PostThu Sep 16, 2021 9:43 pm

Resolve instance is prebuilt when you do internal scripting. Try:
Code: Select all
print(resolve)
www.metafide.com - DaVinci Resolve™ Apps
Offline

tiago.matias

  • Posts: 6
  • Joined: Mon Oct 17, 2022 3:28 pm
  • Real Name: Tiago Matias

Re: Scripting in the free version?

PostThu Nov 03, 2022 10:23 am

roger.magnusson wrote:They say it should work but it never has worked when using methods that connect to the application instance. Instead I use the undocumented "app" variable available in the scripting environment. It is a reference to the existing Fusion application instance. From there you can get a reference to Resolve as well: app.GetResolve()

This works in Lua, and as the variable is available in Python as well, I assume it will work there too.


Thank you for this! I lost hours and hours trying to get an external script working on the free version.

Biggest issue still is that the Path's on the developers\Readme.txt are wrong.

Troubleshooting for other users:
  1. DaVinci Resolve (Free) 18 supports python 3.10, contrary to that some parts of the internet say.
  2. The paths on the readme.txt are wrong. You can't use variable substitution like they say, nor enclose the paths in quotes.
  3. Use this app.GetResolve() trick to get the Resolve instance.

In case of panic, open the console, select Py3 and type:

Code: Select all
import sys
print(sys.path)


It will return an array of paths that you must make sure are defined on your environment variables.

These are mine:
Code: Select all
PYTHONPATH=C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\Modules
RESOLVE_SCRIPT_API=C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting
RESOLVE_SCRIPT_LIB=C:\Program Files\Blackmagic Design\DaVinci Resolve\fusionscript.dll



Working example in python 3, Windows, running py 3.10
Code: Select all
#!/usr/bin/env python

def DisplayProjectInfo( project ):
   print("-----------")
   print("Project '" + project.GetName() +"':")
   print("  Framerate " + str(project.GetSetting("timelineFrameRate")))
   print("  Resolution " + project.GetSetting("timelineResolutionWidth") + "x" + project.GetSetting("timelineResolutionHeight"))
   
   return


resolve = app.GetResolve()
fusion = resolve.Fusion()
projectManager = resolve.GetProjectManager()
project = projectManager.GetCurrentProject()

DisplayProjectInfo(project)

Return to DaVinci Resolve

Who is online

Users browsing this forum: jakstra, Navymorgan, panos_mts and 274 guests