I'm building a tool where a coworker can enter an ID# (called PWS ID) and then go through choose from a list of features (about 15) they want added from to the map based on the ID#. The tool will select the features based on the ID number, add them as a layer to the map and add the symbology. It wont create any new data, just what is stored in the map memory while it is open. I'm just working on the code at this point. I have a script with A LOT of variables and iterations of arcpy.MakefeatureLayer_management and arcpy.ApplySymbologyFromLayer_managment functions. I know I can hardcode the path to the .lyr files used for symbology, but I'm drawing a blank from there. I'm very much a Python novice and I cant figure out if it can be done by a for loop with arcpy.mapping.ListLayers (for symbology) or some other way.
Also, I didn't add the whole script. I left out the code for labels and applying the extent of a layer.
# Import module(s)
from arcpy import env
# Set overwrite option
env.overwriteOutput = True
# Local variables. Reduce number of variables. Hardcode path for ApplySymbologyFromLayer function or create a list or dictionary?
pws = "PWS_ID='465'" # SQL query.
***_pws = "PWS_ID1 = '465'" # SQL query. Assessment table has different firle dname for PWS ID.
mtr_recpws = "REC_ID = '465'" # SQL query. 'REC_ID" is PWS ID of PWS receiving water through master meter, I assume.
sources = "V:\\Source Water Protection\\SWAP Model\\SWAP.code_newrasters\\GIS\\SWAP.gdb\\sources" # Will need to change if used outside of SWPP staff because of directory permissions.
assessment = "V:\\Source Water Protection\\SWAP Model\\SWAP.code_newrasters\\GIS\\SWAP.gdb\\assessment_areas" # Will need to change if used outside of SWPP staff because of directory permissions. Assessments not in WATER_FACILITY.gdb.
srvc_area = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\SERVICE_AREA_COMBO"
bacti = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\BACTI"
wtp = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\WTP"
dbp2 = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\DBP_STAGE2"
dbp = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\DBP"
tank = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\TANK"
valve = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\VALVE_MISCELLANEOUS"
mstr_mtr = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\MASTER_METER"
waterline = "V:\\WATER_FACILITY\\WATERLINES.gdb"
pumpstn = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\PUMP_STATION"
prv = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\PRV"
press_plane = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\PRESSURE_PLANES"
office = "V:\\WATER_FACILITY\\WATER_FACILITY.gdb\\OFFICE"
src_layer = "Sources"
***_layer = "Assessment Area"
srvc_layer = "Service Area"
bacti_layer = "Bacti"
wtp_layer = "WTP"
dbp_layer = "DBP"
dbp2_layer = "DBP Stage 2"
tank_layer = "Tank"
valve_layer = "Valve"
mtr_layer = "Master Meter"
line_layer = "Waterline"
pump_layer = "Pump Station"
prv_layer = "PRV"
press_layer = "Pressure Plane"
ofc_layer = "Office"
src_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\SOURCE.lyr"
***_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\ASSESSMENT.lyr"
wtp_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\WTP.lyr"
valve_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\VALVE.lyr"
tank_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\TANK.lyr"
dbp_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\DBP.lyr"
dbp2_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\DBP2.lyr"
bacti_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\BACTI.lyr"
mtr_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\MASTER_METER.lyr"
ofc_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\OFFICE.lyr"
prv_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\PRV.lyr"
pump_symb = "V:\\Source Water Protection\\PWS_ID_Tool\\PUMP.lyr"
# Make feature layers
arcpy.MakeFeatureLayer_management(office, ofc_layer, pws)
arcpy.MakeFeatureLayer_management(press_plane, press_layer, pws)
arcpy.MakeFeatureLayer_management(srvc_area, srvc_layer, pws)
arcpy.MakeFeatureLayer_management(mstr_mtr, mtr_layer, mtr_recpws)
arcpy.MakeFeatureLayer_management(pumpstn, pump_layer, pws)
arcpy.MakeFeatureLayer_management(prv, prv_layer, pws)
arcpy.MakeFeatureLayer_management(tank, tank_layer, pws)
arcpy.MakeFeatureLayer_management(valve, valve_layer, pws)
arcpy.MakeFeatureLayer_management(wtp, wtp_layer, pws)
arcpy.MakeFeatureLayer_management(dbp, dbp_layer, pws)
arcpy.MakeFeatureLayer_management(dbp2, dbp2_layer, pws)
arcpy.MakeFeatureLayer_management(bacti, bacti_layer, pws)
arcpy.MakeFeatureLayer_management(sources, src_layer, pws)
arcpy.MakeFeatureLayer_management(assessment, ***_layer, ***_pws)
# Apply the symbology from the symbology layer to the input layers