<?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: m.listLayers problematic when run in background tool? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/m-listlayers-problematic-when-run-in-background/m-p/1050197#M40072</link>
    <description>&lt;P&gt;custom tools and models run in the foreground even if background is enabled.&lt;/P&gt;&lt;P&gt;Check the help topic for further restrictions.&lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcmap/latest/analyze/executing-tools/foreground-and-background-processing.htm" target="_blank"&gt;Foreground and background processing—ArcMap | Documentation (arcgis.com)&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Apr 2021 17:32:36 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2021-04-22T17:32:36Z</dc:date>
    <item>
      <title>m.listLayers problematic when run in background tool?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/m-listlayers-problematic-when-run-in-background/m-p/1050168#M40069</link>
      <description>&lt;P&gt;This script creates feature layer files from features in a dataset, then uses the m.listLayers function to reference those layers and update the symbology renderer. The script works w/o issues in the foreground in Jupyter Notebook. However, when the script is called using a custom tool in the GeoProcessing window, interacting with the same aprx and map, the script runs, generates the layer files in the dflt gdb, but then does not draw the layers in the map. It makes me think the way I am referencing the layer files is problematic when run in the background? Any suggestions? Thanks, Penelope&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#List features from Results feature dataset
#Make feature layer from features, add feature layers to map
m = aprx.listMaps()[0]
datasets = arcpy.ListDatasets(feature_type='feature')
for ds in datasets:
    ResultList= arcpy.ListFeatureClasses("*", "ALL", ds)
    for fc in ResultList:
        OutFile = os.path.join(wkspc, str(fc))
        arcpy.MakeFeatureLayer_management(fc, fc, None, None)
        lf = arcpy.management.SaveToLayerFile(fc, OutFile)
p = arcpy.mp.ArcGISProject("CURRENT")
for lyr in m.listLayers():
    if lyr.isFeatureLayer:
        sym = lyr.symbology
        if hasattr(sym, 'renderer'):
            if sym.renderer.type == "SimpleRenderer":
                #sym.updateRenderer('GraduatedSymbolsRenderer')
                #modify graduated symbol renderer
                fields = arcpy.ListFields(lyr)
                #fields = ListFields(dataset)
                for field in fields:
                    if field in fields:
                        if field.name=="Total_Deli":
                            sym.updateRenderer('GraduatedSymbolsRenderer')
                            sym.renderer.classificationField = "Total_Deli"
                            sym.renderer.breakCount = 6
                            sym.renderer.minimumSymbolSize = 1
                            sym.renderer.maximumSymbolSize = 8
                            sym.renderer.colorRamp = p.listColorRamps("Greens")[0]

                        lyr.symbology = sym&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 16:45:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/m-listlayers-problematic-when-run-in-background/m-p/1050168#M40069</guid>
      <dc:creator>PenelopeMitchell2</dc:creator>
      <dc:date>2021-04-22T16:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: m.listLayers problematic when run in background tool?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/m-listlayers-problematic-when-run-in-background/m-p/1050197#M40072</link>
      <description>&lt;P&gt;custom tools and models run in the foreground even if background is enabled.&lt;/P&gt;&lt;P&gt;Check the help topic for further restrictions.&lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcmap/latest/analyze/executing-tools/foreground-and-background-processing.htm" target="_blank"&gt;Foreground and background processing—ArcMap | Documentation (arcgis.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 17:32:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/m-listlayers-problematic-when-run-in-background/m-p/1050197#M40072</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-04-22T17:32:36Z</dc:date>
    </item>
  </channel>
</rss>

