<?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 Selection sequence works in python window but not as stand alone script. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/selection-sequence-works-in-python-window-but-not/m-p/369529#M29206</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was wondering why a selection chain consisted by a "Selected by attributes" followed by a "selected by location" command provides an empty fc as a stand alone script, while it works fine in the python window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here's my piece of code which provides the desirable selection in the python window but produces empty feature classes as a stand alone script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;aree_layer = "aree_2HA_" + input_file[-8:-4]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;punti_layer = "punti_2HA_" + input_file[-8:-4]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management(input_directory + "\\" + input_file, aree_layer) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management(output_directory + "\\" + "p_" + input_file[-8:-4] + ".shp", punti_layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;selection_aree = arcpy.SelectLayerByAttribute_management(aree_layer, 'NEW_SELECTION', ' "NumPoints" = 1 ' )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#select points which are completely within &amp;gt;2HA polygons&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;selection_punti = arcpy.SelectLayerByLocation_management(punti_layer, 'COMPLETELY_WITHIN', aree_layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management(selection_punti, output_directory + "\\" + "selection_punti_" + input_file[-8:-4] + ".shp")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management (aree_layer, "CLEAR_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management (punti_layer, "CLEAR_SELECTION") &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would appreciate any kind of help&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chrysanthi&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 23 Feb 2014 21:57:33 GMT</pubDate>
    <dc:creator>ChrysanthiPolyzoni</dc:creator>
    <dc:date>2014-02-23T21:57:33Z</dc:date>
    <item>
      <title>Selection sequence works in python window but not as stand alone script.</title>
      <link>https://community.esri.com/t5/python-questions/selection-sequence-works-in-python-window-but-not/m-p/369529#M29206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was wondering why a selection chain consisted by a "Selected by attributes" followed by a "selected by location" command provides an empty fc as a stand alone script, while it works fine in the python window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here's my piece of code which provides the desirable selection in the python window but produces empty feature classes as a stand alone script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;aree_layer = "aree_2HA_" + input_file[-8:-4]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;punti_layer = "punti_2HA_" + input_file[-8:-4]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management(input_directory + "\\" + input_file, aree_layer) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management(output_directory + "\\" + "p_" + input_file[-8:-4] + ".shp", punti_layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;selection_aree = arcpy.SelectLayerByAttribute_management(aree_layer, 'NEW_SELECTION', ' "NumPoints" = 1 ' )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#select points which are completely within &amp;gt;2HA polygons&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;selection_punti = arcpy.SelectLayerByLocation_management(punti_layer, 'COMPLETELY_WITHIN', aree_layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management(selection_punti, output_directory + "\\" + "selection_punti_" + input_file[-8:-4] + ".shp")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management (aree_layer, "CLEAR_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management (punti_layer, "CLEAR_SELECTION") &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would appreciate any kind of help&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chrysanthi&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Feb 2014 21:57:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selection-sequence-works-in-python-window-but-not/m-p/369529#M29206</guid>
      <dc:creator>ChrysanthiPolyzoni</dc:creator>
      <dc:date>2014-02-23T21:57:33Z</dc:date>
    </item>
  </channel>
</rss>

