<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Activate the Edit tool and Snap Operations Using Arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/activate-the-edit-tool-and-snap-operations-using/m-p/99845#M7744</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import arcpy
import pythonaddins
from arcpy import edit as EDIT
class Btn(object):
 """Implementation for Python_Snaptool_addin.button (Button)"""
 def __init__(self):
 self.enabled = True
 self.checked = False
 def onClick(self):
 pass
class Edit_Operations(object):
 """Implementation for Python_Snaptool_addin.extension20 (Extension)"""
 def __init__(self):
 # For performance considerations, please remove all unused methods in this class.
 self.enabled = True
 #edit = arcpy.da.Editor(r'D:\Sample.gdb')
 #self.onStartEditing()
 def startup(self):
 pass
 def onStartEditing(self):
 pythonaddins.MessageBox('Select a data frame', 'INFO', 0)
 pass
 def onStopEditing(self, save_changes):
 pass
 def onStartOperation(self):
 pass
 def beforeStopOperation(self):
 pass
 def onStopOperation(self):
 pass
 def onSaveEdits(self):
 pass
 def onCreateFeature(self):
 pass
class LineClass(object):
 """Implementation for Python_Snaptool_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):
 global mid_point
 edit = arcpy.da.Editor(r'D:\Sample.gdb')
 array = arcpy.Array([arcpy.Point(line_geometry.firstPoint.X,line_geometry.firstPoint.Y),arcpy.Point(line_geometry.lastPoint.X,line_geometry.lastPoint.Y)]) 
 polyline = arcpy.Polyline(array)
 edit.startEditing()
 edit.startOperation() 
 cursor = arcpy.da.InsertCursor("CrossLine", ["SHAPE@"])
 cursor.insertRow([polyline])
 del cursor 
 mid_point = arcpy.Point() 
 mid_point.X= line_geometry.positionAlongLine(0.50,True).firstPoint.X
 mid_point.Y= line_geometry.positionAlongLine(0.50,True).firstPoint.Y
 edit.stopOperation()
 edit.stopEditing(True) ## Stop the edit session with True to save the changes
 arcpy.RefreshActiveView()
 obj = Edit_Operations()
 pass
 
 def onRectangle(self, rectangle_geometry):
 pass&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;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t;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you help me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to snap the line feature after line drawn , also need to activate the Edit tool programmatically to select the annotation .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;requirement steps:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;step 1&amp;nbsp; : create a line feature with snapping mode activation&lt;/P&gt;&lt;P&gt;step 2 : select the annotation&lt;/P&gt;&lt;P&gt;step 3 : snap the selected text to the mid point of the created line feature.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Intention of the code :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;created&amp;nbsp; 3 classes in addin&amp;nbsp;&lt;/P&gt;&lt;P&gt;one for line feature draw&lt;/P&gt;&lt;P&gt;two for select the annotation&lt;/P&gt;&lt;P&gt;three for button click if necessary&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;created a gdb (D:\Sample.gdb)&amp;nbsp;&lt;/P&gt;&lt;P&gt;created annotation and line feature classes for testing in arcmap using the addin tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Gopi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 06:12:13 GMT</pubDate>
    <dc:creator>gopi_chandangaluri</dc:creator>
    <dc:date>2021-12-11T06:12:13Z</dc:date>
    <item>
      <title>Activate the Edit tool and Snap Operations Using Arcpy</title>
      <link>https://community.esri.com/t5/python-questions/activate-the-edit-tool-and-snap-operations-using/m-p/99845#M7744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import arcpy
import pythonaddins
from arcpy import edit as EDIT
class Btn(object):
 """Implementation for Python_Snaptool_addin.button (Button)"""
 def __init__(self):
 self.enabled = True
 self.checked = False
 def onClick(self):
 pass
class Edit_Operations(object):
 """Implementation for Python_Snaptool_addin.extension20 (Extension)"""
 def __init__(self):
 # For performance considerations, please remove all unused methods in this class.
 self.enabled = True
 #edit = arcpy.da.Editor(r'D:\Sample.gdb')
 #self.onStartEditing()
 def startup(self):
 pass
 def onStartEditing(self):
 pythonaddins.MessageBox('Select a data frame', 'INFO', 0)
 pass
 def onStopEditing(self, save_changes):
 pass
 def onStartOperation(self):
 pass
 def beforeStopOperation(self):
 pass
 def onStopOperation(self):
 pass
 def onSaveEdits(self):
 pass
 def onCreateFeature(self):
 pass
class LineClass(object):
 """Implementation for Python_Snaptool_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):
 global mid_point
 edit = arcpy.da.Editor(r'D:\Sample.gdb')
 array = arcpy.Array([arcpy.Point(line_geometry.firstPoint.X,line_geometry.firstPoint.Y),arcpy.Point(line_geometry.lastPoint.X,line_geometry.lastPoint.Y)]) 
 polyline = arcpy.Polyline(array)
 edit.startEditing()
 edit.startOperation() 
 cursor = arcpy.da.InsertCursor("CrossLine", ["SHAPE@"])
 cursor.insertRow([polyline])
 del cursor 
 mid_point = arcpy.Point() 
 mid_point.X= line_geometry.positionAlongLine(0.50,True).firstPoint.X
 mid_point.Y= line_geometry.positionAlongLine(0.50,True).firstPoint.Y
 edit.stopOperation()
 edit.stopEditing(True) ## Stop the edit session with True to save the changes
 arcpy.RefreshActiveView()
 obj = Edit_Operations()
 pass
 
 def onRectangle(self, rectangle_geometry):
 pass&lt;SPAN class="line-numbers-rows"&gt;&lt;S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lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you help me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to snap the line feature after line drawn , also need to activate the Edit tool programmatically to select the annotation .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;requirement steps:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;step 1&amp;nbsp; : create a line feature with snapping mode activation&lt;/P&gt;&lt;P&gt;step 2 : select the annotation&lt;/P&gt;&lt;P&gt;step 3 : snap the selected text to the mid point of the created line feature.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Intention of the code :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;created&amp;nbsp; 3 classes in addin&amp;nbsp;&lt;/P&gt;&lt;P&gt;one for line feature draw&lt;/P&gt;&lt;P&gt;two for select the annotation&lt;/P&gt;&lt;P&gt;three for button click if necessary&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;created a gdb (D:\Sample.gdb)&amp;nbsp;&lt;/P&gt;&lt;P&gt;created annotation and line feature classes for testing in arcmap using the addin tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Gopi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:12:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/activate-the-edit-tool-and-snap-operations-using/m-p/99845#M7744</guid>
      <dc:creator>gopi_chandangaluri</dc:creator>
      <dc:date>2021-12-11T06:12:13Z</dc:date>
    </item>
  </channel>
</rss>

