Home Image-Pro Plus Automation with Macros

VB and IpAcqSnap don't seem to trigger POST SNAP MACRO . . .

2017-06-08-162300

All --

I am working to patch up a system which IMAGE-PRO PLUS and a VB PROGRAM I wrote many years ago that includes the SUPERSNAP ROUTINE shown below.

Due to changes in CAMERA and FRAME GRABBER equipment since the program was written, I would like to do some fairly simple operations to the image after it is captured.

I thought this could be accomplished with a POST SNAP MACRO.

After writing such a macro and testing it with the CAPTURE DIALOG BOX, I find that it seems that the POST SNAP MACRO is not triggered by the

    ret = IpAcqSnap(ACQ_NEWEX)

included in SUPERSNAP.

I can crack open the VB PROGRAM and include the operations within it but that will entail a level of surgery on the VB PROGRAM that I was hoping to avoid.

** QUESTIONS **

1) Is there an elegant way to configure IMAGE-PRO PLUS so that a ROUTINE within a MACRO will run when a SNAP is triggered from a routine like SUPERSNAP within a VB PROGRAM?

2) If #1 is not possible, it seems that a VB PROGRAM can command PLUS to run a ROUTINE within an IPM FILE via the IPMACRORUN COMMAND.  This is shown within the HELP FILE as follows:

    ret = IpMacroRun("PREP1","C:\IPWIN\UTILTIIES.SCR")

    This statement will execute the macro "PREP1" in the “UTILITIES.SCR” script file. 

This seems to indicate that if I put an appropriate IPMACRORUN statement into my VB PROGRAM that I can trigger the POST SNAP MACRO stored in an IPM FILE.

Can anyone say whether this will work?

** **

Thanks in advance. 

-- Matt

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

Private Sub SuperSnap()

    'If the preview is on
    If (Check_Preview.Value = vbChecked) Then
   
            'Turn off the PREVIEW
            Check_Preview.Value = vbUnchecked
       
        End If
   
    'Close all of the images that are currently open
    ret = IpAppCloseAll()
   
    'Capture a new image from the camera
    ret = IpAcqSnap(ACQ_NEWEX)
   
End Sub

Best Answers

  • Answer ✓
    2017-06-09-090745

    All --

    I tried a solution related to the question shown as #2 above.

    I modified SUPERSNAP as shown below and created the required MACRO FILE and ROUTINE.

    Everything works well and the POST SNAP ROUTINE can be modified without changing the VB PROGRAM.

    If a POST SNAP ROUTINE is not needed, the IPM FILE can be RENAMED or DELETED and the VB PROGRAM with skip that operation.

    If anyone has a suggestion on a better way to resolve this, please let me know.

    I hope this information is helpful to others here on the forum.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

    Private Sub SuperSnap()

        'If the preview is on
        If (Check_Preview.Value = vbChecked) Then
       
                'Turn off the PREVIEW
                Check_Preview.Value = vbUnchecked
           
            End If
       
        'Close all of the images that are currently open
        ret = IpAppCloseAll()
       
        'Capture a new image from the camera
        ret = IpAcqSnap(ACQ_NEWEX)
       
        'If the POST_SNAP_MACRO.IPM FILE exists
        If (Dir(App.Path & "\POST_SNAP_MACRO.IPM") <> "") Then
       
                'Run the POST_SNAP_ROUTINE inside the IPM FILE
                ret = IpMacroRun("POST_SNAP_ROUTINE", App.Path & "\POST_SNAP_MACRO.IPM")
           
            End If
           
    End Sub


  • Answer ✓
    Hi Matt,

    Any of the macro functions specified on the macro page of the capture dialog like Post-Snap Macro do not execute when capturing using a macro script. This is by design. The reason is that it would potentially create a fatal recursion and the capability is unnecessary. If you are controlling capture from a script, the script itself provides the capability as you can call script function before and after the capture function which is effectively what the macro page provides. The macro page is a feature used only when controlling capture from the UI. As you discovered with solution #2, this works well and it is what I was going to suggest.
Sign In or Register to comment.