LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically rename member vi in a class

Solved!
Go to solution

Dear LabVIEW experts,

I am working on a project that requires me to programmatically rename the member VIs of a class without breaking the links. I have attached the sample class and VIs (LabVIEW 2017) for your reference. My current solution can rename the class VIs, but it breaks the links between them. How can I fix this issue? Any help or advice would be greatly appreciated.

Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 1 of 6
(638 Views)
Solution
Accepted by topic author Baji

Hi Baji,

 

Without using a project, there is no way LabVIEW can detect the callers on disk of the renamed VIs to update their link. I suppose the private VI method you are using (Save.Instrument and Callers Debug) gets the callers from the owning project, but in your case there is none.

 

Try adding the callers of your class members, the class itself and the "Find and Rename" script to the same project, it will work better.

 

If you don't want to use a project, you will have to load all the callers in memory yourself before the renaming, then rename your member VIs, then save the callers, then close them.

 

Regards,

Raphaël.

Message 2 of 6
(629 Views)

When I use the Project Reference, I am not able to find "Find and Rename" script.

Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 3 of 6
(583 Views)
Solution
Accepted by topic author Baji

What do you mean by "the project reference" ? Create manually a project and add all the files to it.

What do you mean by "find "Find and Rename" script" ? I am speaking about your VI "Find and Rename.vi". I call it a "script" because it automates project / VI modification. Just run it again, it will work if everything is inside the same project.

0 Kudos
Message 4 of 6
(569 Views)

Thanks raphschru, this is my working solution

Solution.PNG

Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 5 of 6
(563 Views)

Nice, some remarks on your code:

- don't forget to close project and selected items references when not needed anymore.

- you can merge your 2 loops in a single one.

- the open application ref is not useful. If you don't wire an Application property/method, it will already reference the owning application (where the script executes), and no need to close it, it is a static reference.

 

 

 

 

 

 

0 Kudos
Message 6 of 6
(557 Views)