03-12-2021 11:19 AM
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
03-12-2021 11:31 AM
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
03-12-2021 12:20 PM
Hi Sam,
No, they're a unified control, unfortunately:
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
10-27-2021 06:38 AM
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.
10-27-2021 10:04 AM
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
10-01-2024 03:49 AM - edited 10-01-2024 03:51 AM
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.
10-01-2024 04:14 AM
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.