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 (25.03 KiB) Viewed 1279 times
The second method I found that the error occurred in this function: connected = main_input. GetConnectedOutput ()