<?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: Export Selected Features from Layer within ArcMap in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330753#M25745</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/EN/HELP/MAIN/10.2/index.html#/GetParameterAsText/03q300000090000000/"&gt;arcpy.GetParameterAsText()&lt;/A&gt; grabs the value from the tool dialog. Since you're running this from the Python window, there is no tool dialog, thus no value to describe. Until you're ready to run this within a tool, you can debug with a hardcoded value:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14452823684111592 jive_macro_code jive_text_macro" data-renderedposition="71_8_912_16" jivemacro_uid="_14452823684111592"&gt;&lt;P&gt;lyr = "THE_NAME_OF_YOUR_LAYER_IN_THE_TOC"&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Oct 2015 19:18:31 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2015-10-19T19:18:31Z</dc:date>
    <item>
      <title>Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330745#M25737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to create a python script that will export selected features from a layer within ArcMap.&amp;nbsp; The general workflow would be the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) User opens ArcMap&lt;/P&gt;&lt;P&gt;2) User manually selects features from layer&lt;/P&gt;&lt;P&gt;3) User runs script that exports ONLY selected features from layer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This seems pretty straight-forward but I'm not used to dealing with interactive selections.&amp;nbsp; I'm also wondering if it's necessary to add in some logic for variances in layer names since users may alter the layer name...?&amp;nbsp; Can this be made as a parameter of the script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm also wondering if it would be best to have users run this as a python tool from a toolbox or if a python add-in is possible so it's a button click...?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 18:18:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330745#M25737</guid>
      <dc:creator>mpboyle</dc:creator>
      <dc:date>2015-10-19T18:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330746#M25738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Most tools respect selections. If you run &lt;A href="http://resources.arcgis.com/EN/HELP/MAIN/10.2/index.html#//001700000035000000"&gt;Copy Features&lt;/A&gt; while there is a selection, only the selected features will be copied (otherwise, all features will be copied).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 18:30:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330746#M25738</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-10-19T18:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330747#M25739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there any reason you wouldn't just use Copy Features &lt;A href="http://resources.arcgis.com/EN/HELP/MAIN/10.2/index.html#//001700000035000000" title="http://resources.arcgis.com/EN/HELP/MAIN/10.2/index.html#//001700000035000000"&gt;ArcGIS Help (10.2, 10.2.1, and 10.2.2)&lt;/A&gt; ? I'm just trying to figure out what the purpose of creating a script tool would be when there are multiple standard ways to do an export operation within ArcMap? I suppose having a python add-in on mouse click or selection would be the most user friendly way to go about it. Is this for users who are not familiar with ArcMap? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 18:32:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330747#M25739</guid>
      <dc:creator>LukeSturtevant</dc:creator>
      <dc:date>2015-10-19T18:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330748#M25740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is the initial step of the script.&amp;nbsp; I have several other geoprocessing functions to run after I get the selection set exported to a working feature class (ex: Near, Join, etc...)&amp;nbsp; I'm just looking to get started on the best way to have a script export out a selected set of features from a map doc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 18:35:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330748#M25740</guid>
      <dc:creator>mpboyle</dc:creator>
      <dc:date>2015-10-19T18:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330749#M25741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Conversely from what Darren posted, if you don't want them mucking about with geoprocessing tools at all, you could have them right click the layer and Data&amp;gt;Export Data.&amp;nbsp; The drop down allows for only selected features to be exported to a new feature class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is an easy enough task I'm having a hard time finding a reason to automate such a small portion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 18:39:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330749#M25741</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2015-10-19T18:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330750#M25742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Again...from the reply above, this is just the first step in a longer process.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 18:41:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330750#M25742</guid>
      <dc:creator>mpboyle</dc:creator>
      <dc:date>2015-10-19T18:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330751#M25743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/EN/HELP/MAIN/10.2/index.html#/What_is_a_Python_add_in/014p00000025000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;Python Add-Ins&lt;/A&gt; are definitely handy if you can get the coding to work. Whether you go with an add-in or just a standard script tool you'll want to set it up with a selection check like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
feature =&amp;nbsp; arcpy.GetParameterAsText(0)
outputFeature =&amp;nbsp; arcpy.GetParameterAsText(1)


selectionCheck = arcpy.Describe(feature).FIDSet
if not selectionCheck:
&amp;nbsp;&amp;nbsp; arcpy.AddError("\nYou must have a selection.\n")
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(feature, outputFeature)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:39:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330751#M25743</guid>
      <dc:creator>LukeSturtevant</dc:creator>
      <dc:date>2021-12-11T15:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330752#M25744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Luke,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe I'm not understanding the GetParameterAsText method, I'm assuming it's just a user-entered value?&amp;nbsp; If I use your code snippet, I get the error shown below.&amp;nbsp; Your code makes sense to me...enter a layer name, enter an output feature class, check to see if the layer has a set of OBJECTIDs, if not raise an error, if so, copy to output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure why I'm getting this error...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="error.JPG" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/132335_error.JPG" style="width: 620px; height: 256px;" /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 19:13:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330752#M25744</guid>
      <dc:creator>mpboyle</dc:creator>
      <dc:date>2015-10-19T19:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330753#M25745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/EN/HELP/MAIN/10.2/index.html#/GetParameterAsText/03q300000090000000/"&gt;arcpy.GetParameterAsText()&lt;/A&gt; grabs the value from the tool dialog. Since you're running this from the Python window, there is no tool dialog, thus no value to describe. Until you're ready to run this within a tool, you can debug with a hardcoded value:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14452823684111592 jive_macro_code jive_text_macro" data-renderedposition="71_8_912_16" jivemacro_uid="_14452823684111592"&gt;&lt;P&gt;lyr = "THE_NAME_OF_YOUR_LAYER_IN_THE_TOC"&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 19:18:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330753#M25745</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-10-19T19:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330754#M25746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Matthew, the &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;A href="http://resources.arcgis.com/EN/HELP/MAIN/10.2/index.html#//018v00000047000000"&gt;GetParameterAsText &lt;/A&gt;​is for setting parameters for a script tool. In my code there are two parameters that the script tool would look for then. An Input Layer and an Output Layer. Also I need to edit the code because the first input should be &lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;arcpy.GetParameterAsText(0&lt;/SPAN&gt;&lt;SPAN class="number" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: green; background-color: #f6f6f6;"&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000; background-color: #f6f6f6;"&gt;).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to test the code outside of a python script tool you would set the 'lyr' to a full path to a shapefile or feature class. Such as: lyr = "C:\Test.shp"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 19:20:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330754#M25746</guid>
      <dc:creator>LukeSturtevant</dc:creator>
      <dc:date>2015-10-19T19:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330755#M25747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You use &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;GetParameterAsText as a way to pass parameters to a script. For your test set your lyr = "YourLayersName" and it should run.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 19:22:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330755#M25747</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2015-10-19T19:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330756#M25748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I appreciate your help!&amp;nbsp; Sorry for all the questions, first time I've really worked with GetParameter and python script tools. Now that I understand what it's used for and how to test it properly, this makes sense &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can then use the Parameters toolbar to index the parameters, is that right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/132337_pastedImage_2.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 19:30:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330756#M25748</guid>
      <dc:creator>mpboyle</dc:creator>
      <dc:date>2015-10-19T19:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330757#M25749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You got it. You can set the output parameter to be a Feature Layer and then direction to Output like so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/132331_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Oct 2015 19:35:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330757#M25749</guid>
      <dc:creator>LukeSturtevant</dc:creator>
      <dc:date>2015-10-19T19:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: Export Selected Features from Layer within ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330758#M25750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;Please have a look at this video&amp;nbsp;&lt;A class="link-titled" href="https://www.youtube.com/watch?v=naZlLuDHRSM" title="https://www.youtube.com/watch?v=naZlLuDHRSM"&gt;Extract selected features from multiple layers using Arcgis - YouTube&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2018 08:32:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-selected-features-from-layer-within-arcmap/m-p/330758#M25750</guid>
      <dc:creator>SibghatUllah1</dc:creator>
      <dc:date>2018-08-29T08:32:02Z</dc:date>
    </item>
  </channel>
</rss>

