From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Scripting: Find wire class type

Solved!
Go to solution

I am trying to create a Right-Click Shortcut that will distinguish between a wire of class A and a wire of class B when deciding which option(s) to add to the menu. Actually, more specifically what I really want to know is whether the wire is of a class that inherits from class A.

 

I got the reference of the Wire, then got the Data Type from an associated Terminal. so I know it's a Class.

The question is... how do I know WHICH class?

I have learned that you can't cast the Data Type wire (didn't figure), and I don't see a Value property on either Wire or Terminal.

And oddly enough, neither Wire nor Terminal seem to have nay Dependencies, despite the fact that the wire is of a type that must have an associated *.lvclass file.

 

Any Idea how to do this? Stumped so far...

0 Kudos
Message 1 of 11
(3,870 Views)

Hi Rob,

I'm not scripting expert, so I hope I didn't misinterpret the question. You can get a kind of cryptic string with the class name if you look at the terminal data type as below.

scripting wire type.PNG

Message 2 of 11
(3,849 Views)

wt.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 3 of 11
(3,836 Views)

If you get the type variant you can use this to get the class type.

 

http://zone.ni.com/reference/en-XX/help/371361P-01/glang/get_labview_class_information/

 

Then you can get the class hierachy

 

http://zone.ni.com/reference/en-XX/help/371361L-01/glang/get_class_hierarchy_from_class_name/

 

 

Matt J | National Instruments | CLA
Message 4 of 11
(3,834 Views)

wt.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 5 of 11
(3,791 Views)

Thanks for all the responses... I've got something that works seems like should work now.

 

Here's where I ended up...

 

Untitled.png

Unfortunately, the Class Hierachy comes back empty.even though it should not. I suspect that it is because the plugin is operating in a different application space and the class is not loaded in that space. Can someone confirm?

0 Kudos
Message 6 of 11
(3,715 Views)

Jacobson...Can you post a working example? As you can see from my latest post, you suggestion does not actually seem to work (at least for me)

0 Kudos
Message 7 of 11
(3,707 Views)

@10Things_Rob wrote:

Jacobson...Can you post a working example? As you can see from my latest post, you suggestion does not actually seem to work (at least for me)


I didn't look at the help close enough it seems. That VI only works for things which will appear in the class specifier constant so it's limited to VI server classes basically. I had used that VI to find the earliest common ancestor (latest?) but I was only working with VI server classes.

 

When I get into work I'll see if I can find something else.

Matt J | National Instruments | CLA
0 Kudos
Message 8 of 11
(3,685 Views)

I believe the get class hierchy from class name refers to GObjects, not 'LabVIEW' objects. From the class name, you can get the class path - 'get LV class default value by name', then get the path with the default value of the class. (there may be a better way to get the class path) Once you have the path, open a reference to the class - (Application Invoke node, LVClass.Open) and use the parent class property of the class to get parent classes (just loop up the parent class references as far as you want to go)

 

 

0 Kudos
Message 9 of 11
(3,681 Views)

I knew DCAF loads classes and has to separate them into different buckets based on what they inherit from. I looked it up and DCAF uses the following VI from vi.lib

 

C:\Program Files (x86)\National Instruments\LabVIEW 2017\vi.lib\Utility\LVClass\Read Class Ancestry Without Loading.vi

 

Class Ancestry.png

Matt J | National Instruments | CLA
0 Kudos
Message 10 of 11
(3,675 Views)