12-02-2011 11:18 AM
After a pretty good discussion with tst here (starting on page 2):
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.
12-04-2011 03:18 AM
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.
12-05-2011 07:13 AM
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.
12-05-2011 10:08 AM
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!!
12-05-2011 11:48 AM
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.
12-05-2011 11:54 AM
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.
12-05-2011 12:06 PM
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.
12-05-2011 05:08 PM - edited 12-05-2011 05:08 PM
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.