<?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: How to remove and create structural associations in python toolbox in ArcGIS Utility Network Questions</title>
    <link>https://community.esri.com/t5/arcgis-utility-network-questions/how-to-remove-and-create-structural-associations/m-p/1410218#M3710</link>
    <description>&lt;P&gt;In order to edit the data you will need to start an edit operation then start editing. once you've completed your edits you will need stop your edit operation and stop editing (with save edits = true).&lt;/P&gt;&lt;P&gt;If you want to go down the route of performing these edits in a version, which is a good idea since it lets you QaQc or roll back changes if something fails partway through, you should look at using the ArcGIS API for Python. It will allow you to create a version, perform your edits, validate, reconcile and post, all from a standalone python script (or within ArcGIS Pro if you prefer that approach).&lt;/P&gt;</description>
    <pubDate>Tue, 16 Apr 2024 13:40:29 GMT</pubDate>
    <dc:creator>RobertKrisher</dc:creator>
    <dc:date>2024-04-16T13:40:29Z</dc:date>
    <item>
      <title>How to remove and create structural associations in python toolbox</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/how-to-remove-and-create-structural-associations/m-p/1410017#M3705</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a requirement to develop a python tool to import&amp;nbsp; streetlights (Electric Junction) using a CSV/Excel file. UNM editor runs this tool from ArcGIS pro map by providing CSV file, StructureJunction layer and ElectricJunction layer. CSV file provides details about the streetlights including unique pole ID (Structure Junction) it resides on and also if any existing streetlight on the pole to be removed. Unique pole id is used for the XYZ location of the streetlight. Processing needs to happen in a non-default branch version that current ArcGIS Pro map is connecting to. Here is my workflow&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Ensure current active map has UN topology layer and other required layers such as StructureJunction (for poles) and ElectricJunction (for streetlights) and &lt;STRONG&gt;is connecting to a non-default version&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;For each line in CSV file&lt;OL&gt;&lt;LI&gt;Read streetlight details including pole id.&lt;/LI&gt;&lt;LI&gt;Find pole by the id and get its geometry&amp;nbsp;to add a streetlight using.&lt;/LI&gt;&lt;LI&gt;If there is existing streetlight on the pole, disassociate this streetlight from the pole and change its state to "Removed".&lt;/LI&gt;&lt;LI&gt;Add a new streetlight.&lt;/LI&gt;&lt;LI&gt;Create structural association between the streetlight and pole.&lt;/LI&gt;&lt;LI&gt;Validate the location for topology.&lt;/LI&gt;&lt;LI&gt;Go to next line&amp;nbsp;&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;I can create a new streetlight using arcpy.da.InsertCursor on the streetlights layer. But I cannot see a python tool for creating association. Only tool available is import associations&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/utility-networks/import-associations.htm" target="_blank"&gt;&amp;nbsp;https://pro.arcgis.com/en/pro-app/latest/tool-reference/utility-networks/import-associations.htm&amp;nbsp;&lt;/A&gt;&amp;nbsp; It feels this is a overkill.&lt;/P&gt;&lt;P&gt;Even if I create a CSV file for the association to be created and import it, I cannot see a way to remove association for existing streetlight that needs to be disassociated from the pole for the new streetlight to be added. Is there a better way to create and remove associations using arcpy?&lt;/P&gt;&lt;P&gt;I tried to go down the URL way by finding the REST URL for the Streetlight layer and add a record using "addFeatures". And then I tried to add / remove association record using association layer's (layer id 500001) addFeatures and deleteFeatures. But calling REST API from a python toolbox gives me&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Error: Cannot acquire a lock error.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Failed to add Streetlight ID #xxxxxx: {'error': {'code': 500, 'extendedCode': -2147220947, 'message': 'Unable to complete operation.', 'details': ['Error: Cannot acquire a lock. [StreetlightsProcessing].']}}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;StreetlightsProcessing is the branch version name.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The add features and other REST operations called from python tool are using same version the current map in Pro is connecting to so that user can ensure everything is correct and then reconcile and post. It seems that having Pro map open connecting to a branch version puts a lock on the version and stops any other thread being able to perform any edits. Is this by design? Should version readers block version writer?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea on how I can achieve my workflow?&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 00:35:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/how-to-remove-and-create-structural-associations/m-p/1410017#M3705</guid>
      <dc:creator>EstherSmith_Dev</dc:creator>
      <dc:date>2024-04-16T00:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove and create structural associations in python toolbox</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/how-to-remove-and-create-structural-associations/m-p/1410062#M3706</link>
      <description>&lt;P&gt;Hi Esther,&lt;/P&gt;&lt;P&gt;I guess you could change the version of your map UN workspace to DEFAULT (using arcpy.management.ChangeVersion) in order to release the lock on your target version, make changes through REST or Python API and change back to your target version.&amp;nbsp;&lt;/P&gt;&lt;P&gt;That worked for me before, but changing the version through the user interface.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 04:10:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/how-to-remove-and-create-structural-associations/m-p/1410062#M3706</guid>
      <dc:creator>JuanCarlosOrtiz</dc:creator>
      <dc:date>2024-04-16T04:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove and create structural associations in python toolbox</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/how-to-remove-and-create-structural-associations/m-p/1410218#M3710</link>
      <description>&lt;P&gt;In order to edit the data you will need to start an edit operation then start editing. once you've completed your edits you will need stop your edit operation and stop editing (with save edits = true).&lt;/P&gt;&lt;P&gt;If you want to go down the route of performing these edits in a version, which is a good idea since it lets you QaQc or roll back changes if something fails partway through, you should look at using the ArcGIS API for Python. It will allow you to create a version, perform your edits, validate, reconcile and post, all from a standalone python script (or within ArcGIS Pro if you prefer that approach).&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 13:40:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/how-to-remove-and-create-structural-associations/m-p/1410218#M3710</guid>
      <dc:creator>RobertKrisher</dc:creator>
      <dc:date>2024-04-16T13:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove and create structural associations in python toolbox</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/how-to-remove-and-create-structural-associations/m-p/1413932#M3754</link>
      <description>&lt;P&gt;Thanks for your reply. I have added version name as a parameter to the python tool and expect current map to be using Default version before running the tool. That way I can still call REST API to add update etc in the specific version.&lt;/P&gt;&lt;P&gt;What I really need is an arcpy tool to add an association record between two UNM assets. Seems like it is missing from the UNM toolbox.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 04:03:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/how-to-remove-and-create-structural-associations/m-p/1413932#M3754</guid>
      <dc:creator>EstherSmith_Dev</dc:creator>
      <dc:date>2024-04-23T04:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove and create structural associations in python toolbox</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/how-to-remove-and-create-structural-associations/m-p/1413934#M3755</link>
      <description>&lt;P&gt;Thanks for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can add or update to the UNM layers using arcpy cursors etc with or without start/stop editing. But I do not have any arcpy tool to create structural association between light added and a pole.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 04:06:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/how-to-remove-and-create-structural-associations/m-p/1413934#M3755</guid>
      <dc:creator>EstherSmith_Dev</dc:creator>
      <dc:date>2024-04-23T04:06:16Z</dc:date>
    </item>
  </channel>
</rss>

