Jump to: Board index » General » Fusion

How to reference the input node in expression

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

purplemagic

  • Posts: 57
  • Joined: Tue Jan 05, 2021 9:23 pm
  • Real Name: Justin Lewis

How to reference the input node in expression

PostSun Jun 20, 2021 9:35 pm

I'm making a macro whose behavior depends on whether the input node has a value set for a control, so I need to access the input node's control other than through the node name.

There is self:Input, but you can only access its properties such as width and height, not its controls.

How do you reference the input node that gives you read access to its controls if the input node's name is unknown?
Online
User avatar

Bryan Ray

  • Posts: 1973
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: How to reference the input node in expression

PostSun Jun 20, 2021 10:38 pm

In a macro, you can still reference by a node's name. Fusion will auto-update expressions that are pointed to tools inside the macro to match the new names when you make a copy, the same as it does if you copy-paste tools that are expression-linked.

Just don't call your input node "Input." I learned the hard way that node names that match the input or output names of tools (and almost every node has an input called "Input") will break (thanks again, Pieter, for pointing out my mistake!) Fusion think's you're asking for properties of the node's own Input instead of properties of a node named "Input". I usually use the macro's name followed by "_in". So "MyMacro_in" and "MyMacro_effectMask", and so on.
Bryan Ray
http://www.bryanray.name
http://www.musevfx.com
Offline

purplemagic

  • Posts: 57
  • Joined: Tue Jan 05, 2021 9:23 pm
  • Real Name: Justin Lewis

Re: How to reference the input node in expression

PostMon Jun 21, 2021 4:06 am

Bryan Ray wrote:In a macro, you can still reference by a node's name. Fusion will auto-update expressions that are pointed to tools inside the macro to match the new names when you make a copy, the same as it does if you copy-paste tools that are expression-linked.

Sorry, I should have been clearer with my question.

The macro has one input and inside the macro, the node that defines or exports the input needs to look up the input node's controls.

The input node exists outside the macro, so you can't hardcode it inside the macro and if you do, it won't be automatically updated when you connect the input node to the macro in your composite.
Online
User avatar

Bryan Ray

  • Posts: 1973
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: How to reference the input node in expression

PostMon Jun 21, 2021 5:02 pm

Hrm… I tried a few things, but I didn't come up with a solution. Maybe if you explained what this macro is supposed to do, I (or someone else) could offer more help, or a different approach.

My immediate concern is what if the user connects a tool that simply doesn't have the control you expect to find? The entire macro would fail, and it wouldn't be obvious why.
Bryan Ray
http://www.bryanray.name
http://www.musevfx.com
Offline

purplemagic

  • Posts: 57
  • Joined: Tue Jan 05, 2021 9:23 pm
  • Real Name: Justin Lewis

Re: How to reference the input node in expression

PostTue Jun 22, 2021 3:35 am

Bryan Ray wrote:My immediate concern is what if the user connects a tool that simply doesn't have the control you expect to find? The entire macro would fail, and it wouldn't be obvious why.

The user normally sets the values for the macro's custom controls, but if he doesn't and the input node is an instance of the same macro, then the macro will use the input node's custom controls to derive the values.
Offline

UserNoah

  • Posts: 307
  • Joined: Fri Oct 04, 2019 3:32 pm
  • Location: Berlin
  • Real Name: Noah Hähnel

Re: How to reference the input node in expression

PostTue Jun 22, 2021 5:30 am

The only possibility that I could think of is using a button that the user has to press that executes a script that runs through the inputs and connects them to the previous nodes inputs.
But that's not really dynamic and there would need to be a separate button to disconnect these inputs. Although you could hide the original button once it ran and replace it with the disconnect button.

The benefit of this could be that if a user doesn't want to use the same controls for both macros chained together he could simply not chain them together.

But maybe it doesn't even need to do all of this. If a user wants to use the same values on both nodes he could simply create an instance.

Obviously I have no idea what exactly you're trying to achieve, so maybe this isn't an option.
Online
User avatar

Bryan Ray

  • Posts: 1973
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: How to reference the input node in expression

PostTue Jun 22, 2021 2:20 pm

Knowing that you wanted to grab info from another macro makes the situation exponentially more complex; the experiments I was doing before wouldn't even have worked because a macro isn't usually just one tool. I'm fairly sure GetConnectedOutput():GetTool() would only have found the last node inside the macro, which probably doesn't have the controls you'd want to read. I'm not sure how to get a reference to the parent group, even with a full script. I'm sure there's a way, but I've never needed to do it.
Bryan Ray
http://www.bryanray.name
http://www.musevfx.com
Offline
User avatar

Andrew Hazelden

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

Re: How to reference the input node in expression

PostTue Jun 22, 2021 11:23 pm

Hi purplemagic.

You might want to read through the following thread on WSL:

Entry level project: Developing an advanced Camera Crane Rig.
https://www.steakunderwater.com/wesuckl ... f=6&t=1821

You will see the build log of a new-to-macros-and-expressions user as they slowly create a custom multi-macro linked tool of their own.

Some of the challenges faced on this series of posts sound very similar to some of your own projects needs for realtime node interlinking and attribute probing on the fly.
MacBook Air M1 | Fusion Studio 17 | KartaVR 5
Offline

purplemagic

  • Posts: 57
  • Joined: Tue Jan 05, 2021 9:23 pm
  • Real Name: Justin Lewis

Re: How to reference the input node in expression

PostWed Jun 23, 2021 7:16 pm

UserNoah wrote:The only possibility that I could think of is using a button that the user has to press that executes a script that runs through the inputs and connects them to the previous nodes inputs.

That would work too, but the use cases for my macro are limited so I decided to keep it simple.


Bryan Ray wrote:I'm fairly sure GetConnectedOutput():GetTool() would only have found the last node inside the macro, which probably doesn't have the controls you'd want to read.

You're right. So I ended up moving the controls to the last node of the macro as a workaround.


Andrew Hazelden wrote:Entry level project: Developing an advanced Camera Crane Rig.
https://www.steakunderwater.com/wesuckl ... f=6&t=1821

Thanks. I was able to get the input node with self:GetSourceTool().



Thank you all for your insight.

Return to Fusion

Who is online

Users browsing this forum: Bryan Ray and 9 guests