<?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 Re: Get Attribute Value from Selected Feature in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/get-attribute-value-from-selected-feature/m-p/627152#M2059</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are making it way too hard on yourself. Let's simplify the code a little:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onMouseDownMap(self, x, y, button, shift):
&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; # set up environment
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = "C:/temp/python/test.gdb"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Parcels = "C:/temp/python/test.gdb/Parcels"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("current")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = mxd.activeDataFrame

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # build point geometry, run your getSearchDistanceInches function&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointGeom = arcpy.PointGeometry(arcpy.Point(x, y), mxd.activeDataFrame.spatialReference)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; searchdistance = getSearchDistanceInches(df.scale, 3)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # make an arcpy.mapping layer obj and do the selection by location
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; plyr = arcpy.mapping.Layer(Parcels)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(plyr, "INTERSECT", pointGeom, "%d INCHES" % searchdistance, "NEW_SELECTION")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # all done, now add our layer to the map
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(df, plyr, "BOTTOM")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are 2 kinds of feature layers used in arcpy code. The type made by MakeFeatureLayer_management is a geoprocessing layer and does not work with some parts arcpy.mapping, like AddLayer. The other kind is an arcpy.mapping layer object, which can be a feature layer or a number of other kinds of layers.&amp;nbsp; If it is feature layer, then it will work with at least some of the geoprocessing tools like SelectLayerByLocation that expect a feature layer. If this seems confusing, don't feel bad. It confuses me too. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's some more confusing stuff: You can create an arcpy.mapping.Layer object from a saved .lyr file, like you were doing. Now, the documentation doesn't tell you this, but you can also make a layer object from a feature class on a disk, from another layer in the toc, or even from a geoprocessing layer made with MakeFeatureLayer_management.&amp;nbsp; So all the work you were doing to make a .lyr file was unnecessary.&amp;nbsp; Just make an arcpy.mapping layer straight from the feature class, select against that layer, and add it to the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You were raising an error in your code so that's why it seemed nothing was happening. The addin environment is really tough to debug in, since you don't get to see the traceback and usually don't even know an error has occurred.&amp;nbsp; So I get my code running first by executing it in the Python window. Then, when everything is running correctly, I stick the code into a method or function in the addin.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;good luck,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 02:43:30 GMT</pubDate>
    <dc:creator>MikeHunter</dc:creator>
    <dc:date>2021-12-12T02:43:30Z</dc:date>
    <item>
      <title>Get Attribute Value from Selected Feature</title>
      <link>https://community.esri.com/t5/transportation-questions/get-attribute-value-from-selected-feature/m-p/627151#M2058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: wjackson&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to write python-addin code to create a tool that would enable a user to click on a feature and get an attribute value. The attribute value would be used as a parameter to open an MS Access form (much later). In 10.1 the arcpy.SelectLayerByLocation should be able to use a point geometry but I cannot get it to work and need help. I know I need to create a layer from the feature I'm trying to select on. So, in my code I try to add the layer to the TOC just so I can see that it gets created and the feature selected. I cannot get the layer to add so do not know if a selection is made or not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; import arcpy
from arcpy import env
import pythonaddins
import os
import subprocess

class ToolClass2(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for ArcGISAddins_addin.tool (Tool)"""
&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.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onMouseDownMap(self, x, y, button, shift):
&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; arcpy.env.workspace = "C:/temp/python/test.gdb"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Parcels = "C:/temp/python/test.gdb/Parcels"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #message = "Your mouse clicked:" + str(x) + ", " + str(y)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #pythonaddins.MessageBox(message, "My Coordinates")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("current")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointGeom = arcpy.PointGeometry(arcpy.Point(x, y), mxd.activeDataFrame.spatialReference)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = mxd.activeDataFrame
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; searchdistance = getSearchDistanceInches(df.scale, 3)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #lyr = arcpy.mapping.ListLayers(mxd)[0].name # assumes you want to select features from 1st layer in TOC
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Make a layer from the feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(Parcels, "feature_layer")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SaveToLayerFile_management("feature_layer", "C:/temp/python/test.gdg/Parcels.lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addlayer = arcpy.mapping.Layer("C:/temp/python/Parcels.lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(df, addlayer, "BOTTOM")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management("feature_layer", "INTERSECT", pointGeom, "%d INCHES" % searchdistance,"NEW_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.Delete_management("feature_layer")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:43:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/get-attribute-value-from-selected-feature/m-p/627151#M2058</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T02:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Get Attribute Value from Selected Feature</title>
      <link>https://community.esri.com/t5/transportation-questions/get-attribute-value-from-selected-feature/m-p/627152#M2059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are making it way too hard on yourself. Let's simplify the code a little:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onMouseDownMap(self, x, y, button, shift):
&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; # set up environment
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = "C:/temp/python/test.gdb"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Parcels = "C:/temp/python/test.gdb/Parcels"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("current")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = mxd.activeDataFrame

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # build point geometry, run your getSearchDistanceInches function&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointGeom = arcpy.PointGeometry(arcpy.Point(x, y), mxd.activeDataFrame.spatialReference)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; searchdistance = getSearchDistanceInches(df.scale, 3)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # make an arcpy.mapping layer obj and do the selection by location
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; plyr = arcpy.mapping.Layer(Parcels)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(plyr, "INTERSECT", pointGeom, "%d INCHES" % searchdistance, "NEW_SELECTION")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # all done, now add our layer to the map
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(df, plyr, "BOTTOM")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are 2 kinds of feature layers used in arcpy code. The type made by MakeFeatureLayer_management is a geoprocessing layer and does not work with some parts arcpy.mapping, like AddLayer. The other kind is an arcpy.mapping layer object, which can be a feature layer or a number of other kinds of layers.&amp;nbsp; If it is feature layer, then it will work with at least some of the geoprocessing tools like SelectLayerByLocation that expect a feature layer. If this seems confusing, don't feel bad. It confuses me too. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's some more confusing stuff: You can create an arcpy.mapping.Layer object from a saved .lyr file, like you were doing. Now, the documentation doesn't tell you this, but you can also make a layer object from a feature class on a disk, from another layer in the toc, or even from a geoprocessing layer made with MakeFeatureLayer_management.&amp;nbsp; So all the work you were doing to make a .lyr file was unnecessary.&amp;nbsp; Just make an arcpy.mapping layer straight from the feature class, select against that layer, and add it to the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You were raising an error in your code so that's why it seemed nothing was happening. The addin environment is really tough to debug in, since you don't get to see the traceback and usually don't even know an error has occurred.&amp;nbsp; So I get my code running first by executing it in the Python window. Then, when everything is running correctly, I stick the code into a method or function in the addin.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;good luck,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:43:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/get-attribute-value-from-selected-feature/m-p/627152#M2059</guid>
      <dc:creator>MikeHunter</dc:creator>
      <dc:date>2021-12-12T02:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Get Attribute Value from Selected Feature</title>
      <link>https://community.esri.com/t5/transportation-questions/get-attribute-value-from-selected-feature/m-p/627153#M2060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: wjackson&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much for your response and explanation of the feature layers. It works quite well now. I'm going to submit another post on the piece to open an MS Access form. Almost there...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Bill Jackson&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You are making it way too hard on yourself. Let's simplify the code a little:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onMouseDownMap(self, x, y, button, shift):
&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; # set up environment
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = "C:/temp/python/test.gdb"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Parcels = "C:/temp/python/test.gdb/Parcels"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("current")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = mxd.activeDataFrame

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # build point geometry, run your getSearchDistanceInches function&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointGeom = arcpy.PointGeometry(arcpy.Point(x, y), mxd.activeDataFrame.spatialReference)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; searchdistance = getSearchDistanceInches(df.scale, 3)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # make an arcpy.mapping layer obj and do the selection by location
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; plyr = arcpy.mapping.Layer(Parcels)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(plyr, "INTERSECT", pointGeom, "%d INCHES" % searchdistance, "NEW_SELECTION")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # all done, now add our layer to the map
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(df, plyr, "BOTTOM")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;There are 2 kinds of feature layers used in arcpy code. The type made by MakeFeatureLayer_management is a geoprocessing layer and does not work with some parts arcpy.mapping, like AddLayer. The other kind is an arcpy.mapping layer object, which can be a feature layer or a number of other kinds of layers.&amp;nbsp; If it is feature layer, then it will work with at least some of the geoprocessing tools like SelectLayerByLocation that expect a feature layer. If this seems confusing, don't feel bad. It confuses me too. &lt;BR /&gt;&lt;BR /&gt;Here's some more confusing stuff: You can create an arcpy.mapping.Layer object from a saved .lyr file, like you were doing. Now, the documentation doesn't tell you this, but you can also make a layer object from a feature class on a disk, from another layer in the toc, or even from a geoprocessing layer made with MakeFeatureLayer_management.&amp;nbsp; So all the work you were doing to make a .lyr file was unnecessary.&amp;nbsp; Just make an arcpy.mapping layer straight from the feature class, select against that layer, and add it to the map.&lt;BR /&gt;&lt;BR /&gt;You were raising an error in your code so that's why it seemed nothing was happening. The addin environment is really tough to debug in, since you don't get to see the traceback and usually don't even know an error has occurred.&amp;nbsp; So I get my code running first by executing it in the Python window. Then, when everything is running correctly, I stick the code into a method or function in the addin.&lt;BR /&gt;&lt;BR /&gt;good luck,&lt;BR /&gt;Mike&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:43:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/get-attribute-value-from-selected-feature/m-p/627153#M2060</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T02:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Get Attribute Value from Selected Feature</title>
      <link>https://community.esri.com/t5/transportation-questions/get-attribute-value-from-selected-feature/m-p/627154#M2061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd add that once you have the feature selected, an easy way to grab the attribute value is with arcpy.da.SearchCursor:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14599163068228102 jive_macro_code jive_text_macro" data-renderedposition="60_8_1119_16" jivemacro_uid="_14599163068228102"&gt;&lt;P&gt;line_id = arcpy.da.SearchCursor(plyr, "LINE_ID").next()[0]&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2016 04:18:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/get-attribute-value-from-selected-feature/m-p/627154#M2061</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2016-04-06T04:18:30Z</dc:date>
    </item>
  </channel>
</rss>

