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

CODE to QUERY for ACTIVE MEASUREMENT TOOL . . .

2020-10-20-155950

All

This code will activate the LINE TOOL

        'ACTIVATE THE LINE TOOL
        With Measure.Measurements.ToolsCommands.Line(Nothing)
            .Tool = eMMTool.Line
            .Interactive = False
            .Run(ThisApplication.ActiveDocument)
        End With

This code will activate the NO TOOL

        'ACTIVATE THE NO TOOL TO DEACTIVATE ALL OTHER TOOLS
        With Measure.Measurements.ToolsCommands.Select(Nothing)
            .Tool = eMMTool.NoTool
            .Interactive = False
            .Run(ThisApplication.ActiveImage)
        End With

This code will activate the ANGLE TOOL

        'ACTIVATE THE ANGLE TOOL
        With Measure.Measurements.ToolsCommands.Angle(Nothing)
            .Tool = eMMTool.Angle
            .Interactive = False
            .Run(ThisApplication.ActiveDocument)
        End With

I have poked around in the PROPERTIES and METHODS of

    Measure.Measurements.ToolsCommands

and have not found something to give me info on which TOOL is active.

Is there CODE that will determine which TOOL is active?

Thanks.

-- Matt


Best Answers

  • edited October 2020 Answer ✓
    Hi Matt,

    Here is the code to get ActiveTool of the measurements:

        Public Sub PrintActiveTool
            Debug.Print ThisApplication.ActiveImage.MeasurementsData.ActiveTool
        End Sub
    

    Regards,

    Yuri
  • Answer ✓
    Hi Matt,

    Here is an example of using ENUM directly:

        Public Sub TestENUM
            Select Case ThisApplication.ActiveImage.MeasurementsData.ActiveTool
                Case McMeasurements.enumMMTools.mmtNoTool
                    Debug.Print "NO TOOL"
                Case McMeasurements.enumMMTools.mmtLine
                    Debug.Print "LINE TOOL"
                Case McMeasurements.enumMMTools.mmtAngle
                    Debug.Print "ANGLE"
            End Select
        End Sub
    

    Yuri

Answers

  • 2020-10-21-100337

    Yuri --

    Super.

    I will use that to the APP later today.

    Thanks.

    -- Matt


  • 2020-10-22-140845

    Yuri --

    Thank you for showing me
       
    Debug.Print ThisApplication.ActiveImage.MeasurementsData.ActiveTool

    I am working to add this to my code.

    I am having a difficult time working with the output of the

    Debug.Print ThisApplication.ActiveImage.MeasurementsData.ActiveTool
    Sometimes it acts like a STRING and sometimes it acts like a VALUE

                Debug.Print _
                    Now()
    
                Debug.Print _
                    "ThisApplication.ActiveImage.MeasurementsData.ActiveTool"
                Debug.Print _
                    ThisApplication.ActiveImage.MeasurementsData.ActiveTool
    
                Dim mytest As String = _
                    ThisApplication.ActiveImage.MeasurementsData.ActiveTool
    
                Debug.Print "mytest"
                Debug.Print mytest

    Produces:

    2020-10-22 14:15:47
    ThisApplication.ActiveImage.MeasurementsData.ActiveTool
    mmtAngle
    mytest
    10

    It seems that sometimes this acts like a STRING and sometimes it acts like a VALUE.

    I have found the TABLE in the HELP FILE that shows the VALUES and the NAMES below.


    Is there another method or property to

        ThisApplication.ActiveImage.MeasurementsData.ActiveTool

    that will give me either the MEMBER NAME or the VALUE without my having to setup a string to hold the value?

    Thanks.

    -- Matt

  • Hi Matt,

    As you found in the Help, ActiveTool is ENUM (McMeasurements.enumMMTools), so you should check it as ENUM, without converting it to string.

    Yuri

  • ADDENDUM

    I tried the following code

                'UPDATE THE UI STATUS TEXT
                Select Case ThisApplication.ActiveImage.MeasurementsData.ActiveTool
    
                        Case 0
                            label_StatusText.Text = "NO TOOL"
    
                        Case 2
                            label_StatusText.Text = "LINE TOOL"
    
                        Case 10
                            label_StatusText.Text = "ANGLE"
    
                    End Select

    and it works to do the job I need.

    I would have expected to need to use

    mmtNoTool
    mmtLine
    mmtAngle

    as the CASES but the VALUES worked.

    Any comments you can provide that would help me understand this would be appreciated.

    Thanks.
  • 2020-10-23-074634

    Yuri --

    Thanks for the additional information.

    -- Matt


Sign In or Register to comment.