Jump to content

Need to copy a class rename it and set its parent programmatically

Recommended Posts

Ok , I would like to programmatically copy a Default class and a Default Test.vi to another folder say , XYZ , rename the Default Test.vi to XYZ.vi, then change its DD terminal from the default class  to the newly created  XYZ.lvclass and add it to the project.

I currently can do everything I need to do , except , after changing the XYZ parent to the Default class I copied it from , add it to the project etc....

When I try to open the newly created/renamed  XYZ.vi from the project I get a dialog box that says  , "Default.lvclass:XYZ.vi" is at the expected path but it is part of a library. Default.lvclass:XYZ.vi" will be opened but it will be removed from the project".

I really need to be able to do this programmatically , we will have hundreds of test cases that will have different functionality but use the Default Test.vi as a starting template , I also have to assume that future users will be totally unaware of classes and how to create/use them... I have a framework that should be very expandable in the future , I just want to automate as much as possible....


<EDIT> I should mention this is in LV2012 <EDIT>



Edited by Dan Bookwalter N8DCJ
added lv version
Link to post

Right-click the Default class in project and choose "Save As...", then create an unopened copy.

You only need to rename the terminaly, but there's a quick drop shortcut available for that somewhere (rename labels).

You need to manually change inheritance.

Edited by shoneill
Link to post

Posting your scripting code, so we can exactly what you are trying to do would be helpful.  What you are trying to do should be possible.  Not sure if there are some limitations way back in 2012.

One thing to check would be: Do you save the class before trying to add it to your project? 

Edited to add:  Since the connection between a member vi and a library is a 2 way connection, make sure you save both.  I belive a Save All This Library.vi should handle that (it's in the hidden gems pallette if you have it installed, if not its buried somewhere in vi lib).

Edited by Stagg54
Link to post

Ok , I decided to start over , turns out there is an invoke node LVClassLIbrary.Save a copy... this copies everything to a new directory , then I just need to replace the control(s) , set the parent and save the whole thing using Save All This Project.vi....

works perfect ...

thanks for the pointers ....


Link to post
8 minutes ago, shoneill said:

which is basically just automating what I said above.....

Do you really need to change the controls? When you do a Save As from LV, it changes the type of the controls for you.....

Yep , basically all I did ...

if I don't change the controls , it doesn't work correctly , I will investigate a little more and see if I can eliminate that step...


Link to post

Well , your memory is working , I went back and disabled the part that replaces the DD control , and it works as expected , I think I will just rename it ...

the 2 others on the front panel are of the Default class , (In/out) , it appears I have to replace them as I get the Connector pane doesn't match on the DD vi's if I don't ....

it works , so now I will move on to the next issue on my list , I may come back and revisit it at a later date to see if I am doing something not quite correct...


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.