08-13-2019 07:38 AM
I want to programmatically run the cleanup method on a subdiagram contained within a structure (a for-loop in this case). When I attempt to do so, as shown below, I get an error saying that LabVIEW cannot locate the cleanup method. Note: TargetVI.vi contains one for-loop.
ForLoop.Diagram.CleanUp
When I attempt to cleanup the entire VI I don't get the error. The two ways I try this are shown below.
VI.BD.CleanUp
ForLoop.Owner.CleanUp
Since you can cleanup selected parts of a VI using the cleanup tool in the editor I thought this has to be doable with VI scripting. Any idea what I might be doing wrong?
I am using LabVIEW 17.0.1f3 and I am attaching the VIs I used to take the screenshots here (in case anyone wishes to try to recreate this on their machine).
Thanks,
Ghassan
Solved! Go to Solution.
08-13-2019 09:19 AM
Some of the other methods for subdiagrams seem to be broken too.
But you can just select the objects in the For Loop, then use cleanup method for the top level diagram.
See attachment.
08-13-2019 10:41 AM
Hi,
it seems like there is no invoke-method for "clean selection". You can try something like:
1. copy the FOR loop into a blank VI
2. clean the block diagram there (which consists only of the loop)
3. copy it back into your target VI
4. connect the tunnels
5. remove the original loop
I tried an approach like that and came out with the attached code. Sorry for the huge mess.. I just don't have any more time right now...
PS: Error-wires deserve love, too 😉
08-13-2019 11:13 AM
If you add elements to the selection list then call the BD.Cleanup method (of the *VI* class), it will clean up the selection instead of the whole diagram.
08-14-2019 01:33 AM
@Darren wrote:
If you add elements to the selection list then call the BD.Cleanup method (of the *VI* class), it will clean up the selection instead of the whole diagram.
Works fine, I just tried it. But you have to make sure you add all object refs, all wire refs of the loop into the selection list and then add the loop reference last. If you put the loop ref in first the result is anything but "clean".
08-14-2019 03:00 AM
Thanks for all the replies!
Paul's suggestion is straightforward and definitely works. I didn't know that TopLevelDiagram.CleanUp (or VI.BD.CleanUp) could be limited to the selection only even with VI scripting. This is good to know. Thanks Darren for breaking this down and Crabman for taking the time to suggest the alternative method!