From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add new class to project programmaticly

I'm trying to streamline my development using classes. I have found a way to add folders and such to a project programmaticly, but no success with how to add a new class. My goal is to make a utility that can generate a class skeleton for me to modify as needed. 
Message 1 of 18
(3,153 Views)

Wirejunky,

 

LabVIEW has built-in object oriented programming capability.  The links at Can I Use Object-Oriented Programming in LabVIEW? give a lot of great information on how to use it!

Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
0 Kudos
Message 2 of 18
(3,130 Views)

just created this fast (prob. better ways to do it). Here I also created the class itself.

 

 prog_class

 

Just a fast example. You can play with lots of more in there. Here I also created the class itself. Its fully possible to add a class to your project 🙂 With the create code at the beginning youve lots of class options to use.

Message 3 of 18
(3,105 Views)
Sorry, missed the part on doing this programatically 🙂 Good catch, corny!
Message Edited by Robbob on 02-09-2010 02:23 PM
Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
0 Kudos
Message 4 of 18
(3,098 Views)
Thanks Corny for your example! Learnt something new today :smileyhappy:. Now if only you didn't need to save the class first to disk... I am thinking of how you create classes in the project manager, where creating and adding the class to the project does not create a class file on disk. I am going to play around a bit and see if I cant get that type of behavior. 
0 Kudos
Message 5 of 18
(3,059 Views)

Corny wrote:

just created this fast (prob. better ways to do it). Here I also created the class itself.

 

...

 

Just a fast example. You can play with lots of more in there. Here I also created the class itself. Its fully possible to add a class to your project 🙂 With the create code at the beginning youve lots of class options to use.


This reminds me of an expression we used when I graduated from my Navy "A School".

 

"Six months ago I didn't know how to spell Technician. Now I is one." Smiley Tongue

 

Nice post,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 18
(3,057 Views)

Ben,

 

Well, Navy...that explains a lot...

Hummer1

 

learning every day too.

0 Kudos
Message 7 of 18
(3,049 Views)

WireJunky wrote:
Thanks Corny for your example! Learnt something new today :smileyhappy:. Now if only you didn't need to save the class first to disk... I am thinking of how you create classes in the project manager, where creating and adding the class to the project does not create a class file on disk. I am going to play around a bit and see if I cant get that type of behavior. 
Ive also tried to not save it, and add the reference to the project by entering the type (string) "class" or "lvclass" (I think this is what you tried?, for folders you would use the string name "folder"), but then, it popped up as an unkown object in the project manager.
 
Perhaps if you think the class as a file (it is actually a file), and a folder in the project as a "virtual folder (it doesnt need to exist on HDD)" than perhaps it makes sense?!? (just something that popped to my mind) 🙂
0 Kudos
Message 8 of 18
(3,040 Views)

ops didnt read your post entirely.. my bad. "fast reader" litirally (how the heck is that spelled). If its possible to add classes that are in memory and not HDD to project, inform if you find out (I didnt got it to work) 🙂

0 Kudos
Message 9 of 18
(3,034 Views)

K, I played around abit and I got this to work. By using the AddItemFromMemory method and supplying it with the newly created class name I was able to add the class to the project without first saving the class to disk.

 

CreateClass.png

This creates a new class in the project manager....

 

Project.png 

 

Thanks Corny for your help so far!.... now the cherry on top would be to programmaticly set the access scope of the internal virtual folder of the newly created class.

Message 10 of 18
(3,013 Views)