LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting: Obtaining name of LVClass wrapped in DVR

Solved!
Go to solution

 

There is a need to identify an LVClass wrapped in a Data Value Reference (DVR). This is a test VI (LabVIEW 2021). The DVR control and the DVR constant are of the same type.

 

T1.gif

 
 

The name of the class can be obtained from the DVR control by gradually accessing the nested LabVIEWClassControl. No problem here.

 

S1.gif

 

I can obtain the same name from the class constant, which is not wrapped in a DVR.

 

S2.gif

 

 

However, the DVR constant puzzles me. I can gradually obtain a reference to LabVIEWClassConstant.

 

S3.gif

 

But this data type has no property LabVIEWClassName. An attempt to obtain the value results in error 1048 (only if the property is connected to something).

 

S4.gif

 

Bingo! Hacking this reference gives the result. It is crazy, but it works.

 

S5.gif

 

What am I doing wrong? What is the right (non-hacking) way to obtain the LVClass name from the wrapped LabVIEWClassConstant?

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
Message 1 of 15
(606 Views)

Could inspect the Variant directly with the data type parsing palette.

variant inspection.png

 

Edit: fair warning I always want to mention when I point people here, any variant returned by this library will have the default value for the type of the variant, for a LVObject that's the class of the wire that was converted to variant rather than on the wire, and it cannot pull the actual value out of a refnum because it operates on the type of refnum not value.

Message 2 of 15
(581 Views)
Solution
Accepted by topic author _Y_

Hi _Y_,

 

It is actually not the only example where you have to type cast a reference to achieve VI scripting tasks.

 

Some other examples:

https://discord.com/channels/1015999107921354932/1121475981912330311/1489603287798775819

https://discord.com/channels/1015999107921354932/1121475981912330311/1489654687845318846

 

also talks about this in his VI Scripting presentation (slide 48).

 

Regards,

Raphaël.

 

EDIT: avogadro5's solution would work if you got the variant value of the DVR constant first, but strangely you have to upcast the DVR constant to a generic constant to be able to select property "Value".

0 Kudos
Message 3 of 15
(578 Views)

avogadro5, could you describe your idea in more details? You modified the VI under test but the script is the same.

 

Thank you, Raphaël. Darrens presentation shows that the crazy type conversions are not something unusual. This is the answer.

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
Message 4 of 15
(513 Views)

You can probably save some scripting by just getting the "Value" property for each of the GObject types you're inspecting and passing it into the data type parsing VIs I showed. It's an alternate, probably faster, way of doing what you're doing.

 
0 Kudos
Message 5 of 15
(490 Views)

@_Y_ wrote:

 

...

 

But this data type has no property LabVIEWClassName. An attempt to obtain the value results in error 1048 (only if the property is connected to something).

 

S4.gif

 


That's because when you don't wire the output of a property, the code that would retrieve the property isn't executed.

0 Kudos
Message 6 of 15
(470 Views)

@paul_a_cardinale wrote:

That's because when you don't wire the output of a property, the code that would retrieve the property isn't executed.


Yes. This code shows that the value cannot be obtained. Thus cannot be used to get the class name in the same way as it works for LabVIEWClassConstant

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 7 of 15
(457 Views)

This seems to work?

Skärmbild 2026-04-07 175252.png

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 8 of 15
(403 Views)
 

Screenshot 2026-04-07 153400.png

 I attached an example using the data type palette. No hacking required just an upcast to Constant so the Value property exists.

0 Kudos
Message 9 of 15
(380 Views)

 wrote:

This seems to work?


Sorry, my question is about parsing an external VI with scripting.

 


@avogadro5 wrote:
 

Seems, DVR of Cluster of Class to Class Name.vi is missed in the attached ZIP:(

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 10 of 15
(369 Views)