I have this tool where the user inputs an ID number and the tool selects a list of features applies symbology (.lyr) and adds the queried features to the open mxd.
# Import modules import arcpy import os # Set overwrite option from arcpy import env env.overwriteOutput = True # Set variables pws = arcpy.GetParameterAsText(0) files = ["SERVICE_AREA_COMBO", "BACTI", "DBP", "DBP_STAGE2", "OFFICE", "PRV", "PUMP_STATION", "TANK", "VALVE_MISCELLANEOUS", "WTP"] # list all names used for feature classes and .lyr files. layers = ["Service Area " + pws, "Bacti " + pws, "DBP " + pws, "DBP Stage 2 " + pws, "Office " + pws, "PRV " + pws, "Pump Station " + pws, "Tank " + pws, "Valve " + pws, "Water Treatment Plant " + pws] root = r"V:\WATER_FACILITY\WATER_FACILITY.gdb" symRoot = r"V:\ArcGIS_Tools\pws_id_tool" for i, file in enumerate(files): path = os.path.join(root, files) # Create directory path for featureclasses symPath = os.path.join(symRoot, files + ".lyr") # Create directory path for .lyr files arcpy.MakeFeatureLayer_management(path, layers, "PWS_ID" + " = '" + pws + "'") # Make all the layers from "files" list arcpy.ApplySymbologyFromLayer_management(layers, symPath) # Apply the symbologies from "symNames" list. featureCount = int(arcpy.GetCount_management(layers).getOutput(0)) arcpy.AddMessage(layers + " count = " + str(featureCount)) if featureCount > 0: newLayer = arcpy.mapping.Layer(layers) arcpy.mapping.AddLayer(df, newLayer, "TOP") else: arcpy.AddWarning("No " + layers + " features for this PWS.") The only parameter entered is ID number. I would like to have the user select which features they want to add to the map by using GetPramaterAsText with the 'Data Type' set as boolean. That way they can check, or uncheck, the boxes based on what features they want added to their mxd. I' m not quite sure how I would approach this with the for loop, if it can be done?
أكثر...
# Import modules import arcpy import os # Set overwrite option from arcpy import env env.overwriteOutput = True # Set variables pws = arcpy.GetParameterAsText(0) files = ["SERVICE_AREA_COMBO", "BACTI", "DBP", "DBP_STAGE2", "OFFICE", "PRV", "PUMP_STATION", "TANK", "VALVE_MISCELLANEOUS", "WTP"] # list all names used for feature classes and .lyr files. layers = ["Service Area " + pws, "Bacti " + pws, "DBP " + pws, "DBP Stage 2 " + pws, "Office " + pws, "PRV " + pws, "Pump Station " + pws, "Tank " + pws, "Valve " + pws, "Water Treatment Plant " + pws] root = r"V:\WATER_FACILITY\WATER_FACILITY.gdb" symRoot = r"V:\ArcGIS_Tools\pws_id_tool" for i, file in enumerate(files): path = os.path.join(root, files) # Create directory path for featureclasses symPath = os.path.join(symRoot, files + ".lyr") # Create directory path for .lyr files arcpy.MakeFeatureLayer_management(path, layers, "PWS_ID" + " = '" + pws + "'") # Make all the layers from "files" list arcpy.ApplySymbologyFromLayer_management(layers, symPath) # Apply the symbologies from "symNames" list. featureCount = int(arcpy.GetCount_management(layers).getOutput(0)) arcpy.AddMessage(layers + " count = " + str(featureCount)) if featureCount > 0: newLayer = arcpy.mapping.Layer(layers) arcpy.mapping.AddLayer(df, newLayer, "TOP") else: arcpy.AddWarning("No " + layers + " features for this PWS.") The only parameter entered is ID number. I would like to have the user select which features they want to add to the map by using GetPramaterAsText with the 'Data Type' set as boolean. That way they can check, or uncheck, the boxes based on what features they want added to their mxd. I' m not quite sure how I would approach this with the for loop, if it can be done?
أكثر...