Jump to: Board index » General » Fusion

Script To Insert Macro

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

Nick Verlinden

  • Posts: 135
  • Joined: Wed Aug 12, 2015 11:08 am

Script To Insert Macro

PostSun Jun 17, 2018 3:52 pm

Hi,

Is it possible to insert a Macro after a specific tool from a script? For instance, If I do a comp:FindTool("Blur1"), can I insert a custom Macro after that (Like when you would right click the node and choose "Insert Tool > Macros > [macro name here]"? I have looked through the documentation and googled quite a while but can't seem to find the answer. Any help would be greatly appreciated!

Kind regards,
Nick
macOS 10.13.2 High Sierra
Core i9 7920X, 32GB RAM
GTX 1080 Ti 11GB
Blackmagic DeckLink Mini Monitor 4K
Blackmagic URSA Mini Pro
Blackmagic Pocket Cinema Camera
Blackmagic DaVinci Resolve Studio 15
Offline
User avatar

Andrew Hazelden

  • Posts: 191
  • Joined: Sat Dec 06, 2014 12:10 pm
  • Location: West Dover, Nova Scotia, Canada

Re: Script To Insert Macro

PostSun Jun 17, 2018 8:00 pm

Nick Verlinden wrote:I have looked through the documentation and googled quite a while but can't seem to find the answer. Any help would be greatly appreciated!


Hi Nick.

I wrote a new tutorial on the Steakunderwater website today that explores several different ways to use Lua scripting to add a macro node to a comp and connect it to the currently selected node:

Using a Script to Add Macros to a Comp
https://www.steakunderwater.com/wesuckl ... 822#p17822
MacBook Pro 15-inch Mid 2015|2.8 GHz 4 Core i7|16GB RAM|AMD R9 M370X 2GB|Mac 10.13.4|Fu Studio 9.02|Resolve 15.1|KartaVR 4
11xSupermicro 2042G-6RF Render Nodes|4xAMD G34 6276 CPUs@16 Cores|AMD GPU|Ubuntu 14.04 LTS|Fu Render Node 9.02|KartaVR 4
Offline

Nick Verlinden

  • Posts: 135
  • Joined: Wed Aug 12, 2015 11:08 am

Re: Script To Insert Macro

PostMon Jun 18, 2018 11:12 am

Hi Andrew,

Wow, that is exacty ywhat I need, thank you for taking the time to research and write this. I have implemented this in a script to automatically add a macro to the fusion comp of all clips on a specific video track in DaVinci resovle beta 15. Once I fine tuned it a little, I will check out how to publish it to Reactor. I hope that in one of the net betas a new API function is available to get the selected clips on a timeline, this way the macro can be adapted to apply to the selected clips.

I'm just currently looking at a way to detect if the macro has already been inserted, so that it does not get inserted twice when recalling the script when clips are added to a video track. I think the best way would probably be, parse the filename of the macro, remove the spaces and add 1 to the end of the name.

Kind Regards,
Nick
macOS 10.13.2 High Sierra
Core i9 7920X, 32GB RAM
GTX 1080 Ti 11GB
Blackmagic DeckLink Mini Monitor 4K
Blackmagic URSA Mini Pro
Blackmagic Pocket Cinema Camera
Blackmagic DaVinci Resolve Studio 15
Offline
User avatar

Andrew Hazelden

  • Posts: 191
  • Joined: Sat Dec 06, 2014 12:10 pm
  • Location: West Dover, Nova Scotia, Canada

Re: Script To Insert Macro

PostMon Jun 18, 2018 11:49 am

Nick Verlinden wrote:I'm just currently looking at a way to detect if the macro has already been inserted, so that it does not get inserted twice when recalling the script when clips are added to a video track.


The following code scans the current Fusion comp to look for all of the GroupOperator and MacroOperator node RegIDs. Then it looks up their node names:

Code: Select all
--[[--
Scan comp for macro nodes - 1.0 2018-06-18
By Andrew Hazelden <andrew@andrewhazelden.com>
--]]--

-- Should only the currently selected nodes be displayed
local showSelected = false

print('[Listing Macros]')

-- List the macros that are stored as groups
print('\n[GroupOperator Based Macros]')
local toollist1 = comp:GetToolList(showSelected, 'GroupOperator')
for i, tool in ipairs(toollist1) do
   nodeID = tool:GetAttrs().TOOLS_RegID
   nodeName = tool:GetAttrs().TOOLS_Name
   print('\t[' .. nodeName .. ' Macro] ' ..  nodeID)
end

-- List the macros that have their controls exposed but the group expandable option disabled
print('\n[MacroOperator Based Macros]')
local toollist2 = comp:GetToolList(showSelected, 'MacroOperator')
for i, tool in ipairs(toollist2) do
   nodeID = tool:GetAttrs().TOOLS_RegID
   nodeName = tool:GetAttrs().TOOLS_Name
   print('\t[' .. nodeName .. ' Macro] ' ..  nodeID)
end




This gives you an output in the Console that looks like this:

Code: Select all
[Listing Macros]

[GroupOperator Based Macros]
   [Z360Extract Macro] GroupOperator
   [Angular2Equirectangular Macro] GroupOperator
   [MayaBackgroundGradientEquirectangular Macro] GroupOperator
   [Group1 Macro] GroupOperator

[MacroOperator Based Macros]
   [Z360Render_1 Macro] MacroOperator
MacBook Pro 15-inch Mid 2015|2.8 GHz 4 Core i7|16GB RAM|AMD R9 M370X 2GB|Mac 10.13.4|Fu Studio 9.02|Resolve 15.1|KartaVR 4
11xSupermicro 2042G-6RF Render Nodes|4xAMD G34 6276 CPUs@16 Cores|AMD GPU|Ubuntu 14.04 LTS|Fu Render Node 9.02|KartaVR 4
Offline

Nick Verlinden

  • Posts: 135
  • Joined: Wed Aug 12, 2015 11:08 am

Re: Script To Insert Macro

PostWed Jun 20, 2018 8:46 pm

Thanks Andrew, you have been a very big help for me!
macOS 10.13.2 High Sierra
Core i9 7920X, 32GB RAM
GTX 1080 Ti 11GB
Blackmagic DeckLink Mini Monitor 4K
Blackmagic URSA Mini Pro
Blackmagic Pocket Cinema Camera
Blackmagic DaVinci Resolve Studio 15

Return to Fusion

Who is online

Users browsing this forum: No registered users and 5 guests