[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]

#1

Post by DCTurner » Tue Sep 11, 2018 10:31 am

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
(5.09 KiB) Downloaded 25 times

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

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

#2

Post by SecondMan » 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! :cheer:

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

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

#3

Post by nsf » Thu Sep 13, 2018 8:48 am

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

#4

Post by DCTurner » Thu Sep 13, 2018 3:05 pm

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! :cheer:
hah, now I'm self conscious :D

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.

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

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

#5

Post by Movalex » Sun Sep 16, 2018 12:12 am

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.
Code: [Select all] [Expand/Collapse] [Download] (LineUpHoriz.lua)
  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:

Image
Attachments
LineUpVert.lua
(558 Bytes) Downloaded 2 times
LineUpHoriz.lua
(589 Bytes) Downloaded 2 times

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

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

#6

Post by Movalex » Thu Mar 21, 2019 11:23 am

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
(2.82 KiB) Downloaded 4 times

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

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

#7

Post by SecondMan » Thu Mar 21, 2019 11:50 pm

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

#8

Post by DCTurner » Fri Mar 22, 2019 2:35 am

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