<?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: Arcpy script : add output with predefined symbology to current project's active map in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-add-output-with-predefined-symbology/m-p/1485453#M84195</link>
    <description>&lt;P&gt;Here is my workaround!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
aprxMap = aprx.activeMap  #Map must be active when script launched
lyr = aprxMap.addDataFromPath(fc) #add data to map
L = aprxMap.addDataFromPath(lyrx_symbology) #add lyrx to map
sym = L.symbology # get symbology from lyrx
lyr.symbology = sym #apply symbology to data
aprxMap.removeLayer(L) #remove lyrx from project&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jun 2024 16:07:00 GMT</pubDate>
    <dc:creator>Anne-MarieDubois</dc:creator>
    <dc:date>2024-06-05T16:07:00Z</dc:date>
    <item>
      <title>Arcpy script : add output with predefined symbology to current project's active map</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-add-output-with-predefined-symbology/m-p/1417087#M82556</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to create a script that will add output with a predefined symbology (.lyrx parameter). Apparently you can control that with tool parameters&amp;nbsp; (&lt;A href="https://community.esri.com/t5/python-questions/cannot-apply-symbology-from-layer-using-python/m-p/16037/highlight/true#M1243" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/python-questions/cannot-apply-symbology-from-layer-using-python/m-p/16037/highlight/true#M1243&lt;/A&gt;) but I can't figure how to set that there AND THEN have the data added to the map.&lt;/P&gt;&lt;P&gt;&amp;nbsp; Here is my current code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    aprx = arcpy.mp.ArcGISProject("CURRENT")
    aprxMap = aprx.activeMap
    aprxMap.addDataFromPath(arcpy.management.ApplySymbologyFromLayer(in_layer=arcpy.MakeFeatureLayer_management(ZONE_DETAILS_FILLED, "Carte d'occupation du territoire"), in_symbology_layer=Symbologie, symbology_fields="VALUE_FIELD TYPE TYPE", update_symbology="MAINTAIN"))

#Where 
#ZONE_FILLED_DETAILS is the created output from previous tool
#Symbology is the .lyrx that is defined in the script parameters&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It&amp;nbsp;&amp;nbsp;works really well with raw path within the python window of ArcGIS Pro. However, if I try it within the full script I get this error:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;Traceback (most recent call last):
  File "&amp;lt;string&amp;gt;", line 61, in &amp;lt;module&amp;gt;
  File "C:\Program Files\XTools\XTools AGP\Python\Tools\FeaturesToPointsTool.py", line 7, in &amp;lt;module&amp;gt;
    import XTools.XToolsAGP.Geoprocessing
ModuleNotFoundError: No module named 'XTools'
Traceback (most recent call last):
  File "C:\Temp\22_0993_Outil_carbone\SCRIPTS\OutilCarboneCERFO_v4.py", line 643, in &amp;lt;module&amp;gt;
    OutilCarboneCouches(*argv[1:])
  File "C:\Temp\22_0993_Outil_carbone\SCRIPTS\OutilCarboneCERFO_v4.py", line 550, in OutilCarboneCouches
    aprxMap.addDataFromPath(arcpy.management.ApplySymbologyFromLayer(in_layer=arcpy.MakeFeatureLayer_management(ZONE_DETAILS_FILLED, "Carte d'occupation du territoire"), in_symbology_layer=Symbologie, symbology_fields="VALUE_FIELD TYPE TYPE", update_symbology="MAINTAIN"))
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_
    return fn(*args, **kw)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 3744, in addDataFromPath
    return convertArcObjectToPythonObject(self._arc_object.addDataFromPath(*gp_fixargs((data_path, web_service_type, custom_parameters,), True)))
RuntimeError&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a cue for me?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 15:52:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-add-output-with-predefined-symbology/m-p/1417087#M82556</guid>
      <dc:creator>Anne-MarieDubois</dc:creator>
      <dc:date>2024-04-30T15:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy script : add output with predefined symbology to current project's active map</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-add-output-with-predefined-symbology/m-p/1417889#M82651</link>
      <description>&lt;P&gt;I am looking to do the same thing in a stand-alone script, so I'd love to know if there's a cure as well!&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 01:30:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-add-output-with-predefined-symbology/m-p/1417889#M82651</guid>
      <dc:creator>BrendaMikkiBarnes</dc:creator>
      <dc:date>2024-05-02T01:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy script : add output with predefined symbology to current project's active map</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-add-output-with-predefined-symbology/m-p/1485453#M84195</link>
      <description>&lt;P&gt;Here is my workaround!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
aprxMap = aprx.activeMap  #Map must be active when script launched
lyr = aprxMap.addDataFromPath(fc) #add data to map
L = aprxMap.addDataFromPath(lyrx_symbology) #add lyrx to map
sym = L.symbology # get symbology from lyrx
lyr.symbology = sym #apply symbology to data
aprxMap.removeLayer(L) #remove lyrx from project&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 16:07:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-script-add-output-with-predefined-symbology/m-p/1485453#M84195</guid>
      <dc:creator>Anne-MarieDubois</dc:creator>
      <dc:date>2024-06-05T16:07:00Z</dc:date>
    </item>
  </channel>
</rss>

