<?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 Select newly created feature in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38940#M3053</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a script that creates a point with a mouse click (onMouseDownMap). The feature class is in a SDE geodatabase which has about 80,000 features in it. An edit session and an edit operation is needed, creating the point work just fine but i need some code after stopping the edit session to select the point that was just created to be able to pass to another function. The problem with starting the an edit session and an edit operation is that it clears the selection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be awesome!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Mar 2014 14:04:50 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2014-03-14T14:04:50Z</dc:date>
    <item>
      <title>Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38940#M3053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a script that creates a point with a mouse click (onMouseDownMap). The feature class is in a SDE geodatabase which has about 80,000 features in it. An edit session and an edit operation is needed, creating the point work just fine but i need some code after stopping the edit session to select the point that was just created to be able to pass to another function. The problem with starting the an edit session and an edit operation is that it clears the selection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be awesome!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Mar 2014 14:04:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38940#M3053</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2014-03-14T14:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38941#M3054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The new feature should have the highest ObjectID, but I wouldn't necessarily rely on that. After creating it, before any edit session, while the new feature is still selected, put the ObjectID in a variable. Then when you go to edit, select that ObjectID.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Mar 2014 14:30:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38941#M3054</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-03-14T14:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38942#M3055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;any reason why you don't just create the point from a template.&amp;nbsp; then it would be automatically selected when you place it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have a script that creates a point with a mouse click (onMouseDownMap). The feature class is in a SDE geodatabase which has about 80,000 features in it. An edit session and an edit operation is needed, creating the point work just fine but i need some code after stopping the edit session to select the point that was just created to be able to pass to another function. The problem with starting the an edit session and an edit operation is that it clears the selection.&lt;BR /&gt;&lt;BR /&gt;Any help would be awesome!&lt;BR /&gt;Thanks.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Mar 2014 14:34:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38942#M3055</guid>
      <dc:creator>RobertBorchert</dc:creator>
      <dc:date>2014-03-14T14:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38943#M3056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have tried to put the new feature Object id in a variable (I think i am doing it right) but I am uncertain because the script takes a long time like it's selecting every point feature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;my script creates the point, populates certain fields, then it's suppose to take that new point and runt a spatial join against the parcels feature class and output the result to the in-memory workspace, then Insert the result from above into your original points feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is what i have.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import pythonaddins
arcpy.env.overwriteOutput = True

fcTarget = "TT"
workspace = r"Connection to sqlexpress.sde"

#arcpy.ChangeVersion_management('TT','TRANSACTIONAL','dbo.DEFAULT', "")
# Start an edit session. Must provide the worksapce.
edit = arcpy.da.Editor(workspace)

# Edit session is started without an undo/redo stack for versioned data
#&amp;nbsp; (for second argument, use False for unversioned data)
edit.startEditing(True)

# Start an edit operation
edit.startOperation()

input = arcpy.GetParameterAsText(0)
CC_list = []
with arcpy.da.SearchCursor(fcTarget, ["AddressID"]) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if "CC" in row[0]:
&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;&amp;nbsp; CC_list.append(int(row[0].strip("CC")))&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except TypeError:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
del cursor

CC_list.sort()
AddressID = CC_list[-1] + 1
AddressID = 'CC' + str(AddressID)

rows = arcpy.SearchCursor(input)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; geom = row.shape
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = geom.lastPoint.X
&amp;nbsp;&amp;nbsp;&amp;nbsp; y = geom.lastPoint.Y 
del row, rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
row_values = [(x, y, (x, y), AddressID)]
cursor = arcpy.da.InsertCursor(fcTarget, ["X_Coord", "Y_Coord", "SHAPE@XY", "ADDRESSID"])

for row in row_values:
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.insertRow(row)
#del cursor

Parcellyr = "testParcelsAdmit"

#maxValue = arcpy.SearchCursor(fcTarget, "", "", "", 'AddressID D').next().getValue("AddressID") #Get 1st row in descending cursor sort
#arcpy.SelectLayerByAttribute_management(fcTarget, "NEW_SELECTION", "\"AddressID\"= " + maxValue)

Par_lyr = arcpy.MakeFeatureLayer_management(Parcellyr, "Parcel layer")
entries = int(arcpy.GetCount_management(fcTarget).getOutput(0))

for i in xrange(entries):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fcTarget, "point layer", "\"OBJECTID\"={}".format(str(i)))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(Par_lyr, "INTERSECT", fcTarget, "", "NEW_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; #if arcpy.Exists(pt_lyr): arcpy.Delete_management(pt_lyr)

#### populates fields

add_fields = ["ACCOUNT","SiteNum","OwnerName","SiteAddres","SiteNumSfx","SiteStreet","predir","StreetType","SubName"]

# fix args
if not isinstance(add_fields, list):
&amp;nbsp;&amp;nbsp;&amp;nbsp; # from script tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; add_fields = add_fields.split(';')

# do not need this scratch file
fcOutput = r'in_memory\temp_join'
arcpy.SpatialJoin_analysis(Par_lyr, fcTarget, fcOutput, 'JOIN_ONE_TO_MANY', 'KEEP_COMMON')


# grab oid field from points
oid_t = arcpy.Describe(fcTarget).OIDFieldName


# init rowW and rowR
curR = arcpy.SearchCursor(fcOutput, query)
join_dict = dict([(r.JOIN_FID,[r.getValue(f) for f in add_fields]) for r in curR])
del curR

# Now update the new target
curW = arcpy.UpdateCursor(fcTarget)
for row in curW:
&amp;nbsp;&amp;nbsp;&amp;nbsp; t_oid = row.getValue(oid_t)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if t_oid in join_dict:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for f in add_fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(f, join_dict[t_oid][add_fields.index(f)])
&amp;nbsp;&amp;nbsp;&amp;nbsp; curW.updateRow(row)
del row, curW
arcpy.Delete_management(r"in_memory\temp_join")
arcpy.AddMessage('Updated all records sucussefully')
arcpy.RefreshActiveView()


# Stop the edit operation.
edit.stopOperation()

# Stop the edit session and save the changes
edit.stopEditing(True)
&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;&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; 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:30:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38943#M3056</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2021-12-10T21:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38944#M3057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Anyone have an example of code that they can share on how to select the newest feature created to pass onto another function?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Mar 2014 19:34:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38944#M3057</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2014-03-14T19:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38945#M3058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Tony,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure if this is what you're looking for, but this should get you the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;most recent&lt;STRONG&gt;***&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; AddressID. If you need more fields, make sure you add them after "OID@" so that it will still be reverse sorted on ObjectID.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for row in sorted(arcpy.da.SearchCursor(fcTarget, ["OID@", "AddressID"]),reverse=True):
&amp;nbsp;&amp;nbsp;&amp;nbsp; mostRecentOID=row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; mostRecentAddressID=row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; break

#Do stuff with mostRecentOID and mostRecentAddressID&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From this point you can use proceed with your script. You can (if you need to) perform a select by attribute using &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;mostRecentOID&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;***&lt;/STRONG&gt;&lt;SPAN&gt;: As Greg said, we are (dangerously) assuming the record with the highest Object ID (OID) is the most recent.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:30:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38945#M3058</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2021-12-10T21:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38946#M3059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hua17 thank you for the help and reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have add the the code you posted to my code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems to kind of work, the issue is that now the OBJECTID field is not being populated and second the first point gets created but the OBJECTID and "add_fields" don't get populated, until I use the tool again to create a second point, then all the fields that i need populated get populated except for OBJECTID field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my current code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import pythonaddins
arcpy.env.overwriteOutput = True

fcTarget = "Points_1"
workspace = r"C:\Temp\default.gdb"

DS3 = "oool"

if arcpy.Exists(DS3):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(DS3)

edit = arcpy.da.Editor(workspace)

# Edit session is started without an undo/redo stack for versioned data
#&amp;nbsp; (for second argument, use False for unversioned data)
edit.startEditing(True)

# Start an edit operation
edit.startOperation()

input = arcpy.GetParameterAsText(0)
CC_list = []
with arcpy.da.SearchCursor(fcTarget, ["AddressID"]) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if "CC" in row[0]:
&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;&amp;nbsp; CC_list.append(int(row[0].strip("CC")))&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except TypeError:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
del cursor

CC_list.sort()
AddressID = CC_list[-1] + 1
AddressID = 'CC' + str(AddressID)

rows = arcpy.SearchCursor(input)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; geom = row.shape
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = geom.lastPoint.X
&amp;nbsp;&amp;nbsp;&amp;nbsp; y = geom.lastPoint.Y 
del row, rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
row_values = [(x, y, (x, y), AddressID)]
cursor = arcpy.da.InsertCursor(fcTarget, ["X_Coord", "Y_Coord", "SHAPE@XY", "ADDRESSID"])

for row in row_values:
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.insertRow(row)
#del cursor

Parcellyr = "testParcelsAdmit"

for row in sorted(arcpy.da.SearchCursor(fcTarget, ["OID@", "AddressID"]),reverse=True):
&amp;nbsp;&amp;nbsp;&amp;nbsp; mostRecentOID=row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; mostRecentAddressID=row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; break
#Do stuff with mostRecentOID and mostRecentAddressID

arcpy.MakeFeatureLayer_management(Parcellyr, "Parcel layer")
if int(arcpy.GetCount_management(fcTarget).getOutput(0)) &amp;gt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(fcTarget, "INTERSECT", "Parcel layer", "", "NEW_SELECTION")

#### populates fields

add_fields = ["ACCOUNT","SiteNum","OwnerName","SiteAddres","SiteNumSfx","SiteStreet","predir","StreetType","SubName"]

# fix args
if not isinstance(add_fields, list):
&amp;nbsp;&amp;nbsp;&amp;nbsp; # from script tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; add_fields = add_fields.split(';')

# do not need this scratch file
fcOutput = 'oool'
arcpy.SpatialJoin_analysis("Parcel layer",fcTarget , fcOutput, 'JOIN_ONE_TO_MANY', 'KEEP_COMMON')


# grab oid field from points
oid_t = arcpy.Describe(fcTarget).OIDFieldName


# init rowW and rowR
curR = arcpy.SearchCursor(fcOutput)
join_dict = dict([(r.JOIN_FID,[r.getValue(f) for f in add_fields]) for r in curR])
del curR

# Now update the new target
curW = arcpy.UpdateCursor(fcTarget)
for row in curW:
&amp;nbsp;&amp;nbsp;&amp;nbsp; t_oid = row.getValue(oid_t)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if t_oid in join_dict:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for f in add_fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(f, join_dict[t_oid][add_fields.index(f)])
&amp;nbsp;&amp;nbsp;&amp;nbsp; curW.updateRow(row)
del row, curW
#arcpy.Delete_management(r"in_memory\temp_join")
arcpy.AddMessage('Updated all records sucussefully')
arcpy.RefreshActiveView()


# Stop the edit operation.
edit.stopOperation()

# Stop the edit session and save the changes
edit.stopEditing(True)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:30:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38946#M3059</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2021-12-10T21:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38947#M3060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Tony,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could explain exactly what you are trying to achieve in this script? I'm finding it a little hard to follow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 17:16:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38947#M3060</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2014-03-19T17:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38948#M3061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The script(add-in tool) is suppose to create a point (for addresses)with the mouse click but i need some fields populated (X_Coord, Y_Coord, ADDRESSID) automatically after the click. The field "AddressID" is suppose to be populated by taking the highest number in that filed and adding 1 to it like auto sequential number, but only one's with CC in front of it. I also need it to populate fields from the parcel the new created point sits on. Hopefully it makes sense.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 19:39:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38948#M3061</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2014-03-19T19:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38949#M3062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Tony,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are a lot of complexities to your script and I'm not exactly sure what the problem is. It is very difficult to replicate the issues you are having because there are so many processes/dependencies.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did your script stop working and we are trying to find out why?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this a new tool that you are trying to get working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the tool already working and are you trying to select the point that you just created in your script?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Mar 2014 20:17:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38949#M3062</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2014-03-20T20:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38950#M3063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is a new script that i am trying to build and get working. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not sure if it's working or not because when i run it the script that i posted above ArcMap just sits there thinking and thinking, i eventually have to use task manager to close arc map. I believe my problem is that the script takes every point and every taxparcels in the spatial join instead of just the newly point and the taxparcel it sits on. but i am not 100% certain becasue my python is not very good.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;what i have been trying to is do a select by location on the parcel layer to see what parcel the new point sits on then populate/copy the point with certain fields from that selected parcel only.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have separated the two functions and they run great separated but not together.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This function of this script runs flawless by it's self and as long as the point is selected. except for the "OBJECTID" does not get populated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I create points in arcmap manually with the create features/construction tool then select them with the selection tool and run the following the points get populated with the parcel info it sits on only.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fcTarget = "Points_3"
workspace = r"C:\Temp\default.gdb"
#workspace = r"C:\Users\talmeida\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\Connection to dsd15_sqlexpress.sde"
arcpy.env.overwriteOutput = True

####Select by location on parcels with created point
Parcellyr = "testParcelsAdmit"

arcpy.MakeFeatureLayer_management(Parcellyr, "Parcel layer")
entries = int(arcpy.GetCount_management(fcTarget).getOutput(0))

for i in xrange(entries):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fcTarget, "point layer", "\"OBJECTID\"={}".format(str(i)))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management("Parcel layer", "INTERSECT", fcTarget, "", "NEW_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; #if arcpy.Exists(pt_lyr): arcpy.Delete_management(pt_lyr)

#### populates fields

add_fields = ["ACCOUNT","SiteNum","OwnerName","SiteAddres","SiteNumSfx","SiteStreet","predir","StreetType","SubName"]

# fix args
if not isinstance(add_fields, list):
&amp;nbsp;&amp;nbsp;&amp;nbsp; # from script tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; add_fields = add_fields.split(';')

# do not need this scratch file
fcOutput = r'in_memory\temp_join'
arcpy.SpatialJoin_analysis("Parcel layer", fcTarget, fcOutput, 'JOIN_ONE_TO_MANY', 'KEEP_COMMON')


# grab oid field from points
oid_t = arcpy.Describe(fcTarget).OIDFieldName

# init rowW and rowR
curR = arcpy.SearchCursor(fcOutput)
join_dict = dict([(r.JOIN_FID,[r.getValue(f) for f in add_fields]) for r in curR])
del curR

# Now update the new target
curW = arcpy.UpdateCursor(fcTarget)
for row in curW:
&amp;nbsp;&amp;nbsp;&amp;nbsp; t_oid = row.getValue(oid_t)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if t_oid in join_dict:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for f in add_fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(f, join_dict[t_oid][add_fields.index(f)])
&amp;nbsp;&amp;nbsp;&amp;nbsp; curW.updateRow(row)
del row, curW
arcpy.Delete_management(r"in_memory\temp_join")
arcpy.AddMessage('Updated all records sucussefully')&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would some sample data help?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:30:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38950#M3063</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2021-12-10T21:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38951#M3064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This is a new script that i am trying to build and get working. &lt;BR /&gt;&lt;BR /&gt;I am not sure if it's working or not because when i run it the script that i posted above ArcMap just sits there thinking and thinking, i eventually have to use task manager to close arc map. I believe my problem is that the script takes every point and every taxparcels in the spatial join instead of just the newly point and the taxparcel it sits on. but i am not 100% certain becasue my python is not very good.&lt;BR /&gt;&lt;BR /&gt;what i have been trying to is do a select by location on the parcel layer to see what parcel the new point sits on then populate/copy the point with certain fields from that selected parcel only.&lt;BR /&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As an alternative to a SelectByLocation after your point creation process, why not collect the Parcel attributes when you first click the location to create the point?&amp;nbsp; Hold them in variables to populate the attributes of the new point feature you create later.&amp;nbsp; This would alleviate the need to perform a lengthy SelectByLocation process (if that is what is causing your performance hit, my guess this is the culprit if you have 10's of thousands of parcels).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 14:20:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38951#M3064</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-03-21T14:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38952#M3065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;jamesfreddyc that sounds intresting, but how would pass the click (input) to do the selection by location on the parcels?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for the replay.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2014 15:09:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38952#M3065</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2014-03-25T15:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Select newly created feature</title>
      <link>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38953#M3066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;jamesfreddyc that sounds intresting, but how would pass the click (input) to do the selection by location on the parcels?&lt;BR /&gt;thanks for the replay.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;See this thread for some examples: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://gis.stackexchange.com/questions/49713/select-and-copy-features-in-arcmap-using-python-add-in-tool" rel="nofollow" target="_blank"&gt;http://gis.stackexchange.com/questions/49713/select-and-copy-features-in-arcmap-using-python-add-in-tool&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Important part is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp; def onMouseDownMap(self, x, y, button, shift): &amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("CURRENT") &amp;nbsp;&amp;nbsp;&amp;nbsp; pointGeom = arcpy.PointGeometry(arcpy.Point(x, y), mxd.activeDataFrame.spatialReference) &amp;nbsp;&amp;nbsp;&amp;nbsp; searchdistance = getSearchDistanceInches(mxd.activeDataFrame.scale) &amp;nbsp;&amp;nbsp;&amp;nbsp; lyr = arcpy.mapping.ListLayers(mxd)[0] # assumes you want to select features from 1st layer in TOC &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(lyr, "INTERSECT", pointGeom, "%d INCHES" % searchdistance) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView() &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Make sure "lyr" is referencing your Parcel layer, then after the refresh you should be able get access to the attributes with a SearchCursor.&amp;nbsp; Use the values in the cursor to populate your point feature with.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(note: I have not implemented the code above, so you would have validate it works.)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2014 16:15:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-newly-created-feature/m-p/38953#M3066</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-03-25T16:15:00Z</dc:date>
    </item>
  </channel>
</rss>

