Welcome to WSL!

New to the forum? Please read this and this.

Set BG Color with Expressions

User avatar
spud101
Posts: 9
Joined: Wed Nov 06, 2019 4:45 am

Set BG Color with Expressions

#1

Post by spud101 »

I'm trying to use expressions to link the colors of two background nodes together dependant on the status of a checkbox. If the checkbox CopyColor is checked the color will be the same as Background1 & if unchecked I want the user to be able to select the color of Background2. I thought it would be straight forward but this is the path I rambled down & questions it provoked.

Is there a way to access a color group as a single value (hex) or do you have to assign each color channel (TopLeftRed , etc)?

My first thought was to add iff statement to all the channels . Ex. On Background2 Red channel.
iif (CopyColor==1,Background1.TopLeftRed)
This worked when checked but when unchecked the control is locked because of the expression & cant change the value manually.

Then I thought if I added a block off statements inside If statement but i dont know where I could put it & trigger its execution.
I'm thinking like javascript & an on-click event .
  1. if CopyColor==1 then
  2. Background2.TopLeftRed = Background1.TopLeftRed
  3. Background2.TopLeftGreen = Background1.TopLeftGreen
  4. Background2.TopLeftBlue = Background1.TopLeftBlue
  5. end
Last I thought of a Button control instead of a checkbox since it has an Execute. Setting one channel to a numeric value works (Background2.TopLeftRed = .8) but below doesnt and I dont think you can run multiple statements in the BTNCS_Execute.

BTNCS_Execute = "Background2.TopLeftRed = Background1.TopLeftRed" --------------seems to always evaluate to zero

I hope someone can enlighten as to the best way of doing this & correct my misconceptions of the working of expressions in Fusion.
  1. {
  2.     Tools = ordered() {
  3.         Background1 = Background {
  4.             Inputs = {
  5.                 GlobalOut = Input { Value = 200, },
  6.                 Width = Input { Value = 1920, },
  7.                 Height = Input { Value = 1080, },
  8.                 ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
  9.                 TopLeftRed = Input { Value = 0.244, },
  10.                 TopLeftGreen = Input { Value = 0.283, },
  11.             },
  12.             ViewInfo = OperatorInfo { Pos = { 110, 16.5 } },
  13.         },
  14.         Background2 = Background {
  15.             CtrlWZoom = false,
  16.             Inputs = {
  17.                 GlobalOut = Input { Value = 200, },
  18.                 Width = Input { Value = 1920, },
  19.                 Height = Input { Value = 1080, },
  20.                 ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
  21.                 TopLeftGreen = Input { Value = 0.001, },
  22.             },
  23.             ViewInfo = OperatorInfo { Pos = { 220, 16.5 } },
  24.             UserControls = ordered() {
  25.                 CopyColor = {
  26.                     LINKS_Name = "Copy Color",
  27.                     LINKID_DataType = "Number",
  28.                     INPID_InputControl = "CheckboxControl",
  29.                     INP_Default = 0,
  30.                     INP_Integer = false,
  31.                     CBC_TriState = false,
  32.                     ICS_ControlPage = "Color",
  33.                 },
  34.                 CopyRGB = {
  35.                     LINKS_Name = "CopyRGB",
  36.                     LINKID_DataType = "Number",
  37.                     INPID_InputControl = "ButtonControl",
  38.                     INP_Integer = false,
  39.                     INP_MinScale = 0,
  40.                     INP_MaxScale = 1,
  41.                     INP_MinAllowed = -1000000,
  42.                     INP_MaxAllowed = 1000000,
  43.                     BTNCS_Execute = "Background2.TopLeftRed = Background1.TopLeftRed",
  44.                     ICS_ControlPage = "Color",
  45.                     INP_External = false
  46.                 }
  47.             }
  48.         }
  49.     }
  50. }
by Midgardsormr » Sat May 08, 2021 7:58 am
Go back to your initial idea of a checkbox, and use that to drive the Merge's Blend:

Code: Select all

{
	Tools = ordered() {
		Top_Rectangle = RectangleMask {
			NameSet = true,
			Inputs = {
				Filter = Input { Value = FuID { "Fast Gaussian" }, },
				MaskWidth = Input { Value = 1920, },
				MaskHeight = Input { Value = 1080, },
				PixelAspect = Input { Value = { 1, 1 }, },
				ClippingMode = Input { Value = FuID { "None" }, },
				Center = Input { Value = { 0.5, 0.692982456140351 }, },
				Height = Input { Value = 0.0538847117794486, },
			},
			ViewInfo = OperatorInfo { Pos = { 20.3333, -8.66667 } },
		},
		Instance_Background1 = Background {
			SourceOp = "Background1",
			Inputs = {
				EffectMask = Input {
					SourceOp = "Top_Rectangle",
					Source = "Mask",
				},
				SettingsNest = Input { },
				ImageNest = Input { },
				["Gamut.ColorSpaceNest"] = Input { },
				["Gamut.GammaSpaceNest"] = Input { },
				BackgroundNest = Input { },
				CommentsNest = Input { },
				FrameRenderScriptNest = Input { },
				StartRenderScripts = Input { },
				EndRenderScripts = Input { },
			},
			ViewInfo = OperatorInfo { Pos = { 130.333, 24.3333 } },
		},
		Background1 = Background {
			Inputs = {
				EffectMask = Input {
					SourceOp = "Bottom_Rectangle",
					Source = "Mask",
				},
				Width = Input { Value = 1920, },
				Height = Input { Value = 1080, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				TopLeftRed = Input { Value = 0.496, },
				TopLeftGreen = Input { Value = 0.283, },
			},
			ViewInfo = OperatorInfo { Pos = { 295.333, 24.3333 } },
		},
		Bottom_Rectangle = RectangleMask {
			NameSet = true,
			Inputs = {
				Filter = Input { Value = FuID { "Fast Gaussian" }, },
				MaskWidth = Input { Value = 1920, },
				MaskHeight = Input { Value = 1080, },
				PixelAspect = Input { Value = { 1, 1 }, },
				ClippingMode = Input { Value = FuID { "None" }, },
				Center = Input { Value = { 0.5, 0.317042606516291 }, },
				Height = Input { Value = 0.0538847117794486, },
			},
			ViewInfo = OperatorInfo { Pos = { 295.333, -8.66667 } },
		},
		Merge4 = Merge {
			CtrlWZoom = false,
			Inputs = {
				Blend = Input { Expression = "Background2.CopyColor", },
				Background = Input {
					SourceOp = "Background2",
					Source = "Output",
				},
				Foreground = Input {
					SourceOp = "Instance_Background1",
					Source = "Output",
				},
				PerformDepthMerge = Input { Value = 0, },
			},
			ViewInfo = OperatorInfo { Pos = { 131, 90.3333 } },
		},
		Merge5 = Merge {
			Inputs = {
				Background = Input {
					SourceOp = "Merge4",
					Source = "Output",
				},
				Foreground = Input {
					SourceOp = "Background1",
					Source = "Output",
				},
				PerformDepthMerge = Input { Value = 0, },
			},
			ViewInfo = OperatorInfo { Pos = { 295.333, 90.9394 } },
		},
		Background2 = Background {
			CtrlWZoom = false,
			Inputs = {
				script = Input {
					SourceOp = "Expression2",
					Source = "NumberResult",
				},
				EffectMask = Input {
					SourceOp = "Top_Rectangle",
					Source = "Mask",
				},
				Width = Input { Value = 1920, },
				Height = Input { Value = 1080, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				TopLeftRed = Input { Value = 0.559, },
				TopLeftGreen = Input { Value = 0.094, },
				TopLeftBlue = Input { Value = 0.654, },
				CopyColor = Input { Value = 1, },
			},
			ViewInfo = OperatorInfo { Pos = { 20.3333, 90.3333 } },
			UserControls = ordered() {
				CopyColor = {
					CBC_TriState = false,
					INP_Integer = false,
					LINKID_DataType = "Number",
					INP_Default = 0,
					ICS_ControlPage = "Color",
					INPID_InputControl = "CheckboxControl",
					LINKS_Name = "Copy Color",
				},
				Execute = {
					INP_MaxAllowed = 1000000,
					INP_Integer = false,
					INPID_InputControl = "ButtonControl",
					BTNCS_Execute = "if CopyColor==1 then Merge4:SetAttrs( { TOOLB_PassThrough = false } ) else Merge4:SetAttrs( { TOOLB_PassThrough =true } ) end",
					INP_MaxScale = 1,
					INP_MinScale = 0,
					INP_MinAllowed = -1000000,
					LINKID_DataType = "Number",
					INP_External = false,
					ICS_ControlPage = "Color",
					LINKS_Name = "Execute"
				}
			}
		},
		Expression2 = Expression {
			CtrlWZoom = false,
			Inputs = {
				n1 = Input {
					Value = 0.496,
					Expression = "Background1.TopLeftRed",
				},
				n2 = Input { Value = 1.239, },
				NumberExpression = Input { Value = "n1", },
				NumberControls = Input { Value = 1, },
				ShowNumber4 = Input { Value = 0, },
				ShowNumber5 = Input { Value = 0, },
				ShowNumber6 = Input { Value = 0, },
				ShowNumber7 = Input { Value = 0, },
				ShowNumber8 = Input { Value = 0, },
				ShowNumber9 = Input { Value = 0, },
				ShowPoint1 = Input { Value = 0, },
				ShowPoint2 = Input { Value = 0, },
				ShowPoint3 = Input { Value = 0, },
				ShowPoint4 = Input { Value = 0, },
				ShowPoint5 = Input { Value = 0, },
				ShowPoint6 = Input { Value = 0, },
				ShowPoint7 = Input { Value = 0, },
				ShowPoint8 = Input { Value = 0, },
				ShowPoint9 = Input { Value = 0, },
			},
		}
	}
}
Added in 6 minutes 26 seconds:
Looking at your button control, it can still work, but it needs some adjustments. You can reference the tool the button lives on with tool. Any tool other than that one needs to be referenced in the comp context. In addition, only an Output can be directly assigned to an Input, so you can't assign TopLeftRed to TopLeftRed. Instead, you need to assign the value of an Input to another Input by querying it at a particular frame. So try this:

tool.TopLeftRed = comp.Background1.TopLeftRed[1]

Added in 1 minute 56 seconds:
The trouble you might have with this is that if you copy-and-paste the pair of tools, the copy of Background2 will still get its properties from the original Background1 because you're finding it by its name. That might be okay, but if it's not, you'll need a more elaborate approach. The Merge thing will work fine, though.
Go to full post

User avatar
mrjholt
Posts: 22
Joined: Wed Mar 18, 2020 10:51 am
Answers: 1
Been thanked: 4 times

Re: Set BG Color with Expressions

#2

Post by mrjholt »

Hello.

You could use an instance of the background and have a checkbox operate the deinstance of the color.

Short & simple plus cached rather than calculated every frame.

Just a thought.

User avatar
spud101
Posts: 9
Joined: Wed Nov 06, 2019 4:45 am

Re: Set BG Color with Expressions

#3

Post by spud101 »

Interesting Idea. I dont know how to script the deinstance value of a property. I compared 2 instances of a node in a text editor. One had a deinstance & the other didnt & the files were identical except for the instance name. So thats a mystery in itself to me.
But it gave me an idea to merge the instance over top & control the passthrough of the merge node with the checkbox.

I used a button control to execute the passthrough but the if statement checking the CopyColor checkbox doesnt work.
  1. BTNCS_Execute = "if CopyColor==1 then Merge4:SetAttrs( { TOOLB_PassThrough = false } ) else Merge4:SetAttrs( { TOOLB_PassThrough =true } ) end",
  1. {
  2.     Tools = ordered() {
  3.         Background1 = Background {
  4.             Inputs = {
  5.                 GlobalOut = Input { Value = 200, },
  6.                 Width = Input { Value = 1920, },
  7.                 Height = Input { Value = 1080, },
  8.                 ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
  9.                 TopLeftRed = Input { Value = 0.496, },
  10.                 TopLeftGreen = Input { Value = 0.283, },
  11.                 EffectMask = Input {
  12.                     SourceOp = "Bottom_Rectangle",
  13.                     Source = "Mask",
  14.                 }
  15.             },
  16.             ViewInfo = OperatorInfo { Pos = { 440, -16.5 } },
  17.         },
  18.         Merge5 = Merge {
  19.             Inputs = {
  20.                 Background = Input {
  21.                     SourceOp = "Merge4",
  22.                     Source = "Output",
  23.                 },
  24.                 Foreground = Input {
  25.                     SourceOp = "Background1",
  26.                     Source = "Output",
  27.                 },
  28.                 PerformDepthMerge = Input { Value = 0, },
  29.             },
  30.             ViewInfo = OperatorInfo { Pos = { 440, 49.5 } },
  31.         },
  32.         Bottom_Rectangle = RectangleMask {
  33.             NameSet = true,
  34.             Inputs = {
  35.                 Filter = Input { Value = FuID { "Fast Gaussian" }, },
  36.                 MaskWidth = Input { Value = 1920, },
  37.                 MaskHeight = Input { Value = 1080, },
  38.                 PixelAspect = Input { Value = { 1, 1 }, },
  39.                 ClippingMode = Input { Value = FuID { "None" }, },
  40.                 Center = Input { Value = { 0.5, 0.317042606516291 }, },
  41.                 Height = Input { Value = 0.0538847117794486, },
  42.             },
  43.             ViewInfo = OperatorInfo { Pos = { 440, -49.5 } },
  44.         },
  45.         Merge4 = Merge {
  46.             Inputs = {
  47.                 Background = Input {
  48.                     SourceOp = "Background2",
  49.                     Source = "Output",
  50.                 },
  51.                 Foreground = Input {
  52.                     SourceOp = "Instance_Background1",
  53.                     Source = "Output",
  54.                 },
  55.                 PerformDepthMerge = Input { Value = 0, },
  56.             },
  57.             ViewInfo = OperatorInfo { Pos = { 275, 49.5 } },
  58.         },
  59.         Instance_Background1 = Background {
  60.             SourceOp = "Background1",
  61.             Inputs = {
  62.                 SettingsNest = Input { },
  63.                 ImageNest = Input { },
  64.                 ["Gamut.ColorSpaceNest"] = Input { },
  65.                 ["Gamut.GammaSpaceNest"] = Input { },
  66.                 BackgroundNest = Input { },
  67.                 CommentsNest = Input { },
  68.                 FrameRenderScriptNest = Input { },
  69.                 StartRenderScripts = Input { },
  70.                 EndRenderScripts = Input { },
  71.                 EffectMask = Input {
  72.                     SourceOp = "Top_Rectangle",
  73.                     Source = "Mask",
  74.                 }
  75.             },
  76.             ViewInfo = OperatorInfo { Pos = { 275, -16.5 } },
  77.         },
  78.         Background2 = Background {
  79.             CtrlWZoom = false,
  80.             Inputs = {
  81.                 script = Input {
  82.                     SourceOp = "Expression2",
  83.                     Source = "NumberResult",
  84.                 },
  85.                 GlobalOut = Input { Value = 200, },
  86.                 Width = Input { Value = 1920, },
  87.                 Height = Input { Value = 1080, },
  88.                 ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
  89.                 TopLeftRed = Input { Value = 0.559, },
  90.                 TopLeftGreen = Input { Value = 0.094, },
  91.                 TopLeftBlue = Input { Value = 0.654, },
  92.                 EffectMask = Input {
  93.                     SourceOp = "Top_Rectangle",
  94.                     Source = "Mask",
  95.                 }
  96.             },
  97.             ViewInfo = OperatorInfo { Pos = { 165, 49.5 } },
  98.             UserControls = ordered() {
  99.                 CopyColor = {
  100.                     CBC_TriState = false,
  101.                     INP_Integer = false,
  102.                     LINKID_DataType = "Number",
  103.                     LINKS_Name = "Copy Color",
  104.                     INPID_InputControl = "CheckboxControl",
  105.                     ICS_ControlPage = "Color",
  106.                     INP_Default = 0,
  107.                 },
  108.                 Execute = {
  109.                     LINKS_Name = "Execute",
  110.                     LINKID_DataType = "Number",
  111.                     INPID_InputControl = "ButtonControl",
  112.                     INP_Integer = false,
  113.                     INP_MinScale = 0,
  114.                     INP_MaxScale = 1,
  115.                     INP_MinAllowed = -1000000,
  116.                     INP_MaxAllowed = 1000000,
  117.                     BTNCS_Execute = "if CopyColor==1 then Merge4:SetAttrs( { TOOLB_PassThrough = false } ) else Merge4:SetAttrs( { TOOLB_PassThrough =true } ) end",
  118.                     ICS_ControlPage = "Color",
  119.                     INP_External = false
  120.                 }
  121.             }
  122.         },
  123.         Expression2 = Expression {
  124.             CtrlWZoom = false,
  125.             Inputs = {
  126.                 n1 = Input {
  127.                     Value = 0.496,
  128.                     Expression = "Background1.TopLeftRed",
  129.                 },
  130.                 n2 = Input { Value = 1.239, },
  131.                 NumberExpression = Input { Value = "n1", },
  132.                 NumberControls = Input { Value = 1, },
  133.                 ShowNumber4 = Input { Value = 0, },
  134.                 ShowNumber5 = Input { Value = 0, },
  135.                 ShowNumber6 = Input { Value = 0, },
  136.                 ShowNumber7 = Input { Value = 0, },
  137.                 ShowNumber8 = Input { Value = 0, },
  138.                 ShowNumber9 = Input { Value = 0, },
  139.                 ShowPoint1 = Input { Value = 0, },
  140.                 ShowPoint2 = Input { Value = 0, },
  141.                 ShowPoint3 = Input { Value = 0, },
  142.                 ShowPoint4 = Input { Value = 0, },
  143.                 ShowPoint5 = Input { Value = 0, },
  144.                 ShowPoint6 = Input { Value = 0, },
  145.                 ShowPoint7 = Input { Value = 0, },
  146.                 ShowPoint8 = Input { Value = 0, },
  147.                 ShowPoint9 = Input { Value = 0, },
  148.             },
  149.         },
  150.         Top_Rectangle = RectangleMask {
  151.             NameSet = true,
  152.             Inputs = {
  153.                 Filter = Input { Value = FuID { "Fast Gaussian" }, },
  154.                 MaskWidth = Input { Value = 1920, },
  155.                 MaskHeight = Input { Value = 1080, },
  156.                 PixelAspect = Input { Value = { 1, 1 }, },
  157.                 ClippingMode = Input { Value = FuID { "None" }, },
  158.                 Center = Input { Value = { 0.5, 0.692982456140351 }, },
  159.                 Height = Input { Value = 0.0538847117794486, },
  160.             },
  161.             ViewInfo = OperatorInfo { Pos = { 165, -49.5 } },
  162.         },
  163.         Note1 = Note {
  164.             Inputs = {
  165.                 Comments = Input { Value = "Copy Controls are on Background2 Node", }
  166.             },
  167.             ViewInfo = StickyNoteInfo {
  168.                 Pos = { -55, 16.5 },
  169.                 Flags = {
  170.                     Expanded = true
  171.                 },
  172.                 Size = { 196, 70.4545 }
  173.             },
  174.         }
  175.     }
  176. }

User avatar
Midgardsormr
Fusionator
Posts: 2169
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 28
Location: Los Angeles, CA, USA
Been thanked: 40 times
Contact:

Re: Set BG Color with Expressions

#4

Post by Midgardsormr »

Go back to your initial idea of a checkbox, and use that to drive the Merge's Blend:

Code: Select all

{
	Tools = ordered() {
		Top_Rectangle = RectangleMask {
			NameSet = true,
			Inputs = {
				Filter = Input { Value = FuID { "Fast Gaussian" }, },
				MaskWidth = Input { Value = 1920, },
				MaskHeight = Input { Value = 1080, },
				PixelAspect = Input { Value = { 1, 1 }, },
				ClippingMode = Input { Value = FuID { "None" }, },
				Center = Input { Value = { 0.5, 0.692982456140351 }, },
				Height = Input { Value = 0.0538847117794486, },
			},
			ViewInfo = OperatorInfo { Pos = { 20.3333, -8.66667 } },
		},
		Instance_Background1 = Background {
			SourceOp = "Background1",
			Inputs = {
				EffectMask = Input {
					SourceOp = "Top_Rectangle",
					Source = "Mask",
				},
				SettingsNest = Input { },
				ImageNest = Input { },
				["Gamut.ColorSpaceNest"] = Input { },
				["Gamut.GammaSpaceNest"] = Input { },
				BackgroundNest = Input { },
				CommentsNest = Input { },
				FrameRenderScriptNest = Input { },
				StartRenderScripts = Input { },
				EndRenderScripts = Input { },
			},
			ViewInfo = OperatorInfo { Pos = { 130.333, 24.3333 } },
		},
		Background1 = Background {
			Inputs = {
				EffectMask = Input {
					SourceOp = "Bottom_Rectangle",
					Source = "Mask",
				},
				Width = Input { Value = 1920, },
				Height = Input { Value = 1080, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				TopLeftRed = Input { Value = 0.496, },
				TopLeftGreen = Input { Value = 0.283, },
			},
			ViewInfo = OperatorInfo { Pos = { 295.333, 24.3333 } },
		},
		Bottom_Rectangle = RectangleMask {
			NameSet = true,
			Inputs = {
				Filter = Input { Value = FuID { "Fast Gaussian" }, },
				MaskWidth = Input { Value = 1920, },
				MaskHeight = Input { Value = 1080, },
				PixelAspect = Input { Value = { 1, 1 }, },
				ClippingMode = Input { Value = FuID { "None" }, },
				Center = Input { Value = { 0.5, 0.317042606516291 }, },
				Height = Input { Value = 0.0538847117794486, },
			},
			ViewInfo = OperatorInfo { Pos = { 295.333, -8.66667 } },
		},
		Merge4 = Merge {
			CtrlWZoom = false,
			Inputs = {
				Blend = Input { Expression = "Background2.CopyColor", },
				Background = Input {
					SourceOp = "Background2",
					Source = "Output",
				},
				Foreground = Input {
					SourceOp = "Instance_Background1",
					Source = "Output",
				},
				PerformDepthMerge = Input { Value = 0, },
			},
			ViewInfo = OperatorInfo { Pos = { 131, 90.3333 } },
		},
		Merge5 = Merge {
			Inputs = {
				Background = Input {
					SourceOp = "Merge4",
					Source = "Output",
				},
				Foreground = Input {
					SourceOp = "Background1",
					Source = "Output",
				},
				PerformDepthMerge = Input { Value = 0, },
			},
			ViewInfo = OperatorInfo { Pos = { 295.333, 90.9394 } },
		},
		Background2 = Background {
			CtrlWZoom = false,
			Inputs = {
				script = Input {
					SourceOp = "Expression2",
					Source = "NumberResult",
				},
				EffectMask = Input {
					SourceOp = "Top_Rectangle",
					Source = "Mask",
				},
				Width = Input { Value = 1920, },
				Height = Input { Value = 1080, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				TopLeftRed = Input { Value = 0.559, },
				TopLeftGreen = Input { Value = 0.094, },
				TopLeftBlue = Input { Value = 0.654, },
				CopyColor = Input { Value = 1, },
			},
			ViewInfo = OperatorInfo { Pos = { 20.3333, 90.3333 } },
			UserControls = ordered() {
				CopyColor = {
					CBC_TriState = false,
					INP_Integer = false,
					LINKID_DataType = "Number",
					INP_Default = 0,
					ICS_ControlPage = "Color",
					INPID_InputControl = "CheckboxControl",
					LINKS_Name = "Copy Color",
				},
				Execute = {
					INP_MaxAllowed = 1000000,
					INP_Integer = false,
					INPID_InputControl = "ButtonControl",
					BTNCS_Execute = "if CopyColor==1 then Merge4:SetAttrs( { TOOLB_PassThrough = false } ) else Merge4:SetAttrs( { TOOLB_PassThrough =true } ) end",
					INP_MaxScale = 1,
					INP_MinScale = 0,
					INP_MinAllowed = -1000000,
					LINKID_DataType = "Number",
					INP_External = false,
					ICS_ControlPage = "Color",
					LINKS_Name = "Execute"
				}
			}
		},
		Expression2 = Expression {
			CtrlWZoom = false,
			Inputs = {
				n1 = Input {
					Value = 0.496,
					Expression = "Background1.TopLeftRed",
				},
				n2 = Input { Value = 1.239, },
				NumberExpression = Input { Value = "n1", },
				NumberControls = Input { Value = 1, },
				ShowNumber4 = Input { Value = 0, },
				ShowNumber5 = Input { Value = 0, },
				ShowNumber6 = Input { Value = 0, },
				ShowNumber7 = Input { Value = 0, },
				ShowNumber8 = Input { Value = 0, },
				ShowNumber9 = Input { Value = 0, },
				ShowPoint1 = Input { Value = 0, },
				ShowPoint2 = Input { Value = 0, },
				ShowPoint3 = Input { Value = 0, },
				ShowPoint4 = Input { Value = 0, },
				ShowPoint5 = Input { Value = 0, },
				ShowPoint6 = Input { Value = 0, },
				ShowPoint7 = Input { Value = 0, },
				ShowPoint8 = Input { Value = 0, },
				ShowPoint9 = Input { Value = 0, },
			},
		}
	}
}
Added in 6 minutes 26 seconds:
Looking at your button control, it can still work, but it needs some adjustments. You can reference the tool the button lives on with tool. Any tool other than that one needs to be referenced in the comp context. In addition, only an Output can be directly assigned to an Input, so you can't assign TopLeftRed to TopLeftRed. Instead, you need to assign the value of an Input to another Input by querying it at a particular frame. So try this:

tool.TopLeftRed = comp.Background1.TopLeftRed[1]

Added in 1 minute 56 seconds:
The trouble you might have with this is that if you copy-and-paste the pair of tools, the copy of Background2 will still get its properties from the original Background1 because you're finding it by its name. That might be okay, but if it's not, you'll need a more elaborate approach. The Merge thing will work fine, though.

User avatar
spud101
Posts: 9
Joined: Wed Nov 06, 2019 4:45 am

Re: Set BG Color with Expressions

#5

Post by spud101 »

Good stuff Brian. Kind of locked in thinking of checking the condition of checkbox to initiate some code rather than using its actual value. This was just something I was playing with for a title template and would really like to understand the expression side better.
I never would have figured out the TopLeftRed[1] tip. I was trying TopLeftRed.Value & Background1:GetValue("TopLeftRed")

That tip also got my Button to work with the passthrough method.
Cheers