LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting - Change server class for control of type LVObjectRefNum

Solved!
Go to solution

How can I change the VI Server Class of a LVObjectRefNum control using scripting (i.e. like the following recording):

Do this using scripting?Do this using scripting?

Why I want to do this:

I want to get a list of supported properties for each VI Server Class type programatically. Many types have some sort of  Label property, but there is no common ancestor that can be used. This would allow me to read the Label.Text value for all supported types. For eaxmple all of the following inherit from GObject directly, but only a selection have label properties.

 

Label property present:

Pane

Splitter

Constant

 

Label property not present:

Decoration

Tunnel

 

LabVIEW_2018-07-25_12-47-44.png

I am hoping there is a list of avaialble VI Server Class types that I can easily index through to cover every type.



Using LV2018 32 bit

Highly recommended open source screen capture software (useful for bug reports).

https://getsharex.com/
0 Kudos
Message 1 of 7
(3,862 Views)
Solution
Accepted by topic author matt.baker

I used a class constant, which made it easier to set. You then have a ClassSpecifierConstant, that has a SetType method. If you set AllowAltName to true, it accepts class names. Note that the class specifier constant does not need a value to get the properties.

 

I don't see how to do this on controls. If you insist on using a control, I'd convert the control to constant, then set the type, and convert back. Or instead of converting, create an indicator\control from the constant if that's easier.

 

Just went through this process for the same reasons. Next step would be to call Get Property by the ID, so you'll need a table of property names vs. property ID's.

 

Very cool stuff. Since the results will need to be variants, I automatically handle arrays in my code. That allows me to call Get Label on a reference, or an array of references. So I can call Controls[], and wire the output to Get Label (using the same VI, specifying the property with a string).

 

My ultimate goal is to add methods, so I can do advanced search and replace queries. Methods are a bit more difficult though...

Message 2 of 7
(3,829 Views)

Scriptin Class Specifier Control.png

Something like this. Apparently, changing the constant to control returns an error. So as often with scripting, we need a workaround...

 

Obviously, all connections to the original control (connector pane, wiring, etc.) need to be restored.

 

An of course this code would be a lot easier if we had the API we're trying to make. I'm now actually at a point where the code I'm using to script my code can use my scripted code.

 

Lots of fun Smiley LOL.

Message 3 of 7
(3,827 Views)

Just for completeness, I prefer it like this:Scriptin Class Specifier Control Easy Way.png

A Property Node wired to it will stay wired, so it's easy to get all supported properties that way.

Message 4 of 7
(3,823 Views)

This is also being discussed here and it might be helpful to you as well.

 

 

Message 5 of 7
(3,817 Views)

ShaunR's method is pretty neat (learned something new), but for our purposes it won't be too useful I think. It needs a type, and the only way it will get one is by hardcoding it (or scripting).

 

I don't think there is a way we can produce reference types dynamically (e.g. by class name)?

0 Kudos
Message 6 of 7
(3,811 Views)

That's extremely helpful. Thanks very much for this!

I don't require it to be a control so that works perfectly.LabVIEW_2018-07-26_11-17-46.png

 

LabVIEW_2018-07-26_11-23-07.png

I'll have a proper read through now, but glad I have something that works.

 

 



Using LV2018 32 bit

Highly recommended open source screen capture software (useful for bug reports).

https://getsharex.com/
Download All
0 Kudos
Message 7 of 7
(3,807 Views)