Problem loading bmd in python

User avatar
ziggx
Posts: 31
Joined: Tue Dec 30, 2014 10:26 am

Problem loading bmd in python

#1

Post by ziggx » Mon Aug 19, 2019 6:50 am

Hi there,

I'm trying to access fusion with an external script. Following the Andrew Hazelden's opost about this topic, I have tried

Code: Select all

python -c 'help("modules BlackmagicFusion")'
This is what I get in response:

BlackmagicFusion
2019-08-19 14:43:41.072 Python[3060:339139] Cannot find executable for CFBundle 0x7fe5464cd3e0 </System/Library/Frameworks/Message.framework> (not loaded)


I am on OS X 10.14.6 with python 2.7 - can anyone tell me where I'm going wrong?
TIA
Ziggx

User avatar
AndrewHazelden
Fusionator
Posts: 1310
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 2
Location: West Dover, Nova Scotia, Canada
Been thanked: 38 times
Contact:

Re: Problem loading bmd in python

#2

Post by AndrewHazelden » Mon Aug 19, 2019 7:33 am

ziggx wrote:
Mon Aug 19, 2019 6:50 am
I am on OS X 10.14.6 with python 2.7 - can anyone tell me where I'm going wrong?

Hi @Ziggx.

Note: You need to use Fusion Studio or Resolve Studio in order to have external scripting support. The free versions of Resolve 15/16 and Fusion 9 (free) don't provide scripting acesss from a command prompt/terminal session.

Are you running a version of Python supplied natively by macOS, or are you using a build of Python provided by an external package manager like Homebrew, Fink, or MacPorts?

You can check if a macOS provided version of Python, or an external version of Python is in use by running a command like this in your terminal:
Code: [Select all] [Expand/Collapse] [Download] (CheckPython.bsh)
  1. ls -l /usr/local/bin/python

If you have Homebrew in use you would probably see something like this printed in the terminal as a result:
Code: [Select all] [Expand/Collapse] [Download] (TerminalResult.bsh)
  1. lrwxr-xr-x  1 wsl  admin  36 Apr  7 18:37 /usr/local/bin/python -> ../Cellar/python@2/2.7.16/bin/python


What do you get back if you run the built-in version of Python in the Terminal window?
Code: [Select all] [Expand/Collapse] [Download] (CheckBMDmodule.bsh)
  1. /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c 'help("BlackmagicFusion")'


I see this as the result on my system:

Python FusionScript.png
You do not have the required permissions to view the files attached to this post.

User avatar
ziggx
Posts: 31
Joined: Tue Dec 30, 2014 10:26 am

Re: Problem loading bmd in python

#3

Post by ziggx » Mon Aug 19, 2019 7:45 am

Hi Andrew,

I'm using the built in mac python 2.7 - when i run your CheckBMDmodule, I get the same output as you. But how do i access fusion with an external python script?

Best wishes
Ziggx

User avatar
AndrewHazelden
Fusionator
Posts: 1310
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 2
Location: West Dover, Nova Scotia, Canada
Been thanked: 38 times
Contact:

Re: Problem loading bmd in python

#4

Post by AndrewHazelden » Mon Aug 19, 2019 8:29 am

For my needs I typically use the FuScript approach to launching Lua and Python scripts externally. But that's due to me using primarily Lua in Fusion. FuScript is great and it works well with BBEdit. :)

You should be able to use this code in a terminal session to connect to the active Fusion Standalone/Resolve Fusion composite:
Code: [Select all] [Expand/Collapse] [Download] (PythonGetAttrs.bsh)
  1. /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c 'from pprint import pprint;import BlackmagicFusion as bmd;fusion = bmd.scriptapp("Fusion");pprint(fusion.GetAttrs())'
You are likely to get some extra warning messages in the macOS Terminal window with Fusion/Resolve Fusion 16 and python.

Screenshot

Resolve Python Session From Terminal.png
You do not have the required permissions to view the files attached to this post.

User avatar
ziggx
Posts: 31
Joined: Tue Dec 30, 2014 10:26 am

Re: Problem loading bmd in python

#5

Post by ziggx » Mon Aug 19, 2019 9:22 am

Thanks Andrew

So I can use that invocation of python to run a python script. That's cool!. Now to see if I can use this to batch process a bunch of comps and change the saver path...

Best
Ziggx

User avatar
AndrewHazelden
Fusionator
Posts: 1310
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 2
Location: West Dover, Nova Scotia, Canada
Been thanked: 38 times
Contact:

Re: Problem loading bmd in python

#6

Post by AndrewHazelden » Mon Aug 19, 2019 11:33 am

ziggx wrote:
Mon Aug 19, 2019 9:22 am
Now to see if I can use this to batch process a bunch of comps and change the saver path...
I noticed you started a WSL thread back in 2017 about trying to use events and callbacks in Fusion 8:

Event suite not available
viewtopic.php?f=6&t=1281

If you look on the WSL UI Manager thread there are some posts that cover tapping into actions and events in Fusion 9+ via .fu files. That approach could let you do some of your comp adjustments on the fly when certain actions occur - like new renders being started/stopped, comps opening/saving, nodes being added, etc...

User avatar
ziggx
Posts: 31
Joined: Tue Dec 30, 2014 10:26 am

Re: Problem loading bmd in python

#7

Post by ziggx » Thu Aug 22, 2019 12:00 am

Thanks Andrew,

I think that is the way to go.

Best wishes
Ziggx