From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LV Scripting how to get all diagram object references.

Solved!
Go to solution

Hello,

 

I'm trying to find a way to get a list of all diagram object for a given VI.  I have tried the method "Diagram - AllObjects[]", but this function returns references to the main objects of the diagram, not all the objects recursively that are located inside these main objects.  Is there a method to do so? If not, is there a way to do it recursively? I did not found anything so far.

 

Thanks,

 

Michel

0 Kudos
Message 1 of 6
(2,966 Views)

Search for "Traverse for GObjects.vi"

 

 

0 Kudos
Message 2 of 6
(2,949 Views)

Oh, so simple.

 

Now, let say I want to search for the object "SharedVariableNode".  Is it possible from the references returned by "Traverse for GObjects" to extract the library name of the shared variable?

 

Thanks,

 

Michel

0 Kudos
Message 3 of 6
(2,940 Views)

Is it possible from the references returned by "Traverse for GObjects" to extract the library name of the shared variable?\



Yeah, VI scripting has made life easier...!!

 

Shared Variable Owner's Refnum


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 4 of 6
(2,926 Views)

I think that this is valid when you have a shared variable reference.  In the case of the "Traverse for GObjects" function the references returned are not a shared variable references.

 

So to simplify things I have attached a simple project with two libraries one called "toto.lvlib" and the other one called "toto2.lvlib", one VI "toto.vi" and in it's block diagram I have put the shared variable "What is my owning library name?" from "toto.lvlib" and "What is my owning library name 2?" from "toto2.lvlib".

 

My question is:  How can I programmatically knows how many objects are in the block diagram that are shared variable type and for these shared variable I'd like to know the owning library?  Is this possible with VI scripting?

 

In addition to this, would it be possible to do this operation recursively into the sub VI's of a top level VI?

 

Thanks in advance.

 

Michel

 

 

0 Kudos
Message 5 of 6
(2,899 Views)
Solution
Accepted by topic author Michel_Gauvin

Check the attached file.

 

Edited:


In addition to this, would it be possible to do this operation recursively into the sub VI's of a top level VI?


Oops I missed the recursive part, you still will be able to use the code presented in the attached VI, however you need to provide the VI/subVI references recursively.

Recursive


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


Message 6 of 6
(2,885 Views)