1

I have created one python addin tool which creates some points along a line, it works good.

my problem is when my tool gets activated i am not able able to zoom/pan the map. map view just get stuck wherever it was before clicking on that tool.

more elaborately when i am in the middle of creating a line map view get stuck.

using below code:

class PointAddressCreateClass(object):
"""Implementation for PointAddressCreate_addin.tool (Tool)"""
def __init__(self):
    self.enabled = True
    self.shape = "Line" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.
def onMouseDown(self, x, y, button, shift):
    pass
def onMouseDownMap(self, x, y, button, shift):
    pass
def onMouseUp(self, x, y, button, shift):
    pass
def onMouseUpMap(self, x, y, button, shift):
    pass
def onMouseMove(self, x, y, button, shift):
    pass
def onMouseMoveMap(self, x, y, button, shift):
    pass
def onDblClick(self):
    pass
def onKeyDown(self, keycode, shift):
    pass
def onKeyUp(self, keycode, shift):
    pass
def deactivate(self):
    pass
def onCircle(self, circle_geometry):
    pass
def onLine(self, line_geometry):
   ***Some Code HERE****

its main functionality lies in "def onLine(self, line_geometry)" function. so when i click on the map and start to create a line on map, i want zoom/pan functionality at that time.

i guess there should be a function to zoom/pan in active view by either mouse scrolling or may be any other method.

4
  • Try remove redundant / unused functions
    – user7172
    Commented Mar 18, 2016 at 6:18
  • Assuming you have a mouse with a scroll wheel, have you tried zooming in/out (scrolling) and panning (click and drag scroll wheel)?
    – Ali
    Commented Mar 18, 2016 at 9:09
  • i have tried mouse wheel to scroll but its not working. actually i want this scroll to work, additionally i don't have any unused code in my python Addin. Commented Mar 18, 2016 at 11:07
  • @AkhilKumar I've updated my answer to explain how you can check if scroll zoom is enabled.
    – Ali
    Commented Mar 18, 2016 at 14:05

1 Answer 1

2

To elaborate on my comment above, it sounds like the issue you're having is that when you activate the Zoom In/Out or Pan tool your tool is deactivated and line drawing cancelled.

This is standard functionality that you can see when using the Measure tool. For example, try clicking several points to calculate the distance along a line. If you decide to activate the Pan tool to pan the display your line is cancelled. If you then reactivate the Measure tool you have to start from scratch.

In the Python add-in you can specify what happens when your tool is deactivated using the deactivate method:

def deactivate(self):
    # When tool is deactivated the following code will run...

Try experimenting with this to see if you can produce your desired result.

Alternatively, with your tool activated, you should be able to zoom in/out by scrolling with the scroll wheel. You can pan by clicking and dragging with the scroll wheel (a hand cursor should appear).

Update

To check that the scroll zoom and pan functionality is enabled, go to your ArcMap installation folder -> Utilites -> AdvancedArcMapSettings.exe. Then, in the Miscellaneous tab under Panning and Scrolling, ensure Use mouse wheel to: Zoom in and out is checked.

1
  • it checked , it will not solve my problem, i edited my question for better understanding Commented Mar 20, 2016 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.