Create a Network Dataset using a Template in ArcPy - Error

636
4
Jump to solution
01-24-2019 11:46 AM
GThomson
New Contributor III

Hi there,

I'm trying to create a network dataset using a template in Arcpy (my current installed version of ArcPro is 2.2.4 and I'm using the python version associated with this). I'm going to have to make around 20 of these and would prefer to not need to make them manually.

My hope was to create one, export the xml template, and then use that in a loop for each required network dataset (e.g. Network_2018, Network_2019 etc...). I assumed that by editing the input feature class and output network name in the xml to suit each required parameter this shouldn't be a problem (the schema is identical on all of these feature classes).

Here is my current code below:

            

import arcpy

arcpy.CheckOutExtension("network")

new_network_location = r"C:\Users\Gavin\Desktop\Test Folder\Test_Geodatabase\TM_Analysis.gdb\Networks"
xml_template = r"C:\Users\Gavin\Desktop\Test Folder\Template_ND.xml"

arcpy.na.CreateNetworkDatasetFromTemplate(new_network_location, xml_template)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

It all feels fairly straight forward, but I've been trying to get even a test version to work and I'm receiving the following error (this is before any changes to the xml or looping through different networks etc.):

arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 030176: The input file is not a valid XML file.
ERROR 030178: The output feature dataset is not valid.
Failed to execute (CreateNetworkDatasetFromTemplate).

Any help would be greatly appreciated!

Gavin

0 Kudos
1 Solution

Accepted Solutions
JoeBorgione
MVP Esteemed Contributor

What happens if you go this route:(no pun intended...)

CreateNetworkDatasetFromTemplate_na (network_dataset_template, output_feature_dataset)

(Create Network Dataset From Template—ArcGIS Pro | ArcGIS Desktop )

can't wait to retire....

View solution in original post

4 Replies
MelindaMorang
Esri Regular Contributor

I don't see anything obviously wrong with your code.  What happens if you try running the tool manually in Pro?  Do you get the same errors?  If so, the problem is not within your script but something to do with your input data.

0 Kudos
JoeBorgione
MVP Esteemed Contributor

What happens if you go this route:(no pun intended...)

CreateNetworkDatasetFromTemplate_na (network_dataset_template, output_feature_dataset)

(Create Network Dataset From Template—ArcGIS Pro | ArcGIS Desktop )

can't wait to retire....

View solution in original post

GThomson
New Contributor III

That's great thanks! It's always the little things you miss! Works perfectly now, so I should be able to get that looping process going now (fingers crossed)!

0 Kudos
MelindaMorang
Esri Regular Contributor

Oh yeah, duh, sorry.  Joe is correct.  You just have the parameters in the reverse order of what they should be.