I have some scripts that make symbology for different layers in my TOC. And now I want to merge them into one big script which should have parameters chosen by user to start certain part of script. For instance I have three layers: GGG, DDD, DDA. The whole script contains code to make symbology for all these layers. But is it possible to make something like this?
If box "DDD" is checked script run the part of it which will paint only DDD layer. If it is possible what kind of code I should add to script?
Updated code:
for s in selected:
if selected == "DDD":
arcpy.AddMessage("Making a DDD")
ary = arcpy.mapping.Layer(r"\\SRV-NAS-03\Projects\FIAS_MultiPART.lyr")
arcpy.mapping.AddLayer (df,ary,"AUTO_ARRANGE")
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
It is taken from this answer to Unable to Provide Input for a MultiValue Parameter Script Tool
1 Answer 1
You can retrieve the values checked in the inputdata
parameter using this code:
import arcpy
all_selected = arcpy.GetParameterAsText(0)
selected = all_selected.split(";")
for s in selected:
if s == "DDD":
arcpy.AddMessage("Making a DDD")
# ...
See Setting script tool parameters for reference.
-
According to my case it should be like:
for s in selected: if selected == "DDD": arcpy.AddMessage ("Making a DDD")
But python kicks an errorPavel Pereverzev– Pavel Pereverzev2016年12月13日 07:42:07 +00:00Commented Dec 13, 2016 at 7:42 -
-
IndentationError: expected an indented block (multivalue.py, line 8)
Line 8 is arcpy.AddMessage ("Making a DDD")Pavel Pereverzev– Pavel Pereverzev2016年12月13日 07:48:21 +00:00Commented Dec 13, 2016 at 7:48 -
Says what it says, check your indentation. Write your script in an editor to get your syntax checked. I've edited my code to match your workflowGISGe– GISGe2016年12月13日 07:52:54 +00:00Commented Dec 13, 2016 at 7:52
-
Just replaced. Now it is without errors, however, do nothing if I tick DDD. No messages and adding of symbology layers. Identation is okay.Pavel Pereverzev– Pavel Pereverzev2016年12月13日 07:58:09 +00:00Commented Dec 13, 2016 at 7:58