Jump to: Board index » General » Fusion

How Python gets input nodes of nodes

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

moore_wang

  • Posts: 21
  • Joined: Mon Sep 17, 2018 1:47 am
  • Real Name: wangjian

How Python gets input nodes of nodes

PostTue Dec 18, 2018 7:44 am

I want to use Python to get the input node of the node, but I can't find a way to get it. In Fusion 8 Script Manual. pdf, I found a similar function to get the input node, but I won't use this function. PlainOutput. GetConnectedInput (). Can you tell me how to use this function? Or are there other ways to get input nodes? Thank you!
Offline
User avatar

Roy Nieterau

  • Posts: 50
  • Joined: Wed May 20, 2015 2:02 pm
  • Location: Utrecht, The Netherlands

Re: How Python gets input nodes of nodes

PostThu Dec 20, 2018 9:18 am

Here's some Python example code with comments to explain what it is doing.

To test this, create a Merge tool and connect something to the main "background" input.
Code: Select all
# Get currently selected tools for current comp
tools = comp.GetToolList(True).values()
# Get the first tool in the selection
tool = tools[0]
# Get the connected output for the tools "Background" input (explicitly by input name)
print tool["Background"].getConnectedOutput()


If you want to do it for any tool and don't want to find it by the name of the attrbute like above, you can use FindMainInput with the index of the main input (starting at 1). So doing the same:

Code: Select all
# Get currently selected tools for current comp
tools = comp.GetToolList(True).values()
# Get the first tool in the selection
tool = tools[0]
# Get the first main input of the tool
main_input = tool.FindMainInput(1)
# Get the connected output to this input
connected = main_input.GetConnectedOutputs()

# And to get the actual tool it's connected to...
connected_tool = connected.GetTool()
Offline

moore_wang

  • Posts: 21
  • Joined: Mon Sep 17, 2018 1:47 am
  • Real Name: wangjian

Re: How Python gets input nodes of nodes

PostSat Dec 29, 2018 8:52 am

Roy Nieterau wrote:Here's some Python example code with comments to explain what it is doing.

To test this, create a Merge tool and connect something to the main "background" input.
Code: Select all
# Get currently selected tools for current comp
tools = comp.GetToolList(True).values()
# Get the first tool in the selection
tool = tools[0]
# Get the connected output for the tools "Background" input (explicitly by input name)
print tool["Background"].getConnectedOutput()


If you want to do it for any tool and don't want to find it by the name of the attrbute like above, you can use FindMainInput with the index of the main input (starting at 1). So doing the same:

Code: Select all
# Get currently selected tools for current comp
tools = comp.GetToolList(True).values()
# Get the first tool in the selection
tool = tools[0]
# Get the first main input of the tool
main_input = tool.FindMainInput(1)
# Get the connected output to this input
connected = main_input.GetConnectedOutputs()

# And to get the actual tool it's connected to...
connected_tool = connected.GetTool()


Thank you for answering my question, but I can't get anything with your method.

Py2> # Get currently selected tools for current comp
tools = comp.GetToolList(True).values()
# Get the first tool in the selection
tool = tools[0]
# Get the connected output for the tools "Background" input (explicitly by input name)
print tool["Background"].getConnectedOutput()
Traceback (most recent call last):
File "<nofile>", line 6, in <module>
TypeError: 'NoneType' object is not callable
Py2> # Get currently selected tools for current comp
tools = comp.GetToolList(True).values()
# Get the first tool in the selection
tool = tools[0]
# Get the first main input of the tool
main_input = tool.FindMainInput(1)
# Get the connected output to this input
connected = main_input.GetConnectedOutputs()

# And to get the actual tool it's connected to...
connected_tool = connected.GetTool()
Traceback (most recent call last):
File "<nofile>", line 8, in <module>
TypeError: 'NoneType' object is not callable

QQ截图20181229164626.png
QQ截图20181229164626.png (25.03 KiB) Viewed 1279 times


The second method I found that the error occurred in this function: connected = main_input. GetConnectedOutput ()
Offline

moore_wang

  • Posts: 21
  • Joined: Mon Sep 17, 2018 1:47 am
  • Real Name: wangjian

Re: How Python gets input nodes of nodes

PostSun Dec 30, 2018 12:57 am

moore_wang wrote:
Roy Nieterau wrote:Here's some Python example code with comments to explain what it is doing.

To test this, create a Merge tool and connect something to the main "background" input.
Code: Select all
# Get currently selected tools for current comp
tools = comp.GetToolList(True).values()
# Get the first tool in the selection
tool = tools[0]
# Get the connected output for the tools "Background" input (explicitly by input name)
print tool["Background"].getConnectedOutput()


If you want to do it for any tool and don't want to find it by the name of the attrbute like above, you can use FindMainInput with the index of the main input (starting at 1). So doing the same:

Code: Select all
# Get currently selected tools for current comp
tools = comp.GetToolList(True).values()
# Get the first tool in the selection
tool = tools[0]
# Get the first main input of the tool
main_input = tool.FindMainInput(1)
# Get the connected output to this input
connected = main_input.GetConnectedOutputs()

# And to get the actual tool it's connected to...
connected_tool = connected.GetTool()


Thank you for answering my question, but I can't get anything with your method.

Py2> # Get currently selected tools for current comp
tools = comp.GetToolList(True).values()
# Get the first tool in the selection
tool = tools[0]
# Get the connected output for the tools "Background" input (explicitly by input name)
print tool["Background"].getConnectedOutput()
Traceback (most recent call last):
File "<nofile>", line 6, in <module>
TypeError: 'NoneType' object is not callable
Py2> # Get currently selected tools for current comp
tools = comp.GetToolList(True).values()
# Get the first tool in the selection
tool = tools[0]
# Get the first main input of the tool
main_input = tool.FindMainInput(1)
# Get the connected output to this input
connected = main_input.GetConnectedOutputs()

# And to get the actual tool it's connected to...
connected_tool = connected.GetTool()
Traceback (most recent call last):
File "<nofile>", line 8, in <module>
TypeError: 'NoneType' object is not callable

QQ截图20181229164626.png


The second method I found that the error occurred in this function: connected = main_input. GetConnectedOutput ()



I see. Thank you for your reply. I found that in'connected = main_input. GetConnectedOutput ()'

The plural form was used, so the error was reported.

Return to Fusion

Who is online

Users browsing this forum: jsghost777 and 28 guests