Select to view content in your preferred language

How to Export the Utility network Rules along with RuleID:

1235
9
Jump to solution
06-07-2023 09:46 AM
VeerSingh2
New Contributor III

Hello Guys,

I'm trying to access the utility network rules with RuleID and some other details using Python but it is saying no definition of network rules in Arcpy.describe(UN).networkrule.

any idea to how to get full details of un rules

# Import required modules
import arcpy

# Describe function on a Utility Network
UN = "C:\\MyProject\\databaseConn.sde\\mygdb.USER1.Naperville\\mygdb.USER1.ElectricNetwork"

d = arcpy.Describe(UN)

netRules = d.networkRules
for nr in netRules:


print("*** - Network Rules properties - ***")
print(f"RuleID: {nr.ID}")
print(f"RuleType: {nr.Type}")

print(f"FromClassName: {nr.FromClassName}")
print(f"FromAssetGroupCode: {nr.FromAssetGroupCode}")
print(f"FromAssetGroup: {nr.FromAssetGroup}")
print(f"FromAssetTypeCode: {nr.FromAssetTypeCode}")
print(f"FromAssetType: {nr.FromAssetType}")
print(f"FromTerminal: {nr.FromTerminal}")

print(f"ToClassName: {nr.ToClassName}")
print(f"ToAssetGroupCode: {nr.ToAssetGroupCode}")
print(f"ToAssetGroup: {nr.ToAssetGroup}")
print(f"ToAssetTypeCode: {nr.ToAssetTypeCode}")
print(f"ToAssetType: {nr.ToAssetType}")
print(f"ToTerminal: {nr.ToTerminal}")

 

thanks

Veer

 

0 Kudos
3 Solutions

Accepted Solutions
JohnAlsup
Esri Contributor

there is no object networkRules on the describe of the utility network.

John Alsup
jalsup@esri.com

View solution in original post

0 Kudos
RobertKrisher
Esri Regular Contributor

In order to access the rules you need to query the rules table. If you're accessing a geodatabase (Mobile, SDE, or FGDB) directly it will have the a name similar to your utility_network_description.systemJunctionSource table, but instead of being called system junctions it will be called rules. If you're accessing the rules from a service it will always have layer id of 500003.

 

Here's a snippet I've used in the past:

system_junction_description = un_description.systemJunctionSource
rules_table_base = system_junction_description.name.replace(system_junction_description.sourceType, "Rule")

View solution in original post

0 Kudos
VeerSingh2
New Contributor III

thank you John, Got it 

View solution in original post

0 Kudos
9 Replies
JohnAlsup
Esri Contributor

there is no object networkRules on the describe of the utility network.

John Alsup
jalsup@esri.com
0 Kudos
VeerSingh2
New Contributor III

thank you John, Got it 

0 Kudos
RobertKrisher
Esri Regular Contributor

In order to access the rules you need to query the rules table. If you're accessing a geodatabase (Mobile, SDE, or FGDB) directly it will have the a name similar to your utility_network_description.systemJunctionSource table, but instead of being called system junctions it will be called rules. If you're accessing the rules from a service it will always have layer id of 500003.

 

Here's a snippet I've used in the past:

system_junction_description = un_description.systemJunctionSource
rules_table_base = system_junction_description.name.replace(system_junction_description.sourceType, "Rule")

0 Kudos
VeerSingh2
New Contributor III

thank you Robert, Got it 

0 Kudos
VeerSingh2
New Contributor III

RobertKrisher 

from Rule table I can't get the Description like in pink below.

"72: From[ElectricDistributionLine.LowVoltage] From[ElectricDistributionDevice.CircuitBreaker.Load]"

Actually I have around 22k rules to be deleted .

i need to delete them via script(python).

any help will be appreciated here.

 

arcpy.DeleteRule_un("Electric Network", "JUNCTION_EDGE_CONNECTIVITY",
"72: From[ElectricDistributionLine.LowVoltage] From[ElectricDistributionDevice.CircuitBreaker.Load]")

 

0 Kudos
RobertKrisher
Esri Regular Contributor

If memory serves me, the delete tool doesn't verify the description of the rule being deleted, only the rule ID.

With that being said, it's good to have the full description so you can verify the rules being deleted before you run the script. In order to do that you will need to use the arcpy Describe method to read the utility network properties and look up the network source name, asset group name, and asset type names for each of the from/via/to elements. This can be achieved by looking at the asset groups and asset types of all the edge sources and junction soures for all of your domain networks.

0 Kudos
VeerSingh2
New Contributor III

Hello Robert,

esri dociment is saying to verify the description.

https://pro.arcgis.com/en/pro-app/3.0/tool-reference/utility-networks/delete-rule.htm

 

VeerSingh2_0-1686754192003.png

 

0 Kudos
RobertKrisher
Esri Regular Contributor

The documentation says to include the rule id and the description, but as I said I don't think the tool currently verifies the description. Test it out and let me know!

0 Kudos
VeerSingh2
New Contributor III

thank you Robert,

I'll check it out and let you know!

0 Kudos