In light of the Coronavirus crisis, please help make sure nothing stands in the way of social distancing in the VFX industry.

This petition asks the MPAA to act accordingly:


Sign the petition on Change.org

Be safe, everyone.

Fuscript keeps telling me 'resolve is None'. Why?

User avatar
maarten
Posts: 27
Joined: Sun Dec 15, 2019 9:17 am

Fuscript keeps telling me 'resolve is None'. Why?

#1

Post by maarten » Mon Mar 23, 2020 1:49 pm

Hi Guys,

I am trying to find out how to get Python scripts to work with fuscript.exe to use in DaVinci Resolve 16 Fusion page and found some pieces of information on the internet here and there.

What I did: Python 3.6.8 is installed (64 bits, Window 10), I changed the windows PATH environment variable to always find fuscript.exe, and added the environment variables like this:
paths.jpg

I try to run this basic script:

Code: Select all

import imp
lib = 'C:\\Program Files\\Blackmagic Design\\DaVinci Resolve\\fusionscript.dll'
dvr_script = imp.load_dynamic('fusionscript', lib)
 
# Create the instances you need...
resolve = dvr_script.scriptapp('Resolve')
fusion   = dvr_script.scriptapp('Fusion')

projectManager = resolve.GetProjectManager()
projectManager.CreateProject("Hello World")
When I run this script inside the console of DaVinci Resolve it works without any problem. ([Edit: Well, if I execute the lines one by one that is, if I drop in a python file on the console it doesn't]) But when I run this script with fuscript (both the interactive mode with -i and loading a file, both with 'l py3' ofcoarse to tell fuscript I'm using python3) it doesn't work as the content of the 'resolve' variable is 'None'. So expect for some reason there is no connection between fuscript and Resolve/Fusion, but can't figure out why.

I understand I got to have DaVinci Resolve running while executing the script, and so it's always open. I also have an active project open in the software which is saved. But it doesn't work when running the script with fuscript instead of the internal console.

I am using DaVinci Resolve STUDIO 16.2, so not the free version. So that is not the issue. What I don't understand though is that I've seen some people here and on the Blackmagic forum telling there is some setting that can be set to 'Local' or other (remote?), but wherever I look in my settings, I can't find any setting like this, so I'm not sure if this could be the issue. Also that setting should also be the one, according to what I find on forums, where we can enable or disable (external?) script execution. So I think it's hard to believe this setting is gone in v16 and wonder where it is now?

Also, eventhough Python 3.6.8 is installed and python 3 scripts run fine in the console, the Fusion settings have both Python version option buttons grayed out and python 2 selected, eventhough I only have python 3 installed, not version 2. I don't understand why they are grayed out, especially because the wrong version is selected (and what's the use of this selection anyway, as we can switch the version in the console?)
grayed.jpg

Also I understand by what I found on forums that the connection between fuscript and Resolve/Fusion goes by internal network (127.0.0.1 / localhost). So I switched off my firewall and security for a while to test. But that didn't help either. Also example scripts I found don't work with fuscript, but do with the internal console.

I'm having a lot of programming experience, but little on the Python system and never scripted for Resolve/Fusion as you can tell, so I have to take this hurdle now to start. I do want to use Python though, as I am familiar with the language, also use it with Blender and don't want to switch to another language like lua.

So the questions I have right now:
1) If the scripts run fine in the internal console, does it mean I can be sure the environment variables are set right? Or does the internal interpreter ignore these? Are the environment variables as set now right?
2) Where in v16.2 is the setting to turn on/off scripting and/or put it to local/external?
3) Why are the python option-buttons grayed out in the Fusion settings? And is the wrong version selected?
4) But the main question: Why is the same script working with the internal console, but not with fuscript.exe? What do I need to do to make this work?


Hope anybody here could help me with this step, as there doesn't seem to be much information out there for Python users.
Thanks in advance!!

BTW it's crazy there is so little information on this from Blackmagic Design. Thank god you guys have all these amazing information on this forum. At least 90% of what I needed to know came from this forum. Thanks for that!
You do not have the required permissions to view the files attached to this post.

User avatar
maarten
Posts: 27
Joined: Sun Dec 15, 2019 9:17 am

Re: Fuscript keeps telling me 'resolve is None'. Why?

#2

Post by maarten » Tue Mar 24, 2020 2:03 am

Ah, FINALLY!! found the 'External Scripting' switch in the settings!! When set to 'Network' everything works now!! :)

Crazy how I have looked everywhere in all settings several times now, but overlooked this one.

For future reference in case other people bump into this and have the same problem: it's in DaVinci Resolve menu --> Preferences --> General --> Switch 'External scripting Using' to 'Network'
external-scripting.jpg

So scripts run now. Yah!

Still not sure why the Python version switches are grayed out though.
You do not have the required permissions to view the files attached to this post.

User avatar
PeterLoveday
Fusioneer
Posts: 189
Joined: Sun Sep 14, 2014 6:09 pm
Answers: 6
Been thanked: 7 times

Re: Fuscript keeps telling me 'resolve is None'. Why?

#3

Post by PeterLoveday » Tue Mar 24, 2020 4:58 am

Setting that to "Local" should have been sufficient to run scripts, well, locally. Was that not the case for you? Or did you have it to "None" ?

User avatar
maarten
Posts: 27
Joined: Sun Dec 15, 2019 9:17 am

Re: Fuscript keeps telling me 'resolve is None'. Why?

#4

Post by maarten » Tue Mar 24, 2020 8:43 am

PeterLoveday wrote:
Tue Mar 24, 2020 4:58 am
Setting that to "Local" should have been sufficient to run scripts, well, locally. Was that not the case for you? Or did you have it to "None" ?
You're right. 'Local' also works. So it must have been on 'None' before when it didn't work. Thanks for this addition.

Do you perhaps also know why both Python versions are grayed out in the Fusion settings (see my initial post)?