<?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: use a selection of features in arcmap in python script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/use-a-selection-of-features-in-arcmap-in-python/m-p/723285#M56002</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mathew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for your answer. I got another answer that pushed me in the right direction. I have the user make the selection in ArcMap and input this feature class with the selected features as a feature layer in my toolbox tool. In the code, I just had to copy features and then create my feature layer to work with it. Please see the top part of my code attached.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy,os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ws = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pipes = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = ws&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pipesnew = os.path.join(ws,"Pipes")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management(pipes,pipesnew)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management(pipesnew,"lyr")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Jun 2013 20:42:26 GMT</pubDate>
    <dc:creator>KatharinaPalffy-Gelfand</dc:creator>
    <dc:date>2013-06-17T20:42:26Z</dc:date>
    <item>
      <title>use a selection of features in arcmap in python script</title>
      <link>https://community.esri.com/t5/python-questions/use-a-selection-of-features-in-arcmap-in-python/m-p/723283#M56000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to write a python script and can't get over the first obstacle. I am on ArcMap 10.1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I want for the user to select features in ArcMap and then use these selected features in a python script. Is there a way to do that?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Has somebody attempted that before and has some sample code?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The code that I tried does not use the selection, but the whole feature class instead. Please see code snippet below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Exporting selected features to working database...")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management(fc1,"fclyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SetParameter(1,"fclyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fc2 = os.path.join(ws1,"Pipes")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management("fclyr", fc2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 14:25:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-a-selection-of-features-in-arcmap-in-python/m-p/723283#M56000</guid>
      <dc:creator>KatharinaPalffy-Gelfand</dc:creator>
      <dc:date>2013-06-17T14:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: use a selection of features in arcmap in python script</title>
      <link>https://community.esri.com/t5/python-questions/use-a-selection-of-features-in-arcmap-in-python/m-p/723284#M56001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Make Feature Layer and most other GP tools honour selections. If you are running in the background that may cause issues.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: Also, are you sure you are passing in the layer with the selection as the parameter and not the feature class the selection is based off of? Try posting your complete tool.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 14:37:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-a-selection-of-features-in-arcmap-in-python/m-p/723284#M56001</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-06-17T14:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: use a selection of features in arcmap in python script</title>
      <link>https://community.esri.com/t5/python-questions/use-a-selection-of-features-in-arcmap-in-python/m-p/723285#M56002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mathew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for your answer. I got another answer that pushed me in the right direction. I have the user make the selection in ArcMap and input this feature class with the selected features as a feature layer in my toolbox tool. In the code, I just had to copy features and then create my feature layer to work with it. Please see the top part of my code attached.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy,os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ws = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pipes = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = ws&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pipesnew = os.path.join(ws,"Pipes")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management(pipes,pipesnew)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management(pipesnew,"lyr")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 20:42:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-a-selection-of-features-in-arcmap-in-python/m-p/723285#M56002</guid>
      <dc:creator>KatharinaPalffy-Gelfand</dc:creator>
      <dc:date>2013-06-17T20:42:26Z</dc:date>
    </item>
  </channel>
</rss>

