AnsweredAssumed Answered

How can I adjust the code, so that only one of the Input data is generated as Output?

Question asked by GeoStudy on Nov 3, 2018
Latest reply on Nov 4, 2018 by GeoStudy

Hey Guys,

The Problem is as follows:

Main problem is that I have different data sets in different geodatabases and out of these datasets I want the end-user to choose one dataset. The selection process in the main problem. With the selected data set you can then work in the routine. I want to narrow down the choice for each routine, because only the use of some data is meaningful in the routine. More routines are developed. I want to predefine which datasets could be used for the routine.

Through a script a data set shall be selected for the use in a routine, so that a feature layer is shown.

The script looks like this:

 

import sys, string, os, arcgisscripting
gp = arcgisscripting.create()
gp.AddToolbox("C:\\Users\\bootcamp\\Desktop\\20181008\\Toolbox.tbx")
Input = gp.GetParameterAsText(0)
gp.AddMessage (gp.GetParameterAsText(0))

if Input == "Fahrradwege": Fahrradwege = "C:\\Users\\bootcamp\\Desktop\\20181008\\touristische Infrastruktur.gdb\\Freizeit\\Fahrradwege" Fahrradwege_Layer = "Fahrradwege_Layer" gp.MakeFeatureLayer_management(Fahrradwege, Fahrradwege_Layer, "", "", "NAME NAME VISIBLE NONE; Shape_Length Shape_Length VISIBLE NONE; Shape_Le_1 Shape_Le_1 VISIBLE NONE") gp.SelectLayerByAttribute_management(Fahrradwege_Layer, "ADD_TO_SELECTION") Zwischenergebnis = "Fahrradwege_Layer" Ergebnis_Layer = "Ergebnis_Layer" gp.MakeFeatureLayer_management(Fahrradwege_Layer, Ergebnis_Layer, "", "", "NAME NAME VISIBLE NONE; Shape_Length Shape_Length VISIBLE NONE; Shape_Le_1 Shape_Le_1 VISIBLE NONE")
elif Input == "Straßen": Strassen = "C:\\Users\\bootcamp\\Desktop\\20181008\\touristische Infrastruktur.gdb\\Transport\\Straßen" gp.MakeFeatureLayer_management(Strassen, Strassen_Layer, "", "", "BEZ BEZ VISIBLE NONE; Shape_Length Shape_Length VISIBLE NONE; Shape_Le_1 Shape_Le_1 VISIBLE NONE") gp.SelectLayerByAttribute_management(Strassen_Layer, "ADD_TO_SELECTION") Zwischenergebnis = "Strassen_Layer" Ergebnis_Layer = "Ergebnis_Layer" gp.MakeFeatureLayer_management(Strassen_Layer, Ergebnis_Layer, "", "", "BEZ BEZ VISIBLE NONE; Shape_Length Shape_Length VISIBLE NONE; Shape_Le_1 Shape_Le_1 VISIBLE NONE")
elif Input == "Schienen": Schienen = "C:\\Users\\bootcamp\\Desktop\\20181008\\touristische Infrastruktur.gdb\\Transport\\Schienen" Schienen_Layer = "Schienen_Layer" gp.MakeFeatureLayer_management(Schienen, Schienen_Layer, "", "", "NAME NAME VISIBLE NONE; Shape_Length Shape_Length VISIBLE NONE; Shape_Le_1 Shape_Le_1 VISIBLE NONE") gp.SelectLayerByAttribute_management(Output_Layer, "ADD_TO_SELECTION") Zwischenergebnis = "Schienen_Layer" Ergebnis_Layer = "Ergebnis_Layer" gp.MakeFeatureLayer_management(Schienen_Layer, Ergebnis_Layer, "", "", "NAME NAME VISIBLE NONE; Shape_Length Shape_Length VISIBLE NONE; Shape_Le_1 Shape_Le_1 VISIBLE NONE")
else: print ("Fehlerhafte Auswahl! Dieser Datensatz existiert nicht!")
gp.SetParameter(1,Ergebnis_Layer)

Parameters for the script are defined as follows:

 

If I integrate my script in the Modul Builder in ArcGIS, this script stays white. 

I want to generate the Result_Layer(Ergebins_Layer) as Output. The routine shall then work with the output. Right now, the entry mask of the script queries the Result_Layer(Ergebins_Layer). The output file is not yet generated. I can’t put something in the mask, that is not there. It looks like this: 

 

 

How can I adjust the code, so that the Result_Layer is only generated as the output?

Outcomes