Page 1 of 1

Switches for Macros? And Expressions

PostPosted: Mon Feb 16, 2015 2:37 pm
by Lucas Pfaff
Hi there,

I'm struggling a bit with two (most likely very little) things and google won't do me any good :(

First is for building Macros.
Basically, I want to use something like a Switch (Nuke term), so basically an option to switch between two inputs. For example, the Macro should have a button to preview a luma-matte or something, you just click it and you see the matte. In Nuke I could just use a switch, but I can't seem to find something like that in Fusion.

Is there a way to have something line switches in Fusion Macros? I mean there has to be some way to switch things?


Second is about Expressions. Well, not the normal ones, but the ones in the custom-tool.
In this very case I just want to use an if-else string. I searched a bit in the VFXpedia but the string provided ("iif(x > y, y, x)" for "if x is bigger than y, use y else use x") doesn't seem to work.
Basically I wanted to make simple despill expression, I wrote it like this

Code: Select all
iif(g1 > (max(r1,b1)), max(r1,b1), g1)


But even simple setups of that expression didn't work out (e.g. iif(g1 > r1, r1, g1))
Right now I just wrote "max(r1,b1)" into the green-expression and later applied it with a "darken" on to the plate with a channel booleans. But I think there has to be a way to do it inside the custom tool?

Best,
Rick

Re: Switches for Macros? And Expressions

PostPosted: Mon Feb 16, 2015 3:27 pm
by Stefan Ihringer
I wrote a switch Fuse to fill that gap: http://www.steakunderwater.com/wesuckle ... ?f=6&t=224

However, every workstation that uses your macro needs the Fuse. The "portable" solution is a Dissolve tool with an expression on the slider that switches between 0 or 1. The dissolve tool has problems with DoD though.

The iif syntax is for simple expressions only. For the custom tool you need to use just if(,,)

Re: Switches for Macros? And Expressions

PostPosted: Mon Feb 16, 2015 3:44 pm
by Lucas Pfaff
Hi there Stefan,

thanks a lot, that's a good idea with the Dissolve. I don't I will get problems with the DoD, as this is only meant for previews and switching between trees (e.g. for blue and greenscreen), so only things within the domain.

Interesting, so "if()" should work? I'll give it a go this evening at home (we only have Macs here unfortunately).

So far I'm struggling a bit with Fusion and its expressions and workflows, but I'm getting there :)

Your Blog has been a great helper btw, so thank you also on that :)

Re: Switches for Macros? And Expressions

PostPosted: Mon Feb 16, 2015 7:24 pm
by Lucas Pfaff
Hey there,

ok, the Expression works now, yay :)
Thanks a lot! :)

But I have some issues with the buttons for Macros.

So this is the idea: having three buttons to choose from, the selected one is highlighted in the tool.
How would I set up something like that? :o

Best,
Rick

Re: Switches for Macros? And Expressions

PostPosted: Tue Feb 17, 2015 3:07 pm
by Chad Capeland
Rick Griffo wrote:So this is the idea: having three buttons to choose from, the selected one is highlighted in the tool.
How would I set up something like that? :o


UserControls let you add some (not all) types of UI elements to your tools/groups/macros.

Code: Select all
{
   Tools = ordered() {
      Group1 = GroupOperator {
         CtrlWZoom = false,
         Outputs = {
            Output1 = InstanceOutput {
               SourceOp = "Dissolve2",
               Source = "Output",
            },
         },
         ViewInfo = GroupInfo {
            Pos = { 990, 38.8, },
            Flags = {
               Expanded = true,
               AllowPan = false,
               AutoSnap = true,
               RemoveRouters = true,
            },
            Size = { 456, 163.3, },
            Direction = "Horizontal",
            PipeStyle = "Direct",
            Scale = 1,
            Offset = { -990, -38.8, },
         },
         Tools = ordered() {
            Dissolve1 = Dissolve {
               Transitions = {
                  [0] = "DFTDissolve",
               },
               CtrlWZoom = false,
               Inputs = {
                  Mix = Input {
                     Value = 0,
                     Expression = "Group1.UCMBE",
                  },
                  Background = Input {
                     SourceOp = "Text1",
                     Source = "Output",
                  },
                  Foreground = Input {
                     SourceOp = "Text2",
                     Source = "Output",
                  },
               },
               ViewInfo = OperatorInfo { Pos = { 991, 148.5, }, },
            },
            Text2 = TextPlus {
               Inputs = {
                  Width = Input { Value = 2048, },
                  Height = Input { Value = 1556, },
                  ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2", }, },
                  Font = Input { Value = "Arial", },
                  StyledText = Input { Value = "2", },
                  Style = Input { Value = "Bold", },
                  ManualFontKerningPlacement = Input {
                     Value = StyledText {
                        Array = {
                        },
                        Value = "",
                     },
                  },
                  ShadingGradient1 = Input {
                     Value = Gradient {
                        Colors = {
                           [0] = { 0, 0, 0, 1, },
                           [1] = { 1, 1, 1, 1, },
                        },
                     },
                  },
                  RenderToDPTFile = Input { Disabled = true, },
                  DPTType = Input { Disabled = true, },
                  DPTResolution = Input { Disabled = true, },
               },
               ViewInfo = OperatorInfo { Pos = { 880, 49.5, }, },
            },
            Text3 = TextPlus {
               Inputs = {
                  Width = Input { Value = 2048, },
                  Height = Input { Value = 1556, },
                  ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2", }, },
                  Font = Input { Value = "Arial", },
                  StyledText = Input { Value = "3", },
                  Style = Input { Value = "Bold", },
                  ManualFontKerningPlacement = Input {
                     Value = StyledText {
                        Array = {
                        },
                        Value = "",
                     },
                  },
                  ShadingGradient1 = Input {
                     Value = Gradient {
                        Colors = {
                           [0] = { 0, 0, 0, 1, },
                           [1] = { 1, 1, 1, 1, },
                        },
                     },
                  },
                  RenderToDPTFile = Input { Disabled = true, },
                  DPTType = Input { Disabled = true, },
                  DPTResolution = Input { Disabled = true, },
               },
               ViewInfo = OperatorInfo { Pos = { 1045, 49.5, }, },
            },
            Text1 = TextPlus {
               Inputs = {
                  Width = Input { Value = 2048, },
                  Height = Input { Value = 1556, },
                  ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2", }, },
                  Font = Input { Value = "Arial", },
                  StyledText = Input { Value = "1", },
                  Style = Input { Value = "Bold", },
                  ManualFontKerningPlacement = Input {
                     Value = StyledText {
                        Array = {
                        },
                        Value = "",
                     },
                  },
                  ShadingGradient1 = Input {
                     Value = Gradient {
                        Colors = {
                           [0] = { 0, 0, 0, 1, },
                           [1] = { 1, 1, 1, 1, },
                        },
                     },
                  },
                  RenderToDPTFile = Input { Disabled = true, },
                  DPTType = Input { Disabled = true, },
                  DPTResolution = Input { Disabled = true, },
               },
               ViewInfo = OperatorInfo { Pos = { 825, 148.5, }, },
            },
            Dissolve2 = Dissolve {
               Transitions = {
                  [0] = "DFTDissolve",
               },
               CtrlWZoom = false,
               NameSet = true,
               Inputs = {
                  Mix = Input {
                     Value = 0,
                     Expression = "Group1.UCMBE-1",
                  },
                  Background = Input {
                     SourceOp = "Dissolve1",
                     Source = "Output",
                  },
                  Foreground = Input {
                     SourceOp = "Text3",
                     Source = "Output",
                  },
               },
               ViewInfo = OperatorInfo { Pos = { 1155, 148.5, }, },
            },
         },
         UserControls = ordered() {
            UCMBE = {
               { MBTNC_AddButton = "1", },
               { MBTNC_AddButton = "2", },
               { MBTNC_AddButton = "3", },
               LINKS_Name = "UserControl MultiButton Example",
               MBTNC_StretchToFit = true,
               INP_MaxAllowed = 2,
               INP_MaxScale = 2,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               INP_Default = 0,
               INP_Integer = true,
               MBTNC_ButtonHeight = 35,
               INPID_InputControl = "MultiButtonControl",
            },
         },
      },
   },
   ActiveTool = "Group1",
}

Re: Switches for Macros? And Expressions

PostPosted: Sat Feb 21, 2015 12:42 am
by Lucas Pfaff
Hi there Chad,

sorry I respond so late, I oversaw the answer :(

Thank you so much for your demo-setup. Works flawless! I will inspect how it was done in detail later; I tried to utilize the UserControls before, but the correct expression was where I failed :)

Re: Switches for Macros? And Expressions

PostPosted: Sat Feb 21, 2015 2:14 am
by Chad Capeland
The UserControls script is not complete as far as what UserControls options it enables. It's enough to get you started, yes, but there are more advanced things that you'll want to do by directly editing the tool settings.

Re: Switches for Macros? And Expressions

PostPosted: Sat Feb 21, 2015 5:59 pm
by Lucas Pfaff
I already encountered that; seems I can't even edit things inside of Fusion
I have to get to know the "system" behind the syntax a bit (unfortunately I have no coding-background) to be more efficiant, but still I managed to build my first "complex" tool today :)

Thank you :)