Thursday, March 5, 2009

Bulk Creation of Controls and Indicators

In my previous blog post, Jason commented that it would be nice to have a utility that will create controls and indicators on diagram objects in bulk. I thought that was a good idea, and I decided to write a VI that gets us pretty darn's not quite a right-click option, but it's as close as I can get without getting a C-monkey to modify the LabVIEW source code for me, and without having plug-in VIs yet.

So put this VI in [LabVIEW 8.6]\project and restart LabVIEW. You'll now have a Tools > Create Controls and Indicators menu option. Select a few block diagram objects, then choose this menu option. It will create controls and indicators for any terminals of the selected object(s) that aren't already wired to something. This transaction is undoable/redoable as well.

I hope this VI is useful to people. I also had another motive for writing it, but you'll have to wait until my next blog post to find out what that was.


  1. nice !
    do you really have to hide the block diagram ? :(

  2. and could you make a version that only creates the "required" inputs.

    and as a continuation, add the possibility to set an output terminal as "required" (to enforce error handling that would be cool), this was dicussed some time ago on LAVA :-o

  3. NICE WORK DARREN!!! *tear*


  4. Very cool.

    Could you create a LV 8.5 version???


  5. I haven't tried the code, but isn't what you're decribing already coded into LabVIEW as "Create SubVI"?

  6. Antoine: Sorry, any VIs I post with scripting must be password-protected, since the feature is still considered internal. We're investigating ways to make it more accessible.

    Jaegen: I posted a version saved in 8.0 on the NI Forums:

    Phil: This utility helps when you have one or more objects on the diagram with multiple unwired terminals, and you want to create controls and indicators for those terminals. It's mainly useful for debugging, like passing values into a function/subVI and examining the outputs. Create SubVI is mainly useful when you have a bunch of stuff already wired up and you want to turn it into a subVI.

  7. D-

    Speaking of Create SubVI... Is there an INI token to have the default pattern set to 12 terminals? You mentioned a token for setting the default pattern for new VIs for folks using older versions of LabVIEW.

    (It would be great if Create SubVI would also wire the error clusters in the bottom terminals and auto run "Cleanup" -- I'll file suggestions for those.)

    Aside: You mentioned LabVIEW Scripting. What exactly is this? Do you use G or ...


  8. Jason: There is currently no way to assign a default connector pane pattern to VIs created with Create SubVI...I've certainly requested that feature be added a number of times, though!

    LabVIEW Scripting is an internal feature that gives you a G interface to interrogating, creating, and modifying VIs. Some enterprising users on have discovered some of its can learn more there for the time being.

  9. D-

    Thanks for the explanations.

    I've added my voice to yours with the following product suggestion (posting it here in case there folks who want to join us):

    Create SubVI: I almost never use this function... but it could be so nice!

    Imagine being able to develop code on the mainVI diagram, check functionality in line, and quickly generate a subVI. We're so close with "Create SubVI", but in 7 years, I've never really used it. May I suggest a few tweaks?

    1) Use default connector pane (12 terminals)
    2) If there are error clusters, wire them to the bottom terminals.
    3) If there are error clusters, auto create a case structure and put the code in the No Error case. Wire the error cluster through the Error case.
    4) If there are in and out references (e.g. File In, File Out), wire these to the top terminals.
    5) Run Clean Up Diagram.


  10. Jason,

    I think that would definitely be the ideal behavior for Create SubVI. Thanks for submitting the suggestion.