11-03-2023 04:36 PM
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,
Solved! Go to Solution.
11-03-2023 04:55 PM
Option 1: If it's a fairly limited number you could do this:
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.
11-03-2023 05:16 PM
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.
11-03-2023 09:51 PM
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.
11-14-2023 09:22 AM
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.
11-14-2023 09:50 AM
11-14-2023 10:53 AM
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.
11-16-2023 10:53 AM
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:
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.
11-16-2023 10:56 AM
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.
11-16-2023 11:20 AM
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.