<?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 ArcGIS Pro Python Add Layer Not Working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122028#M63118</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using PYCHARM trying to do something I think is simple but I cannot get it to work!&lt;/P&gt;&lt;P&gt;Inside of PYCHARM I would like to create a new feature class then add it to the map. My code creates the feature class and I can see it in the Geodatabase but it will not show up on the map.&lt;/P&gt;&lt;P&gt;I have tried: addLayer(),&amp;nbsp;addDataFromPath()&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;arcpy&lt;BR /&gt;&lt;BR /&gt;path_workspace = &lt;SPAN&gt;r"C:\Users\Strot\Desktop\ArcGIS Default Map\ArcGIS Default.gdb"&lt;BR /&gt;&lt;/SPAN&gt;arcpy.env.workspace = path_workspace&lt;BR /&gt;arcpy.env.overwriteOutput = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;arcpy.env.addOutputsToMap = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;string_shape_name = &lt;SPAN&gt;"New_Layer_Shape"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;aprx = arcpy.mp.ArcGISProject(&lt;SPAN&gt;r"C:\Users\Strot\Documents\ArcGIS\Projects\Test\Test.aprx"&lt;/SPAN&gt;)&lt;BR /&gt;mp = aprx.listMaps(&lt;SPAN&gt;"Map"&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;fc = arcpy.CreateFeatureclass_management(&lt;SPAN&gt;r"C:\Users\Strot\Documents\ArcGIS\Projects\Test\Test.gdb"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;string_shape_name&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"POLYGON"&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;fl = arcpy.MakeFeatureLayer_management(fc&lt;SPAN&gt;, &lt;/SPAN&gt;string_shape_name)[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;mp.addLayer(fl)&lt;/PRE&gt;&lt;P&gt;I have called Pro support and done all the searching I can, please help!&lt;/P&gt;</description>
    <pubDate>Thu, 02 Dec 2021 02:14:12 GMT</pubDate>
    <dc:creator>StrotherSimpson</dc:creator>
    <dc:date>2021-12-02T02:14:12Z</dc:date>
    <item>
      <title>ArcGIS Pro Python Add Layer Not Working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122028#M63118</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using PYCHARM trying to do something I think is simple but I cannot get it to work!&lt;/P&gt;&lt;P&gt;Inside of PYCHARM I would like to create a new feature class then add it to the map. My code creates the feature class and I can see it in the Geodatabase but it will not show up on the map.&lt;/P&gt;&lt;P&gt;I have tried: addLayer(),&amp;nbsp;addDataFromPath()&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;arcpy&lt;BR /&gt;&lt;BR /&gt;path_workspace = &lt;SPAN&gt;r"C:\Users\Strot\Desktop\ArcGIS Default Map\ArcGIS Default.gdb"&lt;BR /&gt;&lt;/SPAN&gt;arcpy.env.workspace = path_workspace&lt;BR /&gt;arcpy.env.overwriteOutput = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;arcpy.env.addOutputsToMap = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;string_shape_name = &lt;SPAN&gt;"New_Layer_Shape"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;aprx = arcpy.mp.ArcGISProject(&lt;SPAN&gt;r"C:\Users\Strot\Documents\ArcGIS\Projects\Test\Test.aprx"&lt;/SPAN&gt;)&lt;BR /&gt;mp = aprx.listMaps(&lt;SPAN&gt;"Map"&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;fc = arcpy.CreateFeatureclass_management(&lt;SPAN&gt;r"C:\Users\Strot\Documents\ArcGIS\Projects\Test\Test.gdb"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;string_shape_name&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"POLYGON"&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;fl = arcpy.MakeFeatureLayer_management(fc&lt;SPAN&gt;, &lt;/SPAN&gt;string_shape_name)[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;mp.addLayer(fl)&lt;/PRE&gt;&lt;P&gt;I have called Pro support and done all the searching I can, please help!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 02:14:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122028#M63118</guid>
      <dc:creator>StrotherSimpson</dc:creator>
      <dc:date>2021-12-02T02:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Python Add Layer Not Working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122034#M63119</link>
      <description>&lt;P&gt;Did you save the project after?&amp;nbsp; The results won't be present if you have the project open while you are doing this unless you are running a notebook or using Pro's python window.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;aprx.save()&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 02:29:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122034#M63119</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-12-02T02:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Python Add Layer Not Working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122036#M63120</link>
      <description>&lt;P&gt;Wow I think you are right! I checked the map layers using list layers before and after and its not there before but is after.&lt;/P&gt;&lt;P&gt;So I tried the save and got this error, do you have any idea what this could be from?&lt;/P&gt;&lt;P&gt;Thank you so much for your help!&lt;/P&gt;&lt;PRE&gt;#Command&lt;BR /&gt;aprx.save()&lt;BR /&gt;&lt;BR /&gt;# Error&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:/Users/Strot/OneDrive - Desert Royalty Company/Side Projects/5 - Python/2021.11.30 - ArcGIS Operator Development Pace/new_arcgis.py", line 23, in &amp;lt;module&amp;gt;&lt;BR /&gt;aprx.save()&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 285, in save&lt;BR /&gt;return convertArcObjectToPythonObject(self._arc_object.save(*gp_fixargs((), True)))&lt;BR /&gt;OSError: C:\Users\Strot\Documents\ArcGIS\Projects\Test\Test.aprx&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 02:33:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122036#M63120</guid>
      <dc:creator>StrotherSimpson</dc:creator>
      <dc:date>2021-12-02T02:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Python Add Layer Not Working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122040#M63121</link>
      <description>&lt;P&gt;Are you using One Drive Cloud storage for this?&amp;nbsp; If so can you try using a local or network drive instead just to test if those locations will work?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 02:45:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122040#M63121</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-12-02T02:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Python Add Layer Not Working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122041#M63122</link>
      <description>&lt;P&gt;I tried moving it off cloud to local and still got same error.&lt;/P&gt;&lt;P&gt;But it did work if I closed the project, so maybe there is some issue with it being open and trying to save.&lt;/P&gt;&lt;P&gt;Anyways so happy its working, I can live with it being closed that is probably how I intend to run the script anyways.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if anyone has any ideas to this OS error, but so thankful to you guys for the help on this!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 02:50:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122041#M63122</guid>
      <dc:creator>StrotherSimpson</dc:creator>
      <dc:date>2021-12-02T02:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Python Add Layer Not Working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122044#M63123</link>
      <description>&lt;P&gt;where ever you are saving... no spaces, no punctuation in the paths&lt;/P&gt;&lt;P&gt;Save local&lt;/P&gt;&lt;P&gt;Copy to the "cloud" for backup&lt;/P&gt;&lt;P&gt;works every time &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 03:19:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-python-add-layer-not-working/m-p/1122044#M63123</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-12-02T03:19:45Z</dc:date>
    </item>
  </channel>
</rss>

