Tuesday, October 27, 2009

Progress Report #1 - The Block Diagram Cleanup Experiment

As I mentioned a few months ago, I am attempting to use Block Diagram Cleanup for 100% of my diagram arrangement needs in LabVIEW 2009. I figured I might post updates every once in a while detailing my progress. So here, in no particular order, are some of my observations and impressions after heavy use of block diagram cleanup for a few months:
  • It Creates Big Diagrams - When left to my own devices, I create tight diagrams with very little whitespace. I have very quickly discovered that diagram cleanup is rather liberal with its allocation of whitespace. :) Typically this is because I've got a moderately nested diagram, and diagram cleanup doesn't quite know how to allocate space in each frame of a multiframe structure such that whitespace is minimized. I imagine this would be a rather difficult problem to solve, since it would require the repositioning algorithm to simultaneously keep track of the spacing in each frame of a multiframe structure.
  • It Doesn't Respect My Window Size - Along similar lines, the diagram gets resized and often goes past the height and/or width of the diagram window. Sometimes I have diagram windows set to a particular size for a reason, and if I were arranging the diagram myself, I would fit the diagram within those window bounds. I wish we could constrain diagram cleanup to the current diagram's window bounds.
  • It Creates Bendy Wires - I've always been very careful to minimize the number of bends in my wires, maybe because my boss was always very picky about it. In fact, he's the one who insisted "Wire Bends" be a test that shipped with VI Analyzer 1.0! Anyway, diagram cleanup doesn't seem to be so concerned about wire bends. From what little I know about the cleanup algorithm, this makes sense because the algorithm is very much concerned with node placement, and not so much wire placement (except for its strict insistence on keeping error wires straight, which I like). But if you've got nodes that you've arranged just to keep non-error wires straight, diagram cleanup will not take this into account when rearranging. Also, if you've got constants wired to things, and you've got the constants positioned to minimize wire bends, I frequently see the constant moved, and wires bent as a result.
  • It Moves My Control Terminal Labels - I like my control terminals on the sides (left for controls, right for indicators)...in fact, I added the Ctrl-Space-Ctrl-T shortcut in LabVIEW 2009 to make it easier to perform this operation in bulk for all top-level terminals on the diagram. But I've noticed my terminal labels get moved by cleanup, and it doesn't look like something that's configurable.
  • But...I Code Faster - Despite its shortcomings, block diagram cleanup allows me to code *much* faster than I do when arranging the diagram myself. I don't have any specifics, but I'd estimate that I write VIs about twice as fast as normal when I spend zero time arranging diagram objects myself.
These are my first impressions of block diagram cleanup, with just a few months of LabVIEW 2009 development (on a mishmash of small projects). But right now, I'm in the beginning stages of writing a LabVIEW Class-based prototype for a LabVIEW Scripting architecture for my current project. I hope to post more detailed observations as I become more involved in this adventure.


  1. The diagram explosion and overly bent wires are definitely what I find to be the biggest pain points.

    What's particularly annoying about the wires is that there's no good reason for them to have multiple bends. If you invoke a manual cleanup on the wire, it usually comes out with considerably fewer bends. It seems to me that if the algorithm called a cleanup on each wire after it finished cleaning, the result would be better (although this might hurt performance).

  2. Fun experiment:
    Create a control and indicator of matching type.
    Line these two up.
    Create an exesive bendy wire in between.
    Only select the wire with triple-click.
    Select auto-cleanup.
    In LabVIEW 2009, this action is a no-op.


  3. Ton,

    That's expected behavior to me, since Diagram Cleanup is focused on node placement, and not wire placement. If you take any arbitrary diagram and multi-select an arbitrary number of wires, I'm pretty sure you'll see a no-op there as well.

  4. I haven't moved my client to LV2009 yet, so I haven't used the Code Cleanup 2009 myself. But if expands the diagrams, bends the wires and moves the labels where IT wants to, then I still have to go along behind it and clean things up to fit my own standards.
    If that's the case, I don't see how I could get to the "twice as fast" point, as you have.
    What does it actually do FOR you, that saves you that much time?

  5. I'm not going back to clean up after it. I'm basically declaring its results "clean enough". That's how I'm twice as fast now. And I'm sending feedback to the diagram cleanup team on things I would like to see it do better (like all the stuff in this blog post).

  6. I have found that if you select a case structure and clean it up by itself, the case is small. Then if you right-click on it and disable cleanup on that case structure, then cleanup the next outer loop, the inner one stays tight. Then you can progressivly cleanup your code without so much sprawl.