04-09-2010 04:25 PM
Hi, does anyone have any example code of how to call up a VBAI inspection in a .net environment (C# to be exact), run the inspeciton, and get result data? I am lost and cannot find documentation. The only documentation shows me what objects are in the control, not how to instantiate them, load an inspection, etc. For instance, I am having trouble instantiating objects because I am told that they have no constructor. What are all of the references that I need? I do not have formal C# training, so bear with me. Thanks,
Tom
04-12-2010 11:29 AM
Hi Tom,
I don't have an example in particular that does .NET from C#, but hopefully the following examples will provide some insight.
Run VBAI Inspection is a LabVIEW example that does what you would like. The basic flow of the program is:
1- Connect to VBAI (activeX property -NIVBAITargetControl: IP Address, then Connect method)
2- Open Inpsectpion (NIVBAITargetControl "ShowOpenInspectionDialog")
3- Run the inspection (done with again that NIVBAITargetControl, "Active Inspection", then method "Inspect")
4- Disconnect.
All of the documentation for Vision .NET can be found at Programs » National Instruments » Vision » Documentation.
As for .NET activeX documentation, you can look in the Measurement Studio help. Using Measurement Studio ActiveX Controls in Visual Studio .NET is also a good article to check out.
Cheers,
04-15-2010 02:30 PM
Hi Marti,
Thanks for you help, I have the inspection running, but now I need to access the results. I am using:
NIVBAILib.NIVBAIStepResults myResults = myInspection.Steps.Results;
My question is: how do I get a single result out of this collection? The only thing I can see is the get_item(ref object), but I do not know what to use for the 'object'.
Thanks,
Tom
04-16-2010 10:53 AM
Hi Tommy,
Try using a property node for that "results" (right click>create>property). I looked around a little bit, and saw that there are some options for Inspection Results too. Have you tried these and had any luck? Sometimes with these ActiveX controls it takes some digging to get down to what you'd like.
08-02-2011 11:37 AM
Does anyone have an example of doing this in .NET? I'm struggling to get it to work. I have this going:
VB.NET:
Dim NIVBAITarget1 As NIVBAITargetControl
NIVBAITarget1.Connect("")
NIVBAITarget1.OpenInspection("C:\a.vbai")
NIVBAITarget1.ActiveInspection.Inspect()
NIVBAITarget1.Disconnect()
I need to iniate NIVBAITarget1 but it is not as simple as using "new" because it's declared as "Friend".
08-02-2011 10:27 PM
We are about to release a new Vision Builder AI 2011 that will have a dotNET example using the new C API to control Vision Builder AI. This example uses a dotNET assembly and will be the way to control Vision Builder AI in the future as compared with the ActiveX implementation. This new version should be available on the web in another week or two if you can wait.
Thanks,
Brad
08-02-2011 10:30 PM
08-03-2011 10:05 AM
Here.
08-05-2011 09:30 AM
I ended up just writing a batch file to accomplish this. This should solve my problem. Thanks for the help!
@ECHO OFF
start C:\"Program Files"\"National Instruments"\"Vision Builder AI 2010"\"Vision Builder.exe" \inspect "C:\\Program Files\\National Instruments\\Vision Builder AI 2010\\Examples\\Tutorial 6 - State Diagram Looping.vbai" \nowelcomeonexit
start C:\"Program Files"\"National Instruments"\"Vision Builder AI 2010"\"Vision Builder.exe" \inspect "C:\\Program Files\\National Instruments\\Vision Builder AI 2010\\Examples\\Tutorial 5 - State Diagram Branching.vbai" \nowelcomeonexit
exit
09-26-2013 11:29 AM
I just wanted to give this thread a bump. I had been looking for a way to launch multiple instances of VBAI simultaneously, and had thought that a C or .NET application using the api would be required. The batch file approach works beautifully. The only catch is that the window positions for the two inspections come up in the same place, but there are other ways to deal with that (autohotkey).