Select Upstream / Downstream Nodes

User avatar
Protean
Posts: 40
Joined: Mon Nov 03, 2014 12:37 pm
Location: www.axisanimation.com

Select Upstream / Downstream Nodes

#1

Post by Protean » Tue Apr 25, 2017 6:28 am

Hi,

Is there already a function to select nodes up or downstream as per the context menu?

Cheers

J

User avatar
pingking
Fusionista
Posts: 729
Joined: Thu Aug 14, 2014 9:10 am
Been thanked: 8 times

Re: Select Upstream / Downstream Nodes

#2

Post by pingking » Tue Apr 25, 2017 12:13 pm

well, i think the only way is still to write the functions for yourself

start here:

http://pigsfly.com/index.php?/topic/471 ... entry16271

User avatar
Kristof
Fusionista
Posts: 545
Joined: Thu Aug 07, 2014 1:30 pm
Answers: 1
Been thanked: 16 times

Re: Select Upstream / Downstream Nodes

#3

Post by Kristof » Tue Apr 25, 2017 3:18 pm

You can: rmb on a node and go to the "select" section and tadaaa!

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

Re: Select Upstream / Downstream Nodes

#4

Post by Midgardsormr » Tue Apr 25, 2017 3:45 pm

I think he's looking for a script solution.

There's something like that going on in the Connect Mask Stack script in VFXPedia:

Code: Select all


while myStackTool.EffectMask:GetConnectedOutput() do
	myTool = myStackTool.EffectMask:GetConnectedOutput():GetTool()
		
	myStackTool = myTool
end


User avatar
SecondMan
Site Admin
Posts: 3415
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 3
Location: Vancouver, Canada
Been thanked: 78 times
Contact:

Re: Select Upstream / Downstream Nodes

#5

Post by SecondMan » Tue Apr 25, 2017 5:02 pm

This one works for upstream selection, based on Isaac's example on Pigsfly and adjusted to work in Fu8:
Code: [Select all] [Expand/Collapse] [Download] (SelectUpstream.lua)
  1. local flow = comp.CurrentFrame.FlowView
  2.  
  3. function recurseSelect(t)
  4.     -- if the current tool has image inputs, select them, otherwise return nil
  5.     flow:Select(t)
  6.    
  7.     for i, inp in pairs(t:GetInputList()) do
  8.  
  9.         if valid_types[inp:GetAttrs().INPS_DataType] then
  10.             local output = inp:GetConnectedOutput()
  11.             if output then
  12.                 recurseSelect(output:GetTool())
  13.             end
  14.         end
  15.     end
  16.    
  17. end
  18.  
  19. valid_types = {
  20.     Image = true,
  21.     Particles = true,
  22.     Mask = true,
  23.     DataType3D = true,
  24.     }
  25.  
  26. flow:Select() -- clear current selections
  27.  
  28. recurseSelect(tool)

User avatar
Protean
Posts: 40
Joined: Mon Nov 03, 2014 12:37 pm
Location: www.axisanimation.com

Re: Select Upstream / Downstream Nodes

#6

Post by Protean » Mon Jun 12, 2017 7:11 am

Super thanks. The need for this passed quite quickly but it's very useful.

Cheers,

John

grace_mick
Posts: 5
Joined: Sat Aug 10, 2019 4:46 pm
Location: Russia, Moscow
Real name: Dima Dragun
Contact:

Re: Select Upstream / Downstream Nodes

#7

Post by grace_mick » Tue Aug 13, 2019 4:12 pm

SecondMan wrote:
Tue Apr 25, 2017 5:02 pm
This one works for upstream selection, based on Isaac's example on Pigsfly and adjusted to work in Fu8:
Code: [Select all] [Expand/Collapse] [Download] (SelectUpstream.lua)
  1. local flow = comp.CurrentFrame.FlowView
  2.  
  3. function recurseSelect(t)
  4.     -- if the current tool has image inputs, select them, otherwise return nil
  5.     flow:Select(t)
  6.    
  7.     for i, inp in pairs(t:GetInputList()) do
  8.  
  9.         if valid_types[inp:GetAttrs().INPS_DataType] then
  10.             local output = inp:GetConnectedOutput()
  11.             if output then
  12.                 recurseSelect(output:GetTool())
  13.             end
  14.         end
  15.     end
  16.    
  17. end
  18.  
  19. valid_types = {
  20.     Image = true,
  21.     Particles = true,
  22.     Mask = true,
  23.     DataType3D = true,
  24.     }
  25.  
  26. flow:Select() -- clear current selections
  27.  
  28. recurseSelect(tool)
Thank you so much for your tool!
Unfortunately it's not work with FU9 and DVR16. Could you help solve the incompatibility?

User avatar
Movalex
Fusioneer
Posts: 108
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 22 times
Contact:

Re: Select Upstream / Downstream Nodes

#8

Post by Movalex » Fri Aug 16, 2019 7:37 am

@grace_mick Here's a tool scripts I wrote based on mentioned code to select upstream/downstream nodes.
I call them "select forward/ select backward", because up/downstream for me is a concept impossible to remember :)
Unfortunately they are too slow in comparison with native Select-Upstream tool. Still looking for best algorighm for this task.
You do not have the required permissions to view the files attached to this post.

grace_mick
Posts: 5
Joined: Sat Aug 10, 2019 4:46 pm
Location: Russia, Moscow
Real name: Dima Dragun
Contact:

Re: Select Upstream / Downstream Nodes

#9

Post by grace_mick » Fri Aug 16, 2019 9:54 am

Movalex wrote:
Fri Aug 16, 2019 7:37 am
@grace_mick Here's a tool scripts I wrote based on mentioned code to select upstream/downstream nodes.
I call them "select forward/ select backward", because up/downstream for me is a concept impossible to remember :)
Unfortunately they are too slow in comparison with native Select-Upstream tool. Still looking for best algorighm for this task.
Cool! Thank yo so mach! Yeah work a little bit slow, but work :)
I try to make a hotkey

Code: Select all

SHIFT_B = "RunScript{filename = 'Scripts:/Tool/sel_backward.py'}",
but it's not work, as I understand RunScript command execute only comp script, not tool script. Is it possible to make a hotkey to tool script?

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

Re: Select Upstream / Downstream Nodes

#10

Post by Midgardsormr » Fri Aug 16, 2019 10:13 am

I am not sure if this will work on a hotkey or not, but try:

SHIFT_B = "RunScript{filename = 'Scripts:/Tool/sel_backward.py', tool = comp.ActiveTool }",

If that doesn't work, you could add the line tool = comp.ActiveTool to the top of the script itself, maybe after testing to see if the tool variable has already been set (as it would be if you ran it from the context menu).

grace_mick
Posts: 5
Joined: Sat Aug 10, 2019 4:46 pm
Location: Russia, Moscow
Real name: Dima Dragun
Contact:

Re: Select Upstream / Downstream Nodes

#11

Post by grace_mick » Fri Aug 16, 2019 10:30 am

Midgardsormr wrote:
Fri Aug 16, 2019 10:13 am
I am not sure if this will work on a hotkey or not, but try:

SHIFT_B = "RunScript{filename = 'Scripts:/Tool/sel_backward.py', tool = comp.ActiveTool }",

If that doesn't work, you could add the line tool = comp.ActiveTool to the top of the script itself, maybe after testing to see if the tool variable has already been set (as it would be if you ran it from the context menu).
Awesome! Thank you so much!
It work on follow setup:

add "tool = comp.ActiveTool" in sel_backward.py
  1. flow = comp.CurrentFrame.FlowView
  2. valid_types = ['Image', 'Particles', 'Mask', 'DataType3D']
  3.  
  4. tool = comp.ActiveTool
  5.  
  6. def recurse_select_backward(t):
  7.     # if the current tool has image inputs, select them, otherwise pass
  8.     flow.Select(t)
  9.     inp_list = (inp for inp in t.GetInputList().values()
  10.             if inp.GetAttrs()['INPS_DataType'] in valid_types)
  11.     for inp in inp_list:
  12.         next_out = inp.GetConnectedOutput()
  13.         if next_out:
  14.             tool = next_out.GetTool()
  15.             recurse_select_backward(tool)
  16.  
  17.  
  18. flow.Select()
  19. recurse_select_backward(tool)
move sel_backward.py in Scripts/Comp folder and in hotkeys change path

Code: Select all

SHIFT_B = "RunScript{filename = 'Scripts:/Comp/sel_backward.py'}",