LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with project cleanup

I inherited a project several years ago. I duplicated and modified a lot of vi's, and generated a bunch of new ones, but most of the original files are still there. I finally have some time to do some cleanup. I've cleaned up a lot. I've removed a bunch of vi's from the project, and deleted the files. The project size is just over half of what it was. I still have previous versions with this project with all the old files if I ever need to use them or refer to them again. I'm going through items now, looking for vi's and controls that are aren't being used. I know how to do this on a one-by-one basis. Is there a tool or hack that would allow me to more quickly identify a list of unused vi's and controls in a project? I'm using LV 2017.

0 Kudos
Message 1 of 15
(372 Views)

You can remove all VIs from the project except the toplevel, then see which ones show up in dependencies. Move these back to the project structure where you had them before.

 

Everything you no longer need, won't be in dependencies.

 

(assuming you don't have stuff such as auto-populating folders, etc. Also of you call Vis via references obtained from filenames, you need to manually add those back.)

 

Of course your OS folders will still be full of stuff and you want to clean these up too.

0 Kudos
Message 2 of 15
(341 Views)

There's probably a more automated way to do this, but assuming you can define "VI's that are still used in the project" as "the tree of dependencies from Main.vi", you can use Get VI Dependencies (Names and Paths). Set "Whole Hierarchy?" to True, and it'll list everything you need to keep.

 

To make a list of what to get rid of, I'd suggest iterating over all items in the project using VI scripting and making a Set of all of the full path names for everything it finds. Then run Get VI Dependencies, and remove all of the items it returns from the first Set. Then you should have a list of everything that's not called either directly or indirectly from the main VI.

 

(Make sure you do some filtering, as you'll probably have plenty of false positives- stuff in vi.lib, other libraries, etc.) 

0 Kudos
Message 3 of 15
(338 Views)

I make a Source Distribution build with only the top-level VI.  Building it will collect all of the VIs called by that and put them neatly in another folder.  You'll just have to find any VIs that are called dynamically.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 4 of 15
(279 Views)

In the Project Explorer, you can right-click on the project and select Find Items with No Callers. Sort by path and ignore things in vi.lib.

 

You may use that in conjunction with these plugins: Delete file on disk from project explorer and Find Non-Project Files.

 

It sounds like you are not using source code control. You rellay should, it makes it a lot easier to track changes and go back to previous versions, including recovering deleted files.

0 Kudos
Message 5 of 15
(256 Views)

@cordm wrote:

In the Project Explorer, you can right-click on the project and select Find Items with No Callers. Sort by path and ignore things in vi.lib.

 


Just remember to do it multiple times- you may have a chain of VI's where C is called by B which is called by A, but A is never called. The first time through, you'll only find A. If you remove it, the next time through you'll only find B, etc.

Message 6 of 15
(247 Views)

@jcarmody wrote:

I make a Source Distribution build with only the top-level VI.  Building it will collect all of the VIs called by that and put them neatly in another folder.  You'll just have to find any VIs that are called dynamically.


One problem with a source distribution is that vital parts of the project won't make it, but it is typically sufficient to copy some files, such as the lvproj itself to the new location. Vital things that will be missing from a source distribution when forgetting the lvproj file is the project layout, the built specifications, as well as e.g. the installer upgrade codes.

 

(I have a pretty fancy "built all" VI (and entry in the tools menu!) that builds all existing built specifications of a project and adds suitable pre and post processing steps, including copying the lvproj file, bult everything into a special output location hierarchy that is not monitored by google drive (for good reason!), documents all steps as it goes, and even opens the toplevel destination folder when done.)

 

altenbach_0-1760113395475.png

 

0 Kudos
Message 7 of 15
(243 Views)

Thanks for the reply.

 

I have a couple of self-populating folders, but they don't contain vi's or controls.

 

Using dependencies... does this also imply that every vi that shows up in dependencies should be added to a project virtual folder?

0 Kudos
Message 8 of 15
(228 Views)

I can't find Get VI Dependencies in my LabVIEW (2017). I did a search, and got no hits. I'm also not familiar with scripting. Where can I learn about that?

0 Kudos
Message 9 of 15
(225 Views)

"In the Project Explorer, you can right-click on the project and select Find Items with No Callers."

 

I did not know that feature was there. Thank you. I'll try those plug-ins. Source control... I'm the only LabVIEW programmer in the building. There are probably a few more in the company somewhere, but they have nothing to do with this project. I'm not I could convince anyone to implement source control for this.

0 Kudos
Message 10 of 15
(224 Views)