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
Solved! Go to Solution.
there is no object networkRules on the describe of the utility network.
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")
thank you John, Got it
there is no object networkRules on the describe of the utility network.
thank you John, Got it
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")
thank you Robert, Got it
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]")
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.
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
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!
thank you Robert,
I'll check it out and let you know!