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

361
3
11-03-2018 04:23 AM
VerenaSarwas
New Contributor

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?

Tags (1)
0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus

if you are providing a 'value list' as the input string what is your output parameter defined as? Is it 'derived' from that?

There is nothing showing in the first line currently and is your output parameter derived?

If the output is derived it shouldn't show in the dialog

If your script tool has derived output, you need to set the value of the derived output parameter in your script using the SetParameterAsText or SetParameter function.
0 Kudos
VerenaSarwas
New Contributor

At the moment the output Layer is defined as Feature Layer. When I set the output as string the script turns yellow now. But the output is empty. What do you mean with “There is nothing showing in the first line?”

0 Kudos
DanPatterson_Retired
MVP Emeritus

Your input line.  A feature class (unless you want a *.lyr) might be more appropriate for your output

A derived parameter wouldn't have the 2nd line, because derived parameters are output

0 Kudos