Home Image-Pro Automation (Macros, Apps, Reports)

Issue with BEST FIT CIRCLE TOOL . . .

2018-03-14-175511

All --

I have created the

    button_TestCalibration_Click

CODE below to support a TEST CALIBRATION BUTTON in an APP.

When the BUTTON is pressed everything seems to work properly but two identical BEST FIT CIRCLES are created even though I only lay down 3 edge points.

I can deal with this by using the MEAN of the MEAN DIAMETERS rather than the SUM of the MEAN DIAMETERS but I would like to understand why there are two BEST FIT CIRCLES being created and avoid this if possible.

The PREMIER that is being used is

    PREMIER 3D 9.3.2 BUILD 6468

Thanks in advance.

-- Matt
    Private Sub button_TestCalibration_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button_TestCalibration.Click

        'CHANGE THE BUTTON COLOR
        button_TestCalibration.BackColor = _
            SBPA_ActiveButtonColor

        'Refresh CONTROL to allow the UI to REFRESH
        MyControl.Refresh

        'DECLARE VARIABLES
        Dim docAA, measAA

        'CONNECT WITH THE ACTIVE DOCUMENT
        With Application.DocumentCommands.Active(Nothing)
            .Run(docAA)
        End With

        'DELETE ALL MEASUREMENT FEATURES
        With Measure.MeasurementsCommands.DeleteAll(Nothing)
            .Run(docAA)
        End With

        'SET THE NUMBER OF POINTS IN THE BEST FIT CIRCLE TOOL
        With Measure.MeasurementsCommands.Options(Nothing)
            .NMaxPointsCircles = 3
            .Run(docAA)
        End With

        'USE TRY TO TRAP ERRORS
        Try

                With Measure.MeasurementsCommands.Add(Nothing)
                    .Interactive = True
                    .prompt = _
                        "Please create a " & vbLf & vbLf & _
                        "3 POINT CIRCLE at the edge of the CONE" & vbLf & vbLf & _
                        "then press OK to CONTINUE!"
                    .MeasurementType = McMeasurements.enumMMSTypes.mmtsBestFitCircle
                    .SnapFeature = False
                    .Run(docAA, measAA)
                End With

            Catch

                'Do nothing

            Finally

                'Deactivate all tools by selecting the NO TOOL
                With Measure.Measurements.ToolsCommands.Select(Nothing)
                    .Tool = eMMTool.NoTool
                    .Run(docAA)
                End With

            End Try

        'USE TRY TO TRAP ERRORS
        Try

                'Connect with the data for this image
                Dim dataAA As McMMData
                With measure.MeasurementsCommands.GetData(Nothing)
                    .Run(docAA, dataAA)
                End With

            Catch

            End Try

        'IF ANY AREA FEATURES ARE ON THE IMAGE
        If (data.Statistics(eMeasures.RgnMeanDiameter).count > 0) _
            Then

                textBox_MeasuredConeDiameter.Text = _
                    Trim ( Str ( dataAA.Statistics(eMeasures.RgnMeanDiameter).Sum ) )

            End If

        'Deactivate all tools by selecting the NO TOOL
        With Measure.Measurements.ToolsCommands.Select(Nothing)
            .Tool = eMMTool.NoTool
            .Run(docAA)
        End With

        'CHANGE THE BUTTON COLOR
        button_TestCalibration.BackColor = _
            SBPA_OrginalButtonColor

        'Refresh CONTROL to allow the UI to REFRESH
        MyControl.Refresh

    End Sub



Answers

  • edited March 2018
    Hi Matt,

    Yes, I can see the problem with double circle. When you click "Ok" in the prompt window the function uses recorded points (that's mentioned in the default Prompt of this command), creating second circle (we will look into the problem). One of the workarounds would be to click Cancel, after creating the circle, so second circle will not be created.
    Another approach that you can use to create Best-Fit Circle inteactively is to activate BestFitCircle tool and prompt user to click 3 points:

        Public Function CreateBFC() As SimpleScript
            CreateBFC = New SimpleScript
    
            With Measure.Measurements.ToolsCommands.Select(CreateBFC)
                .Prompt = "Please click 3 points to create circle, then click Ok."
                .Tool = eMMTool.BestFitCircle
                .Interactive = True
                .Run(Nothing)
            End With
        End Function
    

    Yuri
  • 2018-03-15-103814

    Yuri --

    Thank you for the diagnosis and guidance to resolution.

    It looks like the difference between mine and yours is the ADD vs the SELECT.

    I'll weave yours into the CODE and I'm sure that will resolve the issue.

    Thanks again.

    -- Matt
  • 2018-03-15-164959

    Yuri --

    I replaced my
                   With Measure.MeasurementsCommands.Add(Nothing)
                       .Interactive = True
                       .prompt = _
                           "Please create a " & vbLf & vbLf & _
                           "3 POINT CIRCLE at the edge of the CONE" & vbLf & vbLf & _
                           "then press OK to CONTINUE!"
                       .MeasurementType = McMeasurements.enumMMSTypes.mmtsBestFitCircle
                       .SnapFeature = False
                       .Run(docAA, measAA)
                   End With
    with a the modified version of your code shown below
                    With Measure.Measurements.ToolsCommands.Select(Nothing)
                        .prompt = _
                            "Please create a " & vbLf & vbLf & _
                            "3 POINT CIRCLE at the edge of the CONE" & vbLf & vbLf & _
                            "then press OK to CONTINUE!"
                        .Tool = eMMTool.BestFitCircle
                        .Interactive = True
                        .Run(Nothing)
                    End With
    and now the
       
        button_TestCalibration_Click

    routine works just the way I need it to.

    Thanks again for the guidance.

    -- Matt
Sign In or Register to comment.