Home Image-Pro General Discussions

Configuration of POLY NUDGE TOOL . . .

2018-02-27-171525

All --

I am writing a PREMIER APP that can benefit from the availability of the POLY NUDGE TOOL.



I know from my previous use of this TOOL in an APP that CODE can ACTIVATE and DEACTIVATE this TOOL and that an POLYGON or POLYLINE must be UNLOCKED before this TOOL will ACTIVATE but . . .

Is there a way to change the RADIUS of this TOOL?

I have looked in the HELP FILE and there does not seem to be a way to do this from the GUI so I cannot record this action as a guide.

Thank you in advance for your assistance with this query.

-- Matt

Best Answer

  • Answer ✓
    Hi Matt,

    The Nudge tool will be enabled when Select mode is active and a polygonal measurement object is selected. It can be activated by ToggleEditToolNudge command. Here is a sample macro that also sets the size:

        Public Sub ToggleNudgeTool
            With ThisApplication.Commands("Select.Image.ToggleEditToolNudge")
                Debug.Print "Nudge tool was active = " & .Checked.ToString
                .Run()'toggle tool
                If Not .Checked Then
                    'set size
                    Dim tool As MediaCy.IQL.Display.Overlays.IMcGraphToolServer=ThisApplication.ActiveImage.MeasurementsData.Overlay.ActiveTool
                    tool.CommandData=100'diameter of the Nudge tool in pixels
                    tool.CommandFlags(0)=MediaCy.IQL.Display.Overlays.mcSelectToolCommandFlags.mcstcfSetPolyNudgeToolSize
                End If
            End With
        End Sub
    

    Yuri

Answers

  • 2018-02-28-095018

    Yuri --

    Thank you for your response and the CODE it contains.

    This looks perfect for the challenge at hand.

    I'll be working on this APP today and tomorrow and will wire this in.

    Thanks again.

    -- Matt
  • 2018-02-28-171421

    Yuri --

    I created an EDIT BUTTON in an APP and then added your CODE to the PROJECT as shown below.

    I can LOAD the PROJECT with no errors and when I press the EDIT BUTTON with an image open with an AUTO CREATED REGION on the image, the NUDGE TOOL (adjusted to 100) works like a champ.

    Unfortunately sometimes the error shown below is displayed when the EDIT BUTTON is pressed


    This is again with an image and a AUTO CREATED REGION on the image.

    The PREMIER APPLICATION INFO from SYSTEM INFORMATION is:

    Application:
    Image-Pro Premier 3D 64-bit

    Exe Name: Image-Pro Premier

    Exe Path: C:\Program Files\Media Cybernetics\Image-Pro Premier 3D 9.3\

    File Version: 9.3.6468.0

    This FILE VERSION INFO is a bit at odds with the ABOUT for PREMIER shown below.

           

    Will you please suggest a solution for this issue?

    Also . . .

    Is there a way to GET the NUDGE TOOL DIAMETER before I SET the NUDGE TOOL DIAMETER so that I can reset it to the NORMAL SIZE when the APP is finished with the NUDGE TOOL?

    I tried using

        MediaCy.IQL.Display.Overlays.mcSelectToolCommandFlags.mcstcfGetPolyNudgeToolSize

    but this did not return a reasonable value.  It looks like some kind of handle value.

    Thanks.

    -- Matt

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

        Private Sub button_Edit_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button_Edit.Click
    
            'CONNECT WITH THE CURRENT IMAGE
            Dim DocA
            With Application.DocumentCommands.Active(NewMacro)
                .Run(DocA)
            End With
    
            'SELECT ALL MEASUREMENT FEATURES ON THE CURRENT IMAGE
            With Measure.MeasurementsCommands.SelectAll(Nothing)
                .Run(DocA)
            End With
    
            'UNLOCK ALL MEASUREMENT FEATURES ON THE CURRENT IMAGE
            With Measure.MeasurementsCommands.Unlock(Nothing)
                .Lock = False
                .Run(DocA)
            End With
    
            'CONNECT WITH THE NUDGE TOOL
            With ThisApplication.Commands("Select.Image.ToggleEditToolNudge")
    
                Debug.Print "Nudge tool was active = " & .Checked.ToString
    
                'TOGGLE TOOL ON OR OFF
                .Run()
    
                'IF THE TOOL IS OFF
                If Not .Checked Then
    
                        'CONNECT WITH THE NUDGE TOOL
                        Dim tool As MediaCy.IQL.Display.Overlays.IMcGraphToolServer = _
                            ThisApplication.ActiveImage.MeasurementsData.Overlay.ActiveTool
    
                        'SET THE DIAMETER (IN PIXELS) OF THE NUDGE TOOL
                        tool.CommandData = _
                            100
    
                        'SET THE DIAMETER OF THE NUDGE TOOL CURSOR TO MATCH THE DIAMETER OF THE NUDGE TOOL
                        tool.CommandFlags(0) = _
                            MediaCy.IQL.Display.Overlays.mcSelectToolCommandFlags.mcstcfSetPolyNudgeToolSize
    
                    End If
    
            End With
    
        End Sub


  • Hi Matt,

    Nudge tool can be activated only when you have ONE feature selected, when yu have multiple, then you get such error. I've modified the macro adding this test:

        Public Sub ToggleNudgeTool
            Dim md As McMMData=ThisApplication.ActiveImage.MeasurementsData
            If md.SelectedSubFeatures.Count<>1 Then
                MsgBox("Only ONE feature must be selected")
                Exit Sub
            End If
            With ThisApplication.Commands("Select.Image.ToggleEditToolNudge")
                Debug.Print "Nudge tool was active = " & .Checked.ToString
                .Run()'toggle tool
                If Not .Checked Then
                    'set size
                    Dim tool As MediaCy.IQL.Display.Overlays.IMcGraphToolServer=ThisApplication.ActiveImage.MeasurementsData.Overlay.ActiveTool
                    tool.CommandData=100'diameter of the Nudge tool in pixels
                    tool.CommandFlags(0)=MediaCy.IQL.Display.Overlays.mcSelectToolCommandFlags.mcstcfSetPolyNudgeToolSize
                End If
            End With
        End Sub
    

    There is a bug getting current Nudge tool size by mcstcfGetPolyNudgeToolSize (we are looking at that), so, for now, you can just assume that the tool has default size of 12.

    Yuri

  • 2018-03-01-141638

    Yuri --

    Thank you for your valuable assistance.

    I am surprised that PREMIER is acting as though there is more than one feature selected.  The path the image takes before the EDIT is set up to discard all but the largest feature.  There must be something hiding someplace.

    I will work with your revised code and my code that leads up to it and see if I can identify and eliminate the MULTIPLE SELECTED ISSUE before activating the POLY NUDGE TOOL.

    I will use the POLY NUDGE TOOL SIZE = 12 to RESET the when the CODE is finished with it.

    Thanks again.

    -- Matt
  • 2018-03-01-150858

    Yuri --

    After playing with this EDIT function a bit more, I think the ERROR may be being generated by the PREMIER thinking that NO FEATURES are SELECTED.

    I re-engineered things a bit and put a short pause in after the UNLOCK and now the EDIT CODE seems to work reliably and it puts the DIAMETER back to the DEFAULT VALUE (12).

    Thank you very much for your guidance.

    -- Matt

        Private Sub button_Edit_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button_Edit.Click
    
            'CONNECT WITH THE CURRENT IMAGE
            Dim DocA
            With Application.DocumentCommands.Active(NewMacro)
                .Run(DocA)
            End With
    
            'SELECT ALL MEASUREMENT FEATURES ON THE CURRENT IMAGE
            With Measure.MeasurementsCommands.SelectAll(Nothing)
                .Run(DocA)
            End With
    
            'UNLOCK ALL MEASUREMENT FEATURES ON THE CURRENT IMAGE
            With Measure.MeasurementsCommands.Unlock(Nothing)
                .Lock = False
                .Run(DocA)
            End With
    
            'PAUSE A MOMENT
            Wait (.5)
    
            '-- CONFIRM THAT THERE IS ONLY ONE FEATURE ON THE CURRENT IMAGE
    
            'CONNECT WITH THE MEASUREMENT DATA FOR THIS IMAGE
            Dim My_MeasurementData As McMMData = _
                ThisApplication.ActiveImage.MeasurementsData
    
            'ERROR TRAP FOR ONE SELECTED FEATURE
            If My_MeasurementData.SelectedSubFeatures.Count <> 1 _
                Then
                    MsgBox("ONE feature must be selected for the POLY NUDGE TOOL to work properly.")
                    Exit Sub
                End If
    
            'CONNECT WITH THE TOOL SERVER
            Dim MyToolServer As MediaCy.IQL.Display.Overlays.IMcGraphToolServer
    
            'CONNECT WITH THE NUDGE TOOL
            With ThisApplication.Commands("Select.Image.ToggleEditToolNudge")
    
                'IF THE NUDGE TOOL IS OFF
                If Not .Checked _
                    Then
    
                        'TOGGLE NUDGE TOOL ON
                        .Run()
    
                        'CONNECT WITH THE NUDGE TOOL
                        MyToolServer = _
                            ThisApplication.ActiveImage.MeasurementsData.Overlay.ActiveTool
    
                        'SET THE DIAMETER (IN PIXELS) OF THE NUDGE TOOL
                        MyToolServer.CommandData = _
                            100
    
                        'SET THE DIAMETER OF THE NUDGE TOOL CURSOR TO MATCH THE DIAMETER OF THE NUDGE TOOL
                        MyToolServer.CommandFlags(0) = _
                            MediaCy.IQL.Display.Overlays.mcSelectToolCommandFlags.mcstcfSetPolyNudgeToolSize
    
                        Debug.Print "Nudge tool is active = " & .Checked.ToString
    
                    Else
    
                        'CONNECT WITH THE NUDGE TOOL
                        MyToolServer = _
                            ThisApplication.ActiveImage.MeasurementsData.Overlay.ActiveTool
    
                        'SET THE DIAMETER (IN PIXELS) OF THE NUDGE TOOL
                        MyToolServer.CommandData = _
                            12
    
                        'SET THE DIAMETER OF THE NUDGE TOOL CURSOR TO MATCH THE DIAMETER OF THE NUDGE TOOL
                        MyToolServer.CommandFlags(0) = _
                            MediaCy.IQL.Display.Overlays.mcSelectToolCommandFlags.mcstcfSetPolyNudgeToolSize
    
                        'TOGGLE TOOL OFF
                        .Run()
    
                        Debug.Print "Nudge tool is active = " & .Checked.ToString
    
                    End If
    
            End With
    
        End Sub
    
  • 2018-03-01-180421

    Yuri --

    In an unrelated but related question . . .

    I like the way the CODE you generated for the POLY NUDGE TOOL turns the TOOL on and off.

    Is there a way to access and control the POLYGON MEASUREMENT TOOL in the same way you accessed and controlled the POLY NUDGE TOOL?

    I have a DRAW FEATURE ROUTINE (below) that works well but it uses a PROMPT BALLOON and it would be nice if the tool was turned on and then off by the same button within the UI for the APP.

    Thanks in advance.

    -- Matt

    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
        Private Sub DrawFeature()
    
            'CONNECT WITH THE CURRENT IMAGE
            Dim DocAA
            With Application.DocumentCommands.Active(Nothing)
                .Run(DocAA)
            End With
    
            'DELETE ALL MEASUREMENT FEATURES ON THE CURRENT IMAGE
            With Measure.MeasurementsCommands.DeleteAll(Nothing)
                .Run(DocAA)
            End With
    
            'ERROR TRAP
            Try
    
                    'ACTIVATE THE POLYGON MEASUREMENT TOOL WITH A PROMPT
                    With Measure.Measurements.ToolsCommands.Polygon(Nothing)
                        .Tool = eMMTool.Polygon
                        .Prompt = _
                            "Please add POLYGONS" & vbLf & vbLf & _
                            "Pressing OK or CANCEL to FINISH!"
                        .Interactive = True
                        .Run(ThisApplication.ActiveDocument)
                    End With
    
                Catch
    
                    'GIVE THE USER AN ERROR MESSAGE
                    MsgBox _
                        ( _
                        "There was a problem with the POLYGON MEASUREMENT TOOL!", _
                        vbInformation, _
                        "'DrawFeature' says . . ." _
                        )
    
                Finally
    
                    'Deactivate all tools by selecting the NO TOOL
                    With Measure.Measurements.ToolsCommands.Select(Nothing)
                        .Tool = eMMTool.NoTool
                        .Run(ThisApplication.ActiveDocument)
                    End With
    
                End Try
    
        End Sub

  • 2018-03-05-173620

    Yuri --

    In the CODE above for the control of the POLY NUDGE TOOL, there are references to changing the SIZE / DIAMETER of the TOOL.

    The CODE you provided change the SIZE but it seems to be the RADIUS of the TOOL rather than the DIAMETER.

    I hope this information is helpful to others here in the FORUM and we appreciate your guidance and assistance.

    -- Matt

Sign In or Register to comment.