<?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: mp.ArcGISProject.save() crash in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/mp-arcgisproject-save-crash/m-p/1488232#M70770</link>
    <description>&lt;P&gt;So, in my experience, I normally get the OS error when someone else (even me) is using that APRX. This includes both arcpy.mp.ArcGISProject("path")/arcpy.mp.ArcGISProject("path") and also&amp;nbsp;arcpy.mp.ArcGISProject("path")/arcpy.mp.ArcGISProject("CURRENT").&lt;/P&gt;&lt;P&gt;Is it possible that you've opened that APRX already outside of the function you shared here?&lt;/P&gt;&lt;P&gt;If you have, you might want to consider passing the APRX object into the function instead.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jun 2024 13:38:15 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2024-06-10T13:38:15Z</dc:date>
    <item>
      <title>mp.ArcGISProject.save() crash</title>
      <link>https://community.esri.com/t5/python-questions/mp-arcgisproject-save-crash/m-p/1487748#M70763</link>
      <description>&lt;P&gt;Got a script which does the same operation that includes opening, altering and saving arcpy.mp.ArcGISProject object. Prior to editing the worflow inside the ArcGIS Pro project all iterations of the workflow finished without a problem. After changes which shouldn´t cause issues, the project workflow crashes at the end (arcpy.mp.ArcGISProject.save()) of 2nd iteration causing an OSError. All the names are fine, inspected the code in big detail. Made a new&amp;nbsp;ArcGIS Pro project, reinstalled&amp;nbsp;ArcGIS Pro, same result. Neither deleting the&amp;nbsp;arcpy.mp.ArcGISProject variable after using its save() method didn´t help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The function called multiple times per script causing the crash:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def to_arcpy(positioned, face_num):
    # Xm, Ym, Xp, Yp, XC, YC, XB, YB
    positioned = [i * (180 / np.pi) for i in positioned]        # convert to deg
    p = ac.mp.ArcGISProject(r"outputProj\project.aprx")        # a group for upcoming map layers
    group_n = f'face{face_num}'

    if face_num in (1, 2, 3, 4, 5, 11):             # gnomonic polar north
        sr = ac.SpatialReference(102034)
    else:
        sr = ac.SpatialReference(102036)            # gnomonic polar south          

    m = p.listMaps(group_n)[0]
    geoms = []
    sr = ac.SpatialReference('WGS 1984')
    clipper = rf'outputProj\project.gdb\boundary_{face_num}'

    line = ac.Array()
    for i in range(len(positioned[6])):         
        line.add(ac.Point(positioned[7][i], positioned[6][i]))

    line.add(line[0])
    ac.CopyFeatures_management(ac.Polygon(line, sr), clipper)

    pairs1 = ((positioned[0], positioned[1]), (positioned[2], positioned[3]))        # Xm, Ym, Xp, Yp

    for i in range(len(pairs1)):
        shp = pairs1[i][0].shape    
        lines_out = []

        for j in np.arange(shp[0]):
            line = ac.Array()

            for k in np.arange(shp[1]):
                line.add(ac.Point(pairs1[i][1][j, k], pairs1[i][0][j, k]))

            lines_out.append(ac.Polyline(line, sr))
            
        geoms.append(lines_out)

    names = ('d', 's')
    for i in range(2):
        ac.Clip_analysis(geoms[i], clipper, rf'outputProj\project.gdb\{names[i]}_{face_num}') 

    names = ('boundary', 'd', 's')
    sym_names = ('boundary', 'graticule', 'graticule')

    for i in range(3):
        layer_n = f'{names[i]}_{face_num}'
        layer_loc = os.path.join(os.getcwd(), rf'outputProj\project.gdb\{layer_n}')
        layer_loc = rf'{layer_loc[0].upper()}{layer_loc[1 : ]}'

        m.addDataFromPath(layer_loc)
        sym_m = p.listMaps('symbology')[0]
        ac.ApplySymbologyFromLayer_management(m.listLayers(layer_n)[0], sym_m.listLayers(sym_names[i])[0])

    boundary = m.listLayers('boundary*')[0]
    m.moveLayer(m.listLayers()[0], boundary)
    m.clipLayers(boundary)
    p.save()
    l = p.listLayouts()[0]
    mf = l.listElements('mapframe_element', group_n)[0]
    mf.camera.setExtent(ac.Describe(boundary).extent)

    p.save()
    del p&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 08 Jun 2024 17:35:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mp-arcgisproject-save-crash/m-p/1487748#M70763</guid>
      <dc:creator>kradijaf</dc:creator>
      <dc:date>2024-06-08T17:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: mp.ArcGISProject.save() crash</title>
      <link>https://community.esri.com/t5/python-questions/mp-arcgisproject-save-crash/m-p/1488232#M70770</link>
      <description>&lt;P&gt;So, in my experience, I normally get the OS error when someone else (even me) is using that APRX. This includes both arcpy.mp.ArcGISProject("path")/arcpy.mp.ArcGISProject("path") and also&amp;nbsp;arcpy.mp.ArcGISProject("path")/arcpy.mp.ArcGISProject("CURRENT").&lt;/P&gt;&lt;P&gt;Is it possible that you've opened that APRX already outside of the function you shared here?&lt;/P&gt;&lt;P&gt;If you have, you might want to consider passing the APRX object into the function instead.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 13:38:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/mp-arcgisproject-save-crash/m-p/1488232#M70770</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2024-06-10T13:38:15Z</dc:date>
    </item>
  </channel>
</rss>

