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

Moderator: SecondMan

User avatar
DCTurner
Posts: 8
Joined: Mon Sep 03, 2018 5:14 pm
Been thanked: 1 time

[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
You do not have the required permissions to view the files attached to this post.

User avatar
SecondMan
Site Admin
Posts: 3774
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 7
Location: Vancouver, Canada
Been thanked: 146 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: 229
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" :)

User avatar
DCTurner
Posts: 8
Joined: Mon Sep 03, 2018 5:14 pm
Been thanked: 1 time

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
Sir Requestalot
Posts: 154
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 44 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
You do not have the required permissions to view the files attached to this post.

User avatar
Movalex
Sir Requestalot
Posts: 154
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 44 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
You do not have the required permissions to view the files attached to this post.

User avatar
SecondMan
Site Admin
Posts: 3774
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 7
Location: Vancouver, Canada
Been thanked: 146 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?

User avatar
DCTurner
Posts: 8
Joined: Mon Sep 03, 2018 5:14 pm
Been thanked: 1 time

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 👍👍

User avatar
Movalex
Sir Requestalot
Posts: 154
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 44 times
Contact:

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

#9

Post by Movalex » Thu Oct 17, 2019 11:25 pm

Hi, @DCTurner! Here's an updated version, that will work with Fusion16.
Please check it out.
com.DcTurner.CleanFlow.zip
@SecondMan, here's a merge request number 100! Is there an achievement for that? :D
https://gitlab.com/WeSuckLess/Reactor/m ... quests/100
You do not have the required permissions to view the files attached to this post.

User avatar
DCTurner
Posts: 8
Joined: Mon Sep 03, 2018 5:14 pm
Been thanked: 1 time

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

#10

Post by DCTurner » Fri Oct 18, 2019 2:54 am

Hey @Movalex,

Thanks! I've been away from Fusion for ages, stuck in AE for a few months. I'll try to find a chunk of time to resubmit, but I absolutely don't mind if you want to submit that version of CleanFlow as your own, I'm not precious about it and would rather have better tools out there for everyone to use :D

If you need to rename it etc, that's 100% fine by me.

User avatar
SecondMan
Site Admin
Posts: 3774
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 7
Location: Vancouver, Canada
Been thanked: 146 times
Contact:

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

#11

Post by SecondMan » Fri Oct 18, 2019 9:43 am

Thanks @DCTurner and @Movalex !

Merge request 100 - we should perhaps indeed mark the occasion ;)

Thank you for doing the change log in the script as well! With Fuses and Scripts there has always been a tradition of putting a change log at the top of the code, especially with multiple people working on it. It's a nice thing in two ways, to keep track of changes of course, and also to be able to give credit when building on work from someone else. Should put that in best practices somewhere :)

As with all of these things, there's no strict laws about them, but it's both a useful and kind to do so it fits the We Suck Less paradigm nicely ;)

User avatar
SirEdric
Fusionator
Posts: 2056
Joined: Tue Aug 05, 2014 10:04 am
Answers: 4
Real name: Eric Westphal
Been thanked: 161 times
Contact:

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

#12

Post by SirEdric » Fri Oct 18, 2019 9:46 am

SecondMan wrote:
Fri Oct 18, 2019 9:43 am
the We Suck Less paradigm
Ooooh! Coool! Shouldn't we call it 'The Codex'?