<?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 Call batch tool arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1245810#M66421</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to write a script that calls a batch tool but cannot get it to work. Any feedback is much appreciated. Code snippet is below (I marked out the file path for privacy purposes):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NSamu_0-1672949703673.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59829i346F643D393A191F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NSamu_0-1672949703673.png" alt="NSamu_0-1672949703673.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nicole&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jan 2023 20:16:25 GMT</pubDate>
    <dc:creator>NSamu</dc:creator>
    <dc:date>2023-01-05T20:16:25Z</dc:date>
    <item>
      <title>Call batch tool arcpy</title>
      <link>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1245810#M66421</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to write a script that calls a batch tool but cannot get it to work. Any feedback is much appreciated. Code snippet is below (I marked out the file path for privacy purposes):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NSamu_0-1672949703673.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59829i346F643D393A191F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NSamu_0-1672949703673.png" alt="NSamu_0-1672949703673.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nicole&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 20:16:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1245810#M66421</guid>
      <dc:creator>NSamu</dc:creator>
      <dc:date>2023-01-05T20:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Call batch tool arcpy</title>
      <link>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1245822#M66423</link>
      <description>&lt;P&gt;Hi Nicole,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you post the code of BatchSelectLayerByLocation which appears to reside in Default.tbx?&amp;nbsp; It's citing two lines in there that I'm guessing are not reading parameters correctly.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 20:27:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1245822#M66423</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2023-01-05T20:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Call batch tool arcpy</title>
      <link>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1245828#M66424</link>
      <description>&lt;P&gt;Okay, does this help (please disregard shortened file paths)?&lt;/P&gt;&lt;P&gt;# -*- coding: utf-8 -*-&lt;BR /&gt;"""&lt;BR /&gt;Generated by ArcGIS ModelBuilder on : 2023-01-05 15:35:27&lt;BR /&gt;"""&lt;BR /&gt;import arcpy&lt;BR /&gt;from sys import argv&lt;BR /&gt;def # NOT IMPLEMENTED# Function Body not implemented&lt;/P&gt;&lt;P&gt;def BatchSelectLayerByLocation(Input_Features, Relationship="INTERSECT", Batch_Selecting_Features, Search_Distance, Selection_type="NEW_SELECTION", Invert_spatial_relationship=False): # Batch Select Layer By Location&lt;/P&gt;&lt;P&gt;# To allow overwriting outputs change overwriteOutput option to True.&lt;BR /&gt;arcpy.env.overwriteOutput = False&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;for Selecting_Features in # NOT IMPLEMENTED(Batch_Selecting_Features):&lt;/P&gt;&lt;P&gt;# Process: Parse Path (Parse Path) (mb)&lt;BR /&gt;Path, Name, Extension, Workspace_Name = arcpy.mb.ParsePathExt(in_data_element=Selecting_Features, format="FORMAT")&lt;/P&gt;&lt;P&gt;# Process: Select Layer By Location (Select Layer By Location) (management)&lt;BR /&gt;if Name:&lt;BR /&gt;Layer_With_Selection, Output_Layer_Names, Count = arcpy.management.SelectLayerByLocation(in_layer=Input_Features, overlap_type=Relationship, select_features=Selecting_Features, search_distance=Search_Distance, selection_type=Selection_type, invert_spatial_relationship=Invert_spatial_relationship)&lt;/P&gt;&lt;P&gt;# Process: Collect_Values (Collect Values)&lt;BR /&gt;# Collect Values Utility is not implemented&lt;/P&gt;&lt;P&gt;return Layer_With_Selection, Output_Layer_Names, Count, Output_Values&lt;/P&gt;&lt;P&gt;if __name__ == '__main__':&lt;BR /&gt;# Global Environment settings&lt;BR /&gt;with arcpy.EnvManager(scratchWorkspace=r"P:\...\Default.gdb", workspace=r"P:\...\Default.gdb"):&lt;BR /&gt;BatchSelectLayerByLocation(*argv[1:])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 20:40:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1245828#M66424</guid>
      <dc:creator>NSamu</dc:creator>
      <dc:date>2023-01-05T20:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: Call batch tool arcpy</title>
      <link>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1245870#M66425</link>
      <description>&lt;P&gt;Oh, yikes I didn't realize this was something from modelbuilder.&amp;nbsp; I am an infant in MB.&amp;nbsp; I would probably go with writing a python toolbox (*.pyt) which gives you more control over the workflow and parameters.&amp;nbsp; What exactly is this supposed to do?&amp;nbsp; I could write up a quick example for you; it would be easier to read and maintain.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 22:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1245870#M66425</guid>
      <dc:creator>EricEagle</dc:creator>
      <dc:date>2023-01-05T22:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Call batch tool arcpy</title>
      <link>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1246013#M66435</link>
      <description>&lt;P&gt;If that code is directly from the Model, I think the model is broke.&amp;nbsp; Your layers you want to intersect are assigned to the Batch_Selecting_Features argument, but in the method, the code is not using that variable and is says:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;Selecting_Features &lt;SPAN&gt;in &lt;/SPAN&gt;&lt;SPAN&gt;# NOT IMPLEMENTED(Batch_Selecting_Features):&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;It probably should be:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;Selecting_Features &lt;SPAN&gt;in &lt;/SPAN&gt;Batch_Selecting_Features:&lt;/PRE&gt;&lt;P&gt;Output_Values is not assigned in the return.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;return &lt;/SPAN&gt;Layer_With_Selection&lt;SPAN&gt;, &lt;/SPAN&gt;Output_Layer_Names&lt;SPAN&gt;, &lt;/SPAN&gt;Count&lt;SPAN&gt;, &lt;/SPAN&gt;Output_Values&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;So my guess is the model needs to be looked at and fixed.&amp;nbsp; I know export to python sometimes creates bad code, but it shouldn't look like what you pasted unless there are issues.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 14:44:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1246013#M66435</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-01-06T14:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Call batch tool arcpy</title>
      <link>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1246099#M66437</link>
      <description>&lt;P&gt;When posting code please format it, click on the 3 dots icon to do that then the &amp;lt;/&amp;gt; icon. YOU can always go back an edit your question.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 17:31:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1246099#M66437</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2023-01-06T17:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Call batch tool arcpy</title>
      <link>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1246429#M66461</link>
      <description>&lt;P&gt;Eric, thanks. It's not a model that I built in model builder--I just right-clicked the select by location geoprocessing tool to create/save a batch tool to my toolbox. ESRI automatically converts batch tools created in that way to model tools. I right-clicked to edit the batch tool and exported the code from the model builder interface since there is no option to pull the code from the tool's properties menu, like with custom script tools. The tool works when I run it by itself. It allows you to select by location on one feature class, based on it's spatial relationship to many feature classes. e.g. I can select all parcels that intersect features within multiple other layers.&lt;/P&gt;&lt;P&gt;If there's no easy way to call a batch tool in Python, I may exclude that tool from my script and try to write some code to do the same thing. I just thought that calling batch tools looked quick/simple, so I wanted to figure out what I was doing wrong.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 14:44:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/call-batch-tool-arcpy/m-p/1246429#M66461</guid>
      <dc:creator>NSamu</dc:creator>
      <dc:date>2023-01-09T14:44:59Z</dc:date>
    </item>
  </channel>
</rss>

