LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a strictly typed refnum control using LabVIEW scripting

Solved!
Go to solution

I wish to use LabVIEW scripting to create a strictly-typed refnum control that is bound to my custom control (a type-defined cluster), but I'm unfamiliar with scripting and can't see how to do it.

 

If I create a New VI Object, using Control Refnum as the Style, how do I provide my custom control to the VI Object Class terminal? When I try using a reference to my custom control.ctl file (using Open VI reference) I get an error: "Error 1057 occurred... Type mismatch: Object cannot be cast to the specified type."

 

Or, if I create a new Control Refnum as above, using a standard Cluster as the VI Object Class, how do I then convert this refnum control to a strictly typed refnum that is bound to my custom cluster control type?

 

Thanks in advance for any advice,

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 1 of 7
(11,251 Views)

Here we go...

 

You have to create a new Control VI and then specify the VI Type as Typedef.

 

example.png

 

Regards,

Da Helmut
Voir le profil de Maxime M. sur LinkedIn - View Maxime M.'s profile on LinkedIn
Message 2 of 7
(11,241 Views)

Hi Helmut,

 

Unfortunately, this isn't what I need. I need a strictly typed refnum control object, not a strictly typed control vi. In your example you created a boolean control object in a custom control vi. If you can instead create a Control Refnum object in a custom control vi which is bound to a custom cluster definition then that will help me. I can create one by hand easily, see illustration below, but I can't create one via scripting.

 

strict_refnum_ctl.jpg

Thoric (CLA, CLED, CTD and LabVIEW Champion)


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

Full Disclosure: I have not tried this.  However, you can usually figure out how to do a scripting operation by doing it manually, then doing it the same way with scripting.  I would try the following:

 

  1. Create your control
  2. Create a reference from your control (this will result in a reference constant)
  3. Convert the reference constant to a reference control
  4. Create a new control (new VI with proper options)
  5. Copy the reference control onto its front panel
  6. Convert to a strict typdef
  7. Save the typedef
  8. Delete your scratch VI, if desired.

Yes, I know it is convoluted.  There may be a much faster way, but I still need to finish my first cup of coffee...

 

Message 4 of 7
(11,222 Views)

Hi DFGray,

 

Actually, that's pretty much how I do it by hand, but I can't find a scripting method for step 3! Hence my plea.

 

Please tell me you know how to conduct step 3 ????? Smiley Tongue

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 5 of 7
(11,212 Views)
Solution
Accepted by Thoric

I tried it, and, as usual, things were slightly different.  The big issue is that a control reference constant becomes a Node, not a Constant, so cannot be converted to a control.  The good news is that you simply move it to the front panel of the new control, just like you would in the dev environment.  Here's the raw code (still needs cleanup to close refs and add save of the new control, plus, you don't need to show the control FP if you don't want to).

 

CreateTypedefControlRef.png

Message 6 of 7
(11,195 Views)

Excellent!

 

Thank you DFGray, this works just as I need! Smiley Happy

 

Many thanks indeed! My scripting optimism has been restored Smiley Tongue

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 7 of 7
(11,185 Views)