<?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 ERROR 003207: ...\testLRS\TestEventFC cannot be deleted because it participates in a Location Referencing dataset in ArcGIS Roads and Highways Questions</title>
    <link>https://community.esri.com/t5/arcgis-roads-and-highways-questions/error-003207-testlrs-testeventfc-cannot-be-deleted/m-p/1201716#M232</link>
    <description>&lt;P&gt;I am trying to use the ArcPy code below with ArcGIS Pro 3.0.0 and a File Geodatabase to:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create &lt;SPAN&gt;&amp;nbsp;events for my LRS Network on its first run&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Remove my LRS events and then delete its event feature class, before recreating events for my LRS Network on its second and subsequent runs&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
gdb = r"C:\temp\test.gdb"
fdName = "testLRS"
fd = r"{0}\{1}".format(gdb,fdName)
lrsNetworkName = "TestLRSNetworkR"
lrsNetwork = r"{0}\{1}".format(fd,lrsNetworkName)
eventFCname = "TestEventFC"
eventFC = r"{0}\{1}".format(fd,eventFCname)

if arcpy.Exists(eventFC):
    arcpy.AddMessage("Removing LRS Event {0} and deleting {1}".format(eventFCname,eventFC))
    arcpy.locref.RemoveLRSEntity(gdb,"EVENT",eventFCname)
    arcpy.management.Delete(eventFC)
arcpy.AddMessage("Creating LRS Event {0} and its feature class".format(eventFCname))
arcpy.locref.CreateLRSEvent(lrsNetwork,eventFCname,"LINE", "EventId",
                            "FromRouteId", "FromDate", "ToDate", "LocError", "FromMeasure", "ToMeasure",
                            "NO_SPANS_ROUTES", "ToRouteId", "STORE_ROUTE_NAME", "RouteName", "ToRouteName")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I run the code by adding it to a toolbox as a Python Script tool with no parameters.&lt;/P&gt;&lt;P&gt;When I run it once the new LRS events are created as expected.&lt;/P&gt;&lt;P&gt;When I re-run it I get an error:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR 003207: ...\testLRS\TestEventFC cannot be deleted because it participates in a Location Referencing dataset&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This is unexpected because I have no problem using the Catalog pane to right-click on&amp;nbsp;..\testLRS\TestEventFC and Delete it.&amp;nbsp; I am also able to delete it by loading the Delete tool into the Geoprocessing pane - it is just trying to do it from Python that causes the error.&lt;/P&gt;&lt;P&gt;I have tried using a Python sleep function for 30 seconds between&amp;nbsp;RemoveLRSEntity and Delete just in case it needs a little time to finish the&amp;nbsp;RemoveLRSEntity but that makes no difference.&lt;/P&gt;&lt;P&gt;Is there any way that I can use Python code to check for LRS events, remove them as an LRS entity if they exist, and then delete the underlying event feature class?&lt;/P&gt;</description>
    <pubDate>Thu, 11 Aug 2022 01:43:30 GMT</pubDate>
    <dc:creator>GraemeBrowning_Aurizon</dc:creator>
    <dc:date>2022-08-11T01:43:30Z</dc:date>
    <item>
      <title>ERROR 003207: ...\testLRS\TestEventFC cannot be deleted because it participates in a Location Referencing dataset</title>
      <link>https://community.esri.com/t5/arcgis-roads-and-highways-questions/error-003207-testlrs-testeventfc-cannot-be-deleted/m-p/1201716#M232</link>
      <description>&lt;P&gt;I am trying to use the ArcPy code below with ArcGIS Pro 3.0.0 and a File Geodatabase to:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create &lt;SPAN&gt;&amp;nbsp;events for my LRS Network on its first run&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Remove my LRS events and then delete its event feature class, before recreating events for my LRS Network on its second and subsequent runs&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
gdb = r"C:\temp\test.gdb"
fdName = "testLRS"
fd = r"{0}\{1}".format(gdb,fdName)
lrsNetworkName = "TestLRSNetworkR"
lrsNetwork = r"{0}\{1}".format(fd,lrsNetworkName)
eventFCname = "TestEventFC"
eventFC = r"{0}\{1}".format(fd,eventFCname)

if arcpy.Exists(eventFC):
    arcpy.AddMessage("Removing LRS Event {0} and deleting {1}".format(eventFCname,eventFC))
    arcpy.locref.RemoveLRSEntity(gdb,"EVENT",eventFCname)
    arcpy.management.Delete(eventFC)
arcpy.AddMessage("Creating LRS Event {0} and its feature class".format(eventFCname))
arcpy.locref.CreateLRSEvent(lrsNetwork,eventFCname,"LINE", "EventId",
                            "FromRouteId", "FromDate", "ToDate", "LocError", "FromMeasure", "ToMeasure",
                            "NO_SPANS_ROUTES", "ToRouteId", "STORE_ROUTE_NAME", "RouteName", "ToRouteName")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I run the code by adding it to a toolbox as a Python Script tool with no parameters.&lt;/P&gt;&lt;P&gt;When I run it once the new LRS events are created as expected.&lt;/P&gt;&lt;P&gt;When I re-run it I get an error:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR 003207: ...\testLRS\TestEventFC cannot be deleted because it participates in a Location Referencing dataset&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This is unexpected because I have no problem using the Catalog pane to right-click on&amp;nbsp;..\testLRS\TestEventFC and Delete it.&amp;nbsp; I am also able to delete it by loading the Delete tool into the Geoprocessing pane - it is just trying to do it from Python that causes the error.&lt;/P&gt;&lt;P&gt;I have tried using a Python sleep function for 30 seconds between&amp;nbsp;RemoveLRSEntity and Delete just in case it needs a little time to finish the&amp;nbsp;RemoveLRSEntity but that makes no difference.&lt;/P&gt;&lt;P&gt;Is there any way that I can use Python code to check for LRS events, remove them as an LRS entity if they exist, and then delete the underlying event feature class?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 01:43:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-roads-and-highways-questions/error-003207-testlrs-testeventfc-cannot-be-deleted/m-p/1201716#M232</guid>
      <dc:creator>GraemeBrowning_Aurizon</dc:creator>
      <dc:date>2022-08-11T01:43:30Z</dc:date>
    </item>
  </channel>
</rss>

