3

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

arcpy.RefreshActiveView()
arcpy.RefreshTOC()

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

1 Answer 1

2

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.

9
  • 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 Dec 13, 2016 at 7:42
  • What is the error message?
    – GISGe
    Dec 13, 2016 at 7:45
  • IndentationError: expected an indented block (multivalue.py, line 8) Line 8 is arcpy.AddMessage ("Making a DDD") 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 workflow
    – GISGe
    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. Dec 13, 2016 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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