LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Renaming Classes Used in Multiple Projects

Solved!
Go to solution

I just finished my project and verified everything is working only realize there's a typo in the class name. Since the project involves both a real-time and GUI programs, its split into two separate projects. How do I rename the file class and get both projects to accept it? When it can't find the file, it will not accept a different name for some reason when you try to browse. I'll need a good method for future tasks too as all our projects reference a common folder for tools and classes. If we had to rename one of those, would there be anyway to convince 5+ projects to accept a new file name for the class its referencing?

 

Sorry if this topic already is solved but the generic wording proved too much for my googlefu. 

 

Thanks,

0 Kudos
Message 1 of 11
(1,509 Views)

Option 1: If it's a fairly limited number you could do this:

 

  • Make sure the class to be renamed is saved to source control, or at least manually copy its state to a different folder that LabVIEW won't look at
  • Open project 1
  • Rename the class in LabVIEW so that everything currently in memory accepts the name change
  • Save all
  • Exit LabVIEW
  • Revert changes to the directory containing the class to be renamed back to its original (or delete it and copy the copy you made earlier back to where it was unchanged)
  • Open project 2 and rename it there, same thing so that everything accepts the change
  • Repeat until done with all projects
  • For the last one, don't revert back to the old version of the renamed class, and commit that to source instead

This could still fail if the projects have shared dependencies, as they might load up and complain about the missing class and then not allow you to rename the class because of the other references to it with the same name that didn't load.

 

Option 2:

Instead of doing a class rename, do a class copy with a new name.  Open each project in turn and replace all instances of the original class with the new one.  

 

This could be extremely tedious if you have to do it manually.  I'm not sure how well the built-in find/replace tool would be at this, so you might need to do some VI scripting.

 

This would also cause issues if this class has any child classes.  I think you could manually change the inheritance of them and have it work but you'll just need to try it if that's the case.

Message 2 of 11
(1,501 Views)

Yeah, option 2 sounds a bit awful and what I am trying to avoid. I can't understand why Labview insists the filename is the same, such an annoying restriction. 

 

Ill try out Option 1 on Monday, seems like a decent solution without too much pain and suffering, but still not something I want to make a habit of. 

0 Kudos
Message 3 of 11
(1,490 Views)
Solution
Accepted by topic author Furbs

Hi Furbs,

 

Here is a script that automates Kyle's Option 1.

Open "Script Rename Class.lvproj", open VI "Script Rename Class.vi", enter the root folder containing all your projects, the current path of your class and the new path of your class.

 

I have tested with 2 projects that each share a common VI that depends on the class, everything seems fine so far. I have not tested for a big project, so that may take some time to execute since all VI references in the project must be opened and saved during the renaming to force them to update their dependency.

 

Regards,

Raphaël.

Message 4 of 11
(1,458 Views)

That script is great, thank you so much. I did get an error when it tried to replace the class object embedded inside another class. 

LabVIEW: (Hex 0x578) Attempted to read flattened data of a LabVIEW class. The flat data could not be converted to the requested type because the flat data is not the same as the requested type nor is it the same as any child class of the requested type. 

I'm not sure why my new data would have been a different type.  

0 Kudos
Message 5 of 11
(992 Views)

Somehow your other class is storing flattened data from the class that is renamed. Since the class name is also contained in the flattened data, a name change makes types incompatible when trying to unflatten it.

I would need a minimal example to try to reproduce your error.

0 Kudos
Message 6 of 11
(982 Views)

I have an event registration that also has the class name in it, would that do it?

The control looks like this:

"badname.lvclass"

"badname Event Reg"

 

Would that do it? I can send an example, but it would basically be a recreation with dummy classes since you don't want all the parent classes and stuff. 

0 Kudos
Message 7 of 11
(969 Views)

Control labels do not make types incompatible.

 

Is this happening while executing the script ?

At which point exactly is it failing (use "Highlight Execution" while running to debug) ?

 

Maybe your class path (either the new or the old one) is too long ? This topic talks about a similar issue:

https://forums.ni.com/t5/LabVIEW/Solved-Error-1400-occurred-at-Invoke-Node-in-AB-Engine-Find/td-p/37...

 

If path length is not what caused the issue, you'll either have to debug the script yourself, or try reproducing the error starting from my sample project so that I can help you.

 

Regards,

Raphaël.

0 Kudos
Message 8 of 11
(920 Views)

I can work on that if it'll help. To be clear, that was the only issue, so I just manually replace those objects and I think everything is working now in my project. I just wanted to give feedback if it was wanted. I can roll back the project and do some more investigating if you want to determine the root cause. 

0 Kudos
Message 9 of 11
(917 Views)

Well, no need to spend too much time on that since your problem is solved, but it's always more satisfying to find the bottom line of a problem.

Maybe if you have some code screenshots or more detailed explanation on how your classes (especially the one that caused the issue) are related to each other and what is special about them, that could be enough for me to reproduce the error.

0 Kudos
Message 10 of 11
(907 Views)