<?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 Creating Polygons with MouseDown in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/creating-polygons-with-mousedown/m-p/698#M89</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would like to create an add-in using the "onMouseDown" and create polygon shape files.&amp;nbsp; I have done this with model builder, but I'm not sure how it works with Python.&amp;nbsp; I exported the Python code from the model, but it still didn't seem correct.&amp;nbsp; Has anyone had any experience creating custom polygons using mouse clicks?&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Apr 2013 22:54:43 GMT</pubDate>
    <dc:creator>HoustonRudy</dc:creator>
    <dc:date>2013-04-01T22:54:43Z</dc:date>
    <item>
      <title>Creating Polygons with MouseDown</title>
      <link>https://community.esri.com/t5/python-questions/creating-polygons-with-mousedown/m-p/698#M89</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would like to create an add-in using the "onMouseDown" and create polygon shape files.&amp;nbsp; I have done this with model builder, but I'm not sure how it works with Python.&amp;nbsp; I exported the Python code from the model, but it still didn't seem correct.&amp;nbsp; Has anyone had any experience creating custom polygons using mouse clicks?&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2013 22:54:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-polygons-with-mousedown/m-p/698#M89</guid>
      <dc:creator>HoustonRudy</dc:creator>
      <dc:date>2013-04-01T22:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Polygons with MouseDown</title>
      <link>https://community.esri.com/t5/python-questions/creating-polygons-with-mousedown/m-p/699#M90</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was able to get the first part to work (create polygon from mouse clicks).&amp;nbsp; However, now I am having issues with the "copy features" and "append" tools.&amp;nbsp; The end goal for the tool is for a user to be able to draw a polygon, save it, draw another polygon, and then append every polygon to that same file.&amp;nbsp; Below is the code I have so far:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import pythonaddins
import os

class CreateNewPolygon(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for NewPolygon_addin.CPNtool (Tool)"""
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.cursor = 3
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.shape = "Line"

&amp;nbsp;&amp;nbsp;&amp;nbsp; def onLine(self, line_geometry):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array = arcpy.Array()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; part = line_geometry.getPart(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for pt in part:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print pt.X, pt.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pt)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(line_geometry.firstPoint)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polygon = arcpy.Polygon(array)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Local Variables
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Input = polygon
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NewPolygons = "C:\Arcfiles\test.gdb\NewPolygons"

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Append Polygon to existing file or Create new file if one is not created.&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists("NewPolygons"):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Append_management(Input, NewPolygons, "Test", "", "")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(Input,NewPolygons, "", "0","0","0")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:02:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-polygons-with-mousedown/m-p/699#M90</guid>
      <dc:creator>HoustonRudy</dc:creator>
      <dc:date>2021-12-10T20:02:40Z</dc:date>
    </item>
  </channel>
</rss>

