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

asked Dec 13, 2016 at 6:54

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.

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.