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?

enter image description here

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")


It is taken from this answer to Unable to Provide Input for a MultiValue Parameter Script Tool


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.

|improve this answer|||||
  • According to my case it should be like: for s in selected: if selected == "DDD": arcpy.AddMessage ("Making a DDD") But python kicks an error – Pavel Pereverzev Dec 13 '16 at 7:42
  • What is the error message? – GISGe Dec 13 '16 at 7:45
  • IndentationError: expected an indented block (multivalue.py, line 8) Line 8 is arcpy.AddMessage ("Making a DDD") – Pavel Pereverzev Dec 13 '16 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 workflow – GISGe Dec 13 '16 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 Dec 13 '16 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.