LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

activex vision builder AI

Hello,
I'm using VBAI 3.0.1
two instances of the python script below started in same time, are able to work with the only one inspection I chose to open.
but I'm not able to make this script connect to an already running instance of VBAI.

What am I missing ???????

thanks in advance

Very ugly, that's just a test ..

import sys, time
import pythoncom
import win32com.client
pythoncom.CoInitializeEx( pythoncom.COINIT_APARTMENTTHREADED )
ctrl = win32com.client.DispatchEx( 'NIVBAILib.NIVBAITargetControl' )
def show( ctrl 😞
    status = {
    win32com.client.constants.vbaiConfigured : 'configured',
    win32com.client.constants.vbaiInitialized : 'initialized',
    win32com.client.constants.vbaiInspecting : 'inspecting',
    win32com.client.constants.vbaiNotRunning : 'not running',
    win32com.client.constants.vbaiRunning : 'running'
        }
    print '\nisConnected : %s' % ctrl.IsConnected
    print 'status       : %s' % status[ ctrl.GetStatus() ]
    if ctrl.ActiveInspection is not None:
        print 'active inspection : %s ' % ctrl.ActiveInspection.Name
   
try:
    ctrl.IPAddress = '127.0.0.1'
    ctrl.Version = win32com.client.constants.vbaiVersion300
    ctrl.Connect(  )
    show( ctrl )
except Exception, ( exc 😞
    print exc
    sys.exit( 1 )
   
if ctrl.ActiveInspection is None:
    ctrl.ShowOpenInspectionDialog(  )
if ctrl.ActiveInspection is not None:
    print '\navailable inspections : '
    for I in ctrl.Inspections:
        print '\t%s' % I.Name
        print '\t%s' % I.CreationDate

    if not ctrl.GetStatus() == win32com.client.constants.vbaiInspecting:
        print 'start inspection'
        ctrl.ActiveInspection.StartInspection( )
        print 'inspecting ...'
        time.sleep( 20 )
        print 'stop inspection'
        stats = ctrl.ActiveInspection.GetStatistics( )
        print '\npassed : %d   -   failed : %d' % ( stats.NumPassed, stats.NumFailed )
        ctrl.ActiveInspection.StopInspection( )
    else:
        while 1:
            try: go = ctrl.GetStatus() == win32com.client.constants.vbaiInspecting
            except: go = False
            if not go: break
            stats = ctrl.ActiveInspection.GetStatistics( )
            print '\npassed : %d   -   failed : %d' % ( stats.NumPassed, stats.NumFailed )
            time.sleep( 2 )
try: ctrl.Disconnect( )
except: pass
0 Kudos
Message 1 of 1
(2,528 Views)