Jump to: Board index » General » Fusion

Mirror selected nodes position in flow

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

Jon Angelo Gjetting

  • Posts: 7
  • Joined: Wed Aug 05, 2015 1:20 am
  • Location: Denmark

Mirror selected nodes position in flow

PostMon Jul 02, 2018 11:24 am

Is there a script or trick to mirror on X or Y the selected nodes position in a flow?

Thank you. :)

Sincerely

/Jon
/Jon Angelo Gjetting

mob.: +45. 2032 9223
http://www.GjettingCreative.com

twitter: http://twitter.com/#!/Gjetting
Skype: JonAngeloGjetting
LinkedIn:http://www.linkedin.com/in/jonangelogjetting
Offline

Sander de Regt

  • Posts: 3574
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Mirror selected nodes position in flow

PostMon Jul 02, 2018 12:30 pm

I don't know of such a trick, but what would you use it for?
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline
User avatar

michael vorberg

  • Posts: 943
  • Joined: Wed Nov 12, 2014 8:47 pm
  • Location: stuttgart, germany

Re: Mirror selected nodes position in flow

PostMon Jul 02, 2018 3:38 pm

And mirror at which line?
A script can be made to achieve that
Offline
User avatar

Bryan Ray

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

Re: Mirror selected nodes position in flow

PostMon Jul 02, 2018 3:50 pm

Just like with pixels or 3d points, you can perform a mirror by subtracting the location of your anchor point from each node's location, multiplying the new x coordinate of each node by -1, then adding the original displacement again to return them to their original location.

To get the location of a tool:
x, y = comp.CurrentFrame.FlowView:GetPos(tool)

To set the location of a tool:
comp.CurrentFrame.FlowView:SetPos(tool, x, y)

To get a list of selected tools:
tools = comp:GetToolList(true)

To perform an operation on each tool in the list:
for i, tool in ipairs(tools) do
<operation>
end


The tricky bit for this script is going to be determining which tool to use as the anchor.

You could do it arbitrarily: Let the script choose whichever tool is at the top of the list as the anchor.

Or you could present a dialogue to ask the user to pick which tool to serve as the anchor.

Or you could let the anchor be determined by a bounding box around the tools—the lower-left corner, for instance. That would require looping through all of the selected tools an additional time in order to get the boundaries.

Here's a script that uses option 1 and mirrors the nodes in the x direction:

Code: Select all
local tools = comp:GetToolList(true)
local offsetX, offsetY = comp.CurrentFrame.FlowView:GetPos(tools[1])
for i, tool in ipairs(tools) do
    local x, y = comp.CurrentFrame.FlowView:GetPos(tool)
    x = (x - offsetX) * -1 + offsetX
    comp.CurrentFrame.FlowView:SetPos(tool, x, y)
end


This needs to be run as a comp script because tool scripts will run once for each selected node, and that's definitely not what you want to happen!
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com

Return to Fusion

Who is online

Users browsing this forum: kayjee and 40 guests