NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
m3rl3n
Posts: 77
0 Kudos

Scripting - replace invoke node

Hi all,

 

After a pretty good discussion with tst here (starting on page 2):

 

http://forums.ni.com/t5/LabVIEW/How-can-I-develop-a-ring-control-with-sub-menus/td-p/143421/highligh...

 

I find myself needing help with scripting.  I have looked at the examples and have decided that for my first crack at this I would use a template vi creation method as given in the LabVIEW examples. And then I could use pieces and parts of tst's example code and make a fairly decent first stab at this.

 

The problem is: I can't figure out how to replace the placeholdermethod (invoke node) with one of the invoke nodes that tst's code develops.  The other problem is that in order to get tst's code to work, I have to place the constructor node, plus one of the invoke nodes for the C# class, but then the VIs that are created all contain the constructor node.  Any hints would be GREATLY appreciated.

 

BTW, this is my first attempt at complex scripting.  I've gone through the tutorials, but until I get more experience, I think I will be asking quite a few questions.

 

Thanks in advance.

 

See the attached for my template vi (LV2011). The VI creation script can be found in the examples, and tst's quickly thrown together example is in the link above.

Knight of NI
Knight of NI
tst
Posts: 10,236

Re: Scripting - replace invoke node

You don't need to replace the invoke node. You just need to set the actual method that the node uses, which is what my VI did. Since the class in the input reference is already your target class, the node itself should also be linked to the target class, so the All Methods property I used should give you a list of all the methods in the class. Of course, you don't need all the copying and pasting I did there, since that code already exists in the template.


___________________
Try to take over the world!
Trusted Enthusiast
DFGray
Posts: 2,566
0 Kudos

Re: Scripting - replace invoke node

If you are using template based scripting, you might want to look at the LabVIEW codegen engine.  It shields you from a lot of the lower level issues of scripting.  It also has optimizations that a normal user cannot make.

Using LabVIEW 2009 - 2012 on Windows 7 64-bit
Member
m3rl3n
Posts: 77
0 Kudos

Re: Scripting - replace invoke node

Thanks for the hints!!

 

This is definately a new area for me.

 

I have looked at and mostly understand tst's code and  it does give me all of the methods in the class that I am calling. Now, since I have to do a number of these AND make it so that others can generate the same interop code, scripting is the way I want to go. Now I just have to figure out the pieces so that I can generate the methods (tst's code), then place those into (or attach them to) the template that has all of the IO hooked up, etc...  even to the point where I can use the CodeGen tool to make the polymorphic VI(s) for me.

 

Lots to learn and SO much fun!!

 

Thanks again.

 

Dan

 

Member
m3rl3n
Posts: 77
0 Kudos

Re: Scripting - replace invoke node

Is there a way to automatically save the generated vi? (and give a path to save to?)

Knight of NI
Knight of NI
tst
Posts: 10,236
0 Kudos

Re: Scripting - replace invoke node

The VI class has a Save Instrument method.

 

I would suggest searching first. "Programmatically", "VI Server" and "scripting" are all good search terms. Also, looking through the list of methods and properties yourself will help you become more familiar with them.


___________________
Try to take over the world!
Member
m3rl3n
Posts: 77
0 Kudos

Re: Scripting - replace invoke node

tst,

 

Thanks...  AGAIN!!

 

I did look through the methods, but was getting stymied...  I kept searching for scripting and save vi, and was getting everything but.  The suggestion of "programmatic" is the way to go.

 

Dan

 

Trusted Enthusiast
Darin.K
Posts: 3,353

Re: Scripting - replace invoke node

Don't forget the Class Browser (Ctrl-Shift-B), you can search for a word (ie. Save) and it will provide a list of properties and methods.  Great way to figure out where things are.

Member
m3rl3n
Posts: 77
0 Kudos

Re: Scripting - replace invoke node

Oh AWESOME....  I really need to use this forum more...  Learning SO much.

 

Thanks,

Dan

 

Member
Sev_K
Posts: 111
0 Kudos

Re: Scripting - replace invoke node

[ Edited ]

HI,

 

I'm pretty sure you've figured it out, but just in case I've attached a simple VI that saves another VI programmatically. If you want to save multiple VI's you can move the invoke node in a loop and use an array of VI names as an input to your loop.

 

1.jpg

Sev K.
Applications Engineer
National Instruments
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page