# Name: DissolveNetwork_Workflow.py
# Description: Creates a new network dataset with reduced number of line
# features in a new file geodatabase workspace. The network dataset
# is also built so that it can be used to perform network analyses.
# Requirements: Network Analyst Extension
#Import system modules
#Check out Network Analyst license if available. Fail if the Network Analyst license is not available.
if arcpy.CheckExtension("network") == "Available":
raise arcpy.ExecuteError("Network Analyst Extension license is not available.")
#Set environment settings
arcpy.env.workspace = "C:/data/SanFrancisco.gdb"
arcpy.env.overwriteOutput = True
#Set local variables
inNetworkDataset = "Transportation/Streets_ND"
outFolder = "C:/data/output"
outputGDBName = "SanFranciscoDissolved"
#Create a new file geodatabase that will contain the dissolved network
result = arcpy.CreateFileGDB_management(outFolder, outputGDBName)
#Get the path to the newly created file gdb from the result object.
outputGDB = result.getOutput(0)
#Dissolve the network dataset
result = arcpy.DissolveNetwork_na(inNetworkDataset, outputGDB)
#Get the path to the dissolved network dataset from the result object
dissolvedNetworkDataset = result.getOutput(0)
#The dissolved network dataset is unbuilt. So build the network dataset
print("Script completed successfully")
except Exception as e: