How to execute Python script in modell builder

2522
2
06-16-2015 04:01 AM
MarlenaGötza
New Contributor II

Hello,

I want to create and trace a geometric network in model builder with python but it does not work.

I get the following error for the "Create geometric Network" tool when I execute the script in model builder: 

SyntaxError: invalid syntax (create_network.py, line 16) Failed to execute (CreateGeometricNetwork ).

Are the settings and the code right? The first four entries are definded as required inputs, the last one ("Network_Net") is defined as a derived output.

Thanks for your help.

0 Kudos
2 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Marlena,

Looks like the issue is when you try and create the geometric network:

screen1.PNG

It doesn't look like you have the variable 'networkdataset' defined.  I believe this should be 'FeatureDataset'.  Also, there should be a comma after the first variable (i.e. FeatureDataset, "network_Net", .....).

MarlenaGötza
New Contributor II

I changed the code so that the Sccript only creates the geometric network, know it always crashes ArcMapw when I start the execution.

import arcpy

FeatureDataset = arcpy.GetParameterAsText(0)

FeatureClass1 = arcpy.GetParameterAsText(1)

FeatureClass2 = arcpy.GetParameterAsText(2)

FeatureClass3 = arcpy.GetParameterAsText(3)

OutputGroupLayer = arcpy.GetParameterAsText(4)

FeatureClasses = "'" + FeatureClass1 + " COMPLEX_EDGE NO;" + FeatureClass2 + " SIMPLE_JUNCTION YES;" + FeatureClass3 + "SIMPLE_JUNCTION YES" + "'"

print FeatureDataset

Weights = "'" + FeatureClass1 + "SR_L_m Kosten" + "'"

arcpy.AddMessage(FeatureClasses)

try:

    arcpy.CreateGeometricNetwork_management(FeatureDataset, "network_Net", FeatureClasses, "", "Kosten DOUBLE #", Weights, "", "PRESERVE_ENABLED")

except:

    arcpy.AddMessage(arcpy.GetMessages())

0 Kudos