Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Using .NET To Run a VBAI Inspection

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 

0 Kudos
Message 1 of 11
(5,162 Views)

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, 

Marti C
Applications Engineer
National Instruments
NI Medical
0 Kudos
Message 2 of 11
(5,143 Views)

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 

0 Kudos
Message 3 of 11
(5,115 Views)

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. 

Marti C
Applications Engineer
National Instruments
NI Medical
0 Kudos
Message 4 of 11
(5,102 Views)

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

0 Kudos
Message 5 of 11
(4,550 Views)

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

Message 6 of 11
(4,543 Views)
Where can I read about new features coming with VBAI 2011?
0 Kudos
Message 7 of 11
(4,540 Views)

Here.

John B.
Embedded Networks R&D
National Instruments
Certified LabVIEW Developer
Message 8 of 11
(4,534 Views)

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

Message 9 of 11
(4,520 Views)

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

0 Kudos
Message 10 of 11
(4,316 Views)