## [Submission] CleanFlow - Quickly align nodes in the FlowView [SUBMITTED]

Moderator: SecondMan

DCTurner
Posts: 7
Joined: Mon Sep 03, 2018 5:14 pm

### [Submission] CleanFlow - Quickly align nodes in the FlowView  [SUBMITTED]

Howdy,

This is my first submission, so apologies if I'm doing anything majorly wrong

This is a simple pair of scripts to align selected nodes vertically / horizontally.
I made it for personal use and it has been pretty handy, so I thought I'd share

dt
Attachments
com.DcTurner.CleanFlow.zip

SecondMan
Posts: 3415
Joined: Thu Jul 31, 2014 5:31 pm
Been thanked: 78 times
Contact:

### Re: [Submission] CleanFlow - Quickly align nodes in the FlowView

Howdy!

Well done for your first submission, absolutely nothing wrong with it

Interesting code syntax with the variable names, I don't see that often - mind if I ask you where that came from?

And submitted, thanks!

nsf
Fusioneer
Posts: 228
Joined: Mon Aug 04, 2014 2:24 am
Contact:

### Re: [Submission] CleanFlow - Quickly align nodes in the FlowView

this one is really nice, a little bit closer to the "Houdini aligning"

DCTurner
Posts: 7
Joined: Mon Sep 03, 2018 5:14 pm

### Re: [Submission] CleanFlow - Quickly align nodes in the FlowView

SecondMan wrote:
Wed Sep 12, 2018 10:16 pm
Howdy!

Well done for your first submission, absolutely nothing wrong with it

Interesting code syntax with the variable names, I don't see that often - mind if I ask you where that came from?

And submitted, thanks!
hah, now I'm self conscious

I think that style comes from last year when I had to bash-together a quick Javascript project for a big client. I really don't like JS, and had to get heavy-handed with my variable scope conventions, just to keep everything clear.
I started using _VAR style names for locally-scoped temporary variables, and regular camelCase for class-level stuff.

^ this way I could look at a busy bit of code - nested loops and anonymous functions - and could instantly tell which scope each var belonged to.

I find it also helps me to focus on the working vars at any one time - they look radically different from API vars and methods too.
_POS <-- local position var that I'm using for something around here
vs
pos <-- Could be from anywhere (class, global, API)

It also helps me keep track of which vars can be destroyed and GarbageCollected at the end of the method.

Added in 1 minute 19 seconds:
I have noticed that these scripts can fail if you're using a non-standard window layout... Having the FlowView on a separate monitor, or having multiple flowViews open seems to prevent the scripts from working. I'll try to patch that at some point.

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

### Re: [Submission] CleanFlow - Quickly align nodes in the FlowView

Hi! This is a great script and useful for my workflow.
However I've found kind of a drawback: if the nodes have already the same X value, you cannot align them vertically, Instead they be stacked on each other.
Here's my change for LineSelected script which handles this issue. The same goes for Stack Nodes script.
1. fl = comp.CurrentFrame.FlowView
2.
3. comp:StartUndo("Align Tools Horizontally")
4. comp:Lock()
5. selected_tools = comp:GetToolList(true)
6. active_tool = comp.ActiveTool
7.
8. if active_tool == nil then
9.     active_tool = selected_tools[1]
10. end
11.
12. active_X, active_Y = fl:GetPos(active_tool)
13.
14. for pos, tool in pairs(selected_tools) do
15.     if tool ~= active_tool then
16.         _TEMP_X, _TEMP_Y = fl:GetPos(tool)
17.         -- check if nodes have the same X value
18.         if _TEMP_X == active_X then
19.             newpos = _TEMP_X + (pos - 1)
20.         else
21.             newpos = _TEMP_X
22.         end
23.         fl:SetPos(tool, newpos, active_Y)
24.     end
25. end
26.
27. comp:Unlock()
28. comp:EndUndo()
Here's the result:

Attachments
LineUpVert.lua
LineUpHoriz.lua

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

### Re: [Submission] CleanFlow - Quickly align nodes in the FlowView

Hi!
Here's a changes proposed for the Clean Flow script:

1) set shortcuts by default (ALT+H/ALT+V to align horizontally/vertically)
2) add check if tools have same X or Y value to switch between horizontal and vertical state,
3) some variables refactoring

diffs:
https://gitlab.com/WeSuckLess/Reactor/m ... 970e7c17b1
Attachments
com.DcTurner.CleanFlow.zip

SecondMan
Posts: 3415
Joined: Thu Jul 31, 2014 5:31 pm
Been thanked: 78 times
Contact:

### Re: [Submission] CleanFlow - Quickly align nodes in the FlowView

Some nice changes it looks like. Does this incorporate the functionality from your LineUpVert.lua and LineUpHoriz.lua scripts above?

I should give it a go, really

@DCTurner - are you around to take a look at these?

DCTurner
Posts: 7
Joined: Mon Sep 03, 2018 5:14 pm

### Re: [Submission] CleanFlow - Quickly align nodes in the FlowView

Ooh, good stuff, I'll take a look over the weekend