Page 1 of 1

Using ComboControl or MultiButtonControl to alter a formular

PostPosted: Mon Apr 09, 2018 10:30 am
by GarethT
Hi

I'm relatively new to Fusion, and know very little about coding, but always keen to pick up knowledge along the way.

I'm building my own little macro to apply the applicable aspect ratio mask to delivery footage, so I wanted to use the control button or multi button control in a custom tool node to change the formular driving the mask. I have 5 buttons which send the values of 0-4 to the formular. I want to change those default values to specific values, like 1.78, 2.39 etc. I cant seem to figure out how to do it :/

Does anyone know an easy way to do this?

Thanks for your help

Gareth Tredrea

Re: Using ComboControl or MultiButtonControl to alter a form

PostPosted: Mon Apr 09, 2018 7:25 pm
by Sander de Regt
Can you post the in progress macro here? This way we can take a look at the internals to help you better.

Re: Using ComboControl or MultiButtonControl to alter a form

PostPosted: Mon Apr 09, 2018 8:35 pm
by Bryan Ray
There are a couple of ways you could go about it. Here's an example from my custom keyer macro where a ComboControl chooses which image goes to the output:

Code: Select all
{
   Tools = ordered() {
      switch_revFringe = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         NameSet = true,
         Inputs = {
            Mix = Input { Expression = "MADKey_BetaD.OutputControl-9", },
            Background = Input {
               SourceOp = "switch_fringe",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1870, 181.5 } },
      },
      switch_insideMask = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         NameSet = true,
         Inputs = {
            Mix = Input {
               Value = 0,
               Expression = "MADKey_BetaD.OutputControl-4",
            },
            Background = Input {
               SourceOp = "switch_srcAlpha",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1320, 181.5 } },
      },
      switch_outsideMask = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         NameSet = true,
         Inputs = {
            Mix = Input {
               Value = 0,
               Expression = "MADKey_BetaD.OutputControl-5",
            },
            Background = Input {
               SourceOp = "switch_insideMask",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1430, 181.5 } },
      },
      switch_srcAlpha = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         NameSet = true,
         Inputs = {
            Mix = Input {
               Value = 0,
               Expression = "MADKey_BetaD.OutputControl-3",
            },
            Background = Input {
               SourceOp = "switch_source",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1182.5, 181.5 } },
      },
      switch_status = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         NameSet = true,
         Inputs = {
            Mix = Input {
               Value = 0,
               Expression = "MADKey_BetaD.OutputControl-7",
            },
            Background = Input {
               SourceOp = "out_switch_edgeMatte",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1650, 181.5 } },
      },
      out_switch_edgeMatte = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         NameSet = true,
         Inputs = {
            Mix = Input {
               Value = 0,
               Expression = "MADKey_BetaD.OutputControl-6",
            },
            Background = Input {
               SourceOp = "switch_outsideMask",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1540, 181.5 } },
         Colors = {
            TileColor = { R = 0.298039215686275, G = 0.298039215686275, B = 0.298039215686275 },
            TextColor = { R = 0.709803921568627, G = 0.709803921568627, B = 0.709803921568627 },
         }
      },
      switch_fringe = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         NameSet = true,
         Inputs = {
            Mix = Input { Expression = "MADKey_BetaD.OutputControl-8", },
            Background = Input {
               SourceOp = "switch_status",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1760, 181.5 } },
      },
      switch_source = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         NameSet = true,
         Inputs = {
            Mix = Input {
               Value = 0,
               Expression = "MADKey_BetaD.OutputControl-2",
            },
            Background = Input {
               SourceOp = "switch_fg",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 990, 181.5 } },
      },
      switch_fg = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         NameSet = true,
         Inputs = {
            Mix = Input {
               Value = 0,
               Expression = "MADKey_BetaD.OutputControl-1",
            },
            Background = Input {
               SourceOp = "switch_combinedMatte",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 880, 181.5 } },
      },
      switch_combinedMatte = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         NameSet = true,
         Inputs = {
            Mix = Input {
               Value = 0,
               Expression = "MADKey_BetaD.OutputControl",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 770, 181.5 } },
         Colors = {
            TileColor = { R = 0.498039215686275, G = 1, B = 0.498039215686275 },
            TextColor = { R = 0, G = 0, B = 0 },
         }
      }
   }
}

Re: Using ComboControl or MultiButtonControl to alter a form

PostPosted: Thu Apr 12, 2018 1:25 pm
by GarethT
Hey

Thank you for replying and for your suggestions.

Here is the macro
Code: Select all
{
   Tools = ordered() {
      AspectRatioMask_V1.0 = MacroOperator {
         CtrlWZoom = false,
         Inputs = ordered() {
            MainInput1 = InstanceInput {
               SourceOp = "PipeRouter2_1",
               Source = "Input",
            },
            Input1 = InstanceInput {
               SourceOp = "SETRESOLUTION_1",
               Source = "Width",
               Default = 2048,
            },
            Input2 = InstanceInput {
               SourceOp = "SETRESOLUTION_1",
               Source = "Height",
               Default = 1080,
            },
            Input3 = InstanceInput {
               SourceOp = "SETRESOLUTION_1",
               Source = "TopLeftRed",
               Name = "Color",
               ControlGroup = 4,
               Default = 0,
            },
            Input4 = InstanceInput {
               SourceOp = "SETRESOLUTION_1",
               Source = "TopLeftGreen",
               ControlGroup = 4,
               Default = 0,
            },
            Input5 = InstanceInput {
               SourceOp = "SETRESOLUTION_1",
               Source = "TopLeftBlue",
               ControlGroup = 4,
               Default = 0,
            },
            Input6 = InstanceInput {
               SourceOp = "SETRESOLUTION_1",
               Source = "TopRightRed",
               Name = "Top Right",
               ControlGroup = 5,
               Default = 0,
            },
            Input7 = InstanceInput {
               SourceOp = "SETRESOLUTION_1",
               Source = "TopRightGreen",
               ControlGroup = 5,
               Default = 0,
            },
            Input8 = InstanceInput {
               SourceOp = "SETRESOLUTION_1",
               Source = "TopRightBlue",
               ControlGroup = 5,
               Default = 0,
            },
            Input9 = InstanceInput {
               SourceOp = "SETASPECTRATIO_1",
               Source = "AspectControl",
               Default = 3,
            },
            Input10 = InstanceInput {
               SourceOp = "OUTPUT_1",
               Source = "BlendClone",
               Default = 1,
            }
         },
         Outputs = {
            MainOutput1 = InstanceOutput {
               SourceOp = "PipeRouter3",
               Source = "Output",
            }
         },
         ViewInfo = GroupInfo { Pos = { 220, 16.5 } },
         Tools = ordered() {
            PipeRouter2_1 = PipeRouter {
               CtrlWShown = false,
               ViewInfo = PipeRouterInfo { Pos = { -275, 43.6 } },
            },
            SETRESOLUTION_1 = Background {
               CtrlWZoom = false,
               CtrlWShown = false,
               NameSet = true,
               Inputs = {
                  Width = Input { Value = 2048, },
                  Height = Input { Value = 1080, },
                  ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
               },
               ViewInfo = OperatorInfo { Pos = { -110, 10.6 } },
            },
            PipeRouter1_1 = PipeRouter {
               CtrlWShown = false,
               Inputs = {
                  Input = Input {
                     SourceOp = "SETRESOLUTION_1",
                     Source = "Output",
                  },
               },
               ViewInfo = PipeRouterInfo { Pos = { -98.525, 144.176 } },
            },
            ASPECTMASK_1 = SetDomain {
               CtrlWShown = false,
               NameSet = true,
               Inputs = {
                  AdjustBottom = Input {
                     Value = 0.183950617283951,
                     Expression = "((SETRESOLUTION_1.Height-(SETRESOLUTION_1.Width/SETASPECTRATIO_1.AspectControl))/2)*(1/SETRESOLUTION_1.Height)",
                  },
                  AdjustTop = Input {
                     Value = -0.183950617283951,
                     Expression = "-(((SETRESOLUTION_1.Height-(SETRESOLUTION_1.Width/SETASPECTRATIO_1.AspectControl))/2)*(1/SETRESOLUTION_1.Height))",
                  },
                  Input = Input {
                     SourceOp = "PipeRouter1_1",
                     Source = "Output",
                  },
               },
               ViewInfo = OperatorInfo { Pos = { 55, 142.6 } },
            },
            SETASPECTRATIO_1 = Custom {
               CtrlWShown = false,
               NameSet = true,
               Inputs = {
                  LUTControlsNest = Input { Value = 1, },
                  LUTIn1 = Input {
                     SourceOp = "CustomTool1LUTIn1_1",
                     Source = "Value",
                  },
                  LUTIn2 = Input {
                     SourceOp = "CustomTool1LUTIn2_1",
                     Source = "Value",
                  },
                  LUTIn3 = Input {
                     SourceOp = "CustomTool1LUTIn3_1",
                     Source = "Value",
                  },
                  LUTIn4 = Input {
                     SourceOp = "CustomTool1LUTIn4_1",
                     Source = "Value",
                  },
                  AspectControl = Input { Value = 3, },
               },
               ViewInfo = OperatorInfo { Pos = { 275, 208.6 } },
               UserControls = ordered() {
                  NewControl = {
                     INP_Integer = false,
                     LINKS_Name = "New Control",
                     LINKID_DataType = "Number",
                  },
                  AspectControl = {
                     { CCS_AddString = "1.66" },
                     { CCS_AddString = "1.78" },
                     { CCS_AddString = "1.85" },
                     { CCS_AddString = "2.39" },
                     { CCS_AddString = "2.75" },
                     INP_MaxAllowed = 1000000,
                     INP_Integer = false,
                     INPID_InputControl = "ComboControl",
                     CC_LabelPosition = "Vertical",
                     INP_MaxScale = 4,
                     INP_MinScale = 1,
                     INP_MinAllowed = -1000000,
                     LINKID_DataType = "Number",
                     LINKS_Name = "Aspect Control",
                  }
               }
            },
            CustomTool1LUTIn1_1 = LUTBezier {
               KeyColorSplines = {
                  [0] = {
                     [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
                     [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
                  }
               },
               SplineColor = { Red = 204, Green = 0, Blue = 0 },
               CtrlWShown = false,
            },
            CustomTool1LUTIn2_1 = LUTBezier {
               KeyColorSplines = {
                  [0] = {
                     [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
                     [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
                  }
               },
               SplineColor = { Red = 0, Green = 204, Blue = 0 },
               CtrlWShown = false,
            },
            CustomTool1LUTIn3_1 = LUTBezier {
               KeyColorSplines = {
                  [0] = {
                     [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
                     [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
                  }
               },
               SplineColor = { Red = 0, Green = 0, Blue = 204 },
               CtrlWShown = false,
            },
            CustomTool1LUTIn4_1 = LUTBezier {
               KeyColorSplines = {
                  [0] = {
                     [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
                     [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
                  }
               },
               SplineColor = { Red = 204, Green = 204, Blue = 204 },
               CtrlWShown = false,
            },
            ChannelBooleans1_1_2 = ChannelBoolean {
               CtrlWShown = false,
               Inputs = {
                  Operation = Input { Value = 10, },
                  Background = Input {
                     SourceOp = "ASPECTMASK_1",
                     Source = "Output",
                  },
               },
               ViewInfo = OperatorInfo { Pos = { 55, 274.6 } },
               Colors = {
                  TileColor = { R = 0.552941176470588, G = 0.0666666666666667, B = 0.27843137254902 },
                  TextColor = { R = 0, G = 0, B = 0 },
               }
            },
            ChannelBooleans1_1_1_1 = ChannelBoolean {
               CtrlWShown = false,
               Inputs = {
                  ToRed = Input { Value = 4, },
                  ToGreen = Input { Value = 4, },
                  ToBlue = Input { Value = 4, },
                  Background = Input {
                     SourceOp = "PipeRouter1_1",
                     Source = "Output",
                  },
                  Foreground = Input {
                     SourceOp = "ChannelBooleans1_1_2",
                     Source = "Output",
                  },
               },
               ViewInfo = OperatorInfo { Pos = { -110, 274.6 } },
               Colors = {
                  TileColor = { R = 0.552941176470588, G = 0.0666666666666667, B = 0.27843137254902 },
                  TextColor = { R = 0, G = 0, B = 0 },
               }
            },
            AlphaMultiply1_1 = AlphaMultiply {
               CtrlWShown = false,
               Inputs = {
                  Input = Input {
                     SourceOp = "ChannelBooleans1_1_1_1",
                     Source = "Output",
                  },
               },
               ViewInfo = OperatorInfo { Pos = { -110, 373.6 } },
            },
            OUTPUT_1 = Merge {
               CtrlWShown = false,
               NameSet = true,
               Inputs = {
                  Background = Input {
                     SourceOp = "PipeRouter2_1",
                     Source = "Output",
                  },
                  Foreground = Input {
                     SourceOp = "AlphaMultiply1_1",
                     Source = "Output",
                  },
                  PerformDepthMerge = Input { Value = 0, },
               },
               ViewInfo = OperatorInfo { Pos = { -275, 373.6 } },
               Colors = {
                  TileColor = { R = 0.254901960784314, G = 0.298039215686275, B = 0.843137254901961 },
                  TextColor = { R = 0, G = 0, B = 0 },
               }
            },
            PipeRouter3 = PipeRouter {
               CtrlWZoom = false,
               CtrlWShown = false,
               Inputs = {
                  Input = Input {
                     SourceOp = "OUTPUT_1",
                     Source = "Output",
                  },
               },
               ViewInfo = PipeRouterInfo { Pos = { -275, 505.6 } },
            }
         },
      }
   },
   ActiveTool = "AspectRatioMask_V10"
}


Also, any idea how I can add dividers into the macro between the settings so its clear what the settings are for?

Thank you for your help.

Best wishes

Gareth T

Re: Using ComboControl or MultiButtonControl to alter a form

PostPosted: Thu Apr 12, 2018 8:24 pm
by Sander de Regt
For some more info on how to set-up extra buttons etc for your macros check out this link.

https://www.steakunderwater.com/VFXPedi ... r_Controls

It has some very useful stuff on creating labels and nests etc. This will definitely help you understand things better.

Re: Using ComboControl or MultiButtonControl to alter a form

PostPosted: Fri Apr 13, 2018 9:37 am
by GarethT
Thanks Sander, there is some helpful info there.

Looks like I will have to get creative with getting a button to return a specific value.

Thanks for your help.

Gareth T