Thoric Posted March 14 Report Share Posted March 14 (edited) I have two classes (A and A1), and A1 is present on the block diagram of VIs within A.lvclass. I want to clone this precisely, so that I have two new classes B and B1, with B1 appearing in the VIs of B. I don't want B using A1. When I use the LVClassLibrary.Save A Copy method on A and A1 to create B and B1, I predictably get B using A1, and a lonely B1 with no callers. How can I either avoid this, or fix this? I don't see a way to "replace all calls to A1 with B1" or "Replace A1.lvclass with B1.lvclass" in B. I briefly looked at the method LVClassLibrary.Replace Item With but I don't see how I can use it when A1 doesn't appear in B's "library view" Note that B and B1 will later go on to be modified, so A and A1 are kinda like source templates. Ultimately there will be C and D and E, each customised slightly, but based on A. Edited March 14 by Thoric Quote Link to comment
Thoric Posted March 14 Author Report Share Posted March 14 (edited) Well, so far I have one ugly workaround - clone A as B and A1 as B1 into a new folder. Programmatically create a New Project, add B and A1 (its natural dependency), find A1 and call method "Replace Item With" using path to B1, set to "Save All without Prompts", then close the Project without ever saving it. This updates B to use B1, and seems to be the only way to get the "Replace Item With" method to work. Takes about 8 seconds though. I originally tried putting A and A1 into a library and cloning the library, but this didn't prevent the issue, and it also blocked access to "Replace Item With". Edited March 14 by Thoric Quote Link to comment
Francois Normandin Posted March 15 Report Share Posted March 15 In the special case where your A and A1 classes are in the same lvlib, you can simply clone the whole lvlib to have linkage preserved and rename to B and B1. Quote Link to comment
Thoric Posted March 15 Author Report Share Posted March 15 (edited) Hi Francois - as I mentioned in my second post that didn't work for me. B referenced A1, cross-linking the two libraries, and B1 in the clone was therefore uncalled. Did I do it wrong maybe? I used the Save A Copy method on the library to achieve the clone. Do you have an alternative approach? Edited March 15 by Thoric Quote Link to comment
Francois Normandin Posted March 15 Report Share Posted March 15 Hi Richard, I was referring to the Save a Copy on a LVLIB that contains classes A and A1, instead of saving individual classes sequentially. You'd start with Template.lvlib:A.lvclass * Template.lvlib:A1.lvclass, and end up with Clone.lvlib:A.lvclass & Clone.lvlib:A1.lvclass Your new clone lvlib will maintain the linkage within its own namespace. It then becomes a renaming operation for the Clone.lvlib:AX.lvclass to Clone.lvlib:BX.lvclass This only work if your template has all dependent classes in the same lvlib, hence why I called that a "special case". Your solution is more generic. Even when I don't want the classes to end up in the same lvlib, I prefer to extract them after they have been cloned... 1 Quote Link to comment
Thoric Posted March 15 Author Report Share Posted March 15 Thanks, but that's what I thought I'd tried and it didn't work for me. My classes are perhaps bit more complex (A is actually a child of some other parent), so I wonder if that's complicating this. Certainly the entire class heirarchy is not in the lvlib. I will give it another go though! 🙂 Quote Link to comment
Neil Pate Posted March 15 Report Share Posted March 15 (edited) 1 hour ago, Thoric said: Thanks, but that's what I thought I'd tried and it didn't work for me. My classes are perhaps bit more complex (A is actually a child of some other parent), so I wonder if that's complicating this. Certainly the entire class heirarchy is not in the lvlib. I will give it another go though! 🙂 for what it is worth, we do this... I have a shallow-ish hierachacy somthing like ths: actor <-- device <-- type_of_device <-- concrete_implementation We have some scipting code to help us make a new instance of type_of_device <-- concrete_implementation I have a template with the last two in a .lvlib, and we clone them as needed to two brand new classes. To further complicate, our stuff is in PPLs. Edited March 15 by Neil Pate 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.