LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inline code from all subvi's into block diagram

LabVIEW has a hidden .ini option to enable a right click menu inem on SubVI called "Inline SubVI" which inlines the code from the SubVI into the block diagram.

 

Is there an option or a way to do this for **all** the SubVI's in a given VI? Basically, to flatten the entire VI structure into one giant block diagram. I do not care if the resulting gigantic block diagram is unreadable.

 

Why I need this:

I have a couple of VI's developed for some common tasks which are used as SubVI's in larger projects for customers. The said VI's (let's called them A-level VI's) have anywhere from 10 to 100 or more SubVI's. I should note here that the customer is buying also the source code for the main app, but not the source code for our A-level VI's (which all have to be locked).

So, if I want to use the A-level VI's in a customer project, I have to copy every subvi to the project folder. Compiled packed libraries are a good solution, but the problem is they only work for the LabVIEW version it was built for. 

Inlining everything into 1 big giant SubVI would solve the messy folder structure, reduce the number of files and simply make it easier for us to manage the customer projects.

0 Kudos
Message 1 of 3
(2,854 Views)

Well that is an interesting request and it can be done through scripting.  There is an Inline method that can do the same as the right click.  The attached code demonstrates it.  Open and run the Inline VI, and it will inline all VIs in the Main.vi.  Now not all VI's can be inlined in this way.  There was a thread on LAVA that discusses when some can't.  This method will probably throw an error if it can't but automatic error handling is turned off.

 

Also for your actual code you will probably want it to ignore VIs in vi.lib, or really under the LabVIEW install folder in general.  For this you'll want to get the path of the subVI and not inline it depending on where it comes from.  You'll also want this to work on all VIs recursivly in a directory.  For that use the recursive file list getting all VIs, and then using the Open VI Reference with the path for each VI.  You won't need the Undo methods in my test either but that just made it easy for me to revert changes.  Oh and then don't forget the save method on the VI after inlining the functions...I think that's everything.

Message 2 of 3
(2,831 Views)

You know that while inlining vis you 

1) loose functional globals functionality (saving data in unitialized shift registers)? 

2) might increase memory since LV will not be reusing subVI memory

 

Maybe there are better ways of distributing code? 

Source distribution (also to LLB if you do not like copying folders)? While building it, you can set password for all VIs. A-subVIs on top level.

Compile A-s into dll, distribute wrapper VIs?  Will require corresponding run-time engine only.

Invest time into folder structure (it is a great investment!)

0 Kudos
Message 3 of 3
(2,802 Views)