Page 1 of 1

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

Posted: Tue Sep 11, 2018 10:31 am
by DCTurner
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

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

Posted: Wed Sep 12, 2018 10:16 pm
by SecondMan
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:

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

Posted: Thu Sep 13, 2018 8:48 am
by nsf
this one is really nice, a little bit closer to the "Houdini aligning" :)

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

Posted: Thu Sep 13, 2018 3:05 pm
by DCTurner
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.

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

Posted: Sun Sep 16, 2018 12:12 am
by Movalex
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

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

Posted: Thu Mar 21, 2019 11:23 am
by Movalex
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

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

Posted: Thu Mar 21, 2019 11:50 pm
by SecondMan
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?

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

Posted: Fri Mar 22, 2019 2:35 am
by DCTurner
Ooh, good stuff, I'll take a look over the weekend 👍👍

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

Posted: Thu Oct 17, 2019 11:25 pm
by Movalex
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

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

Posted: Fri Oct 18, 2019 2:54 am
by DCTurner
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.

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

Posted: Fri Oct 18, 2019 9:43 am
by SecondMan
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 ;)

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

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