Jump to content
News about the LabVIEW Wiki! Read more... ×
Sign in to follow this  
Dan Bookwalter N8DCJ

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>

TIA

Dan

Edited by Dan Bookwalter N8DCJ
added lv version

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

I'd suggest looking at/borrowing from https://github.com/opengds/OpenGDS

I believe theres a good amount of class scripting, including (I think) scripting from a template, so it probably has what you need. May have to dig a bit though.

Share this post


Link to post
Share on other sites

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 ....

Dan

Share this post


Link to post
Share on other sites

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.....

Share this post


Link to post
Share on other sites
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...

Dan

Share this post


Link to post
Share on other sites

Hmm, maybe the manual "Save As..." and the Programmatic "Save As..." are not equivalent?  Or memory fails me.  I thought it wasn't neccessary to replace the controls if doing a manual "Save As...".

Share this post


Link to post
Share on other sites

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...

Dan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

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