LabVIEW APIs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Can you change a VISA Reference control's VISA class using scripting?

I need to change the VISA class of VISA Reference controls on dozens of VIs from "I/O Session -> Instr" to "I/O Session -> Serial Instr". I was hoping to build a scripting tool to do it, but don't see this property exposed by LV Scripting. Anyone know where I can find it, or can confirm it's not available? I see the Undo system can reverse changes to this (referring to it as "Undo Change Attribute"), so I suspect it's out there, just not obviously so.

 

Thanks,

Erik

0 Kudos
Message 1 of 7
(2,885 Views)

I'm not superfamiliar with how VISA refs work, but in the palettes aren't they all separate controls? So instead of changing an attribute, maybe you should be looking at replacing the control with the correct one?

 

Just a thought

Sam Taggart
CLA, CPI, CTD, LabVIEW Champion
DQMH Trusted Advisor
Read about my thoughts on Software Development at sasworkshops.com/blog
GCentral
0 Kudos
Message 2 of 7
(2,878 Views)

Hi Sam,

 

No, they're a unified control, unfortunately: 

 

ErikL68_0-1615572987169.png

 

At least, if they're not, NI's doing a good job disguising it!

 

It's rather annoying when I run into a project where they're left at "instr" when it's not necessary (and I haven't yet run into one where it was) as it leaves out what IMHO is useful functionality - especially with probes - that is added for the "Serial Instr" type.

 

Thanks,
Erik

0 Kudos
Message 3 of 7
(2,858 Views)

Please try with attached VI.

It will convert all VI Resource Name available on FP to Class Name you have Mentioned. You can provide either I/O session names or Event Class Names. 

0 Kudos
Message 4 of 7
(2,636 Views)

Hi Jalel,

 

Sorry, no, it doesn't seem to be working. I tried it on a VI with both a VISA Refnum control and indicator, both of class "I/O Session -> Instr", and tried to change them to "Serial Instr" and neither changed. The converter VI didn't throw an error either.

 

Please unlock the VI you next post. I prefer not to run anything that I can't see the source code behind unless it's from a trusted source, and you're not a trusted source, sorry! If the next version you post is password-locked, I won't be running it.

 

Thanks,
Erik




0 Kudos
Message 5 of 7
(2,630 Views)

The VI you want to change should probably be in memory. It doesn't save the VI after loading it and making the changes, so any edits will be lost if it is not in memory. This particular VI is harmless otherwise aside from using a private method to change the class name but indeed it is not wise to run random password protected VIs from the big wild web.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 7
(353 Views)

You can always copy a control that works for you to the clipboard (manually) and replace the control and indicators.

 

I do this for classes, and it's easier compared to changing the type. Connection to the connector pane shouldn't change (like a manual replace), but the label might.

 

The same applies: you need to save the 'instrument', because scripting won't change the modified flag of a VI, so save all won't do anything. Unless you wrap your scripting in an start\end undo, and that might be a good idea anyway if you plan on using the script more often.

 

Obviously, secure your original code. In SCC of course.

0 Kudos
Message 7 of 7
(349 Views)