I am creating a python code to iterate through a folder of shapefiles of contour s data load it and then publish it. as part if the script i am trying to get all the files to have the same line color so when it is published it looks consistent. my code loads the data but it not applying the same color to all the layers. How would i accomplish this ?
my code is:
import arcpy
import os
# Define the folder containing the files
q=1
folder_path = r"E:\Macon_Bibb_County_Contour2024\Contour 5 ft"
output = f"E:\Macon_Bibb_County_Contour2024\outputs\ 5ft package{q}"
tag ="contour, contour 5 ft, elevation, mwa"
summ = "5 ft vector tile package from macon bidd lidar data flown 2024"
lower=380000
upper=410000
# Define the map and project
project = arcpy.mp.ArcGISProject("CURRENT") # Use "CURRENT" for the active ArcGIS Pro project
map = project.listMaps()[0] # Get the first map in the project (adjust if needed)
for dirpath, dirnames, filenames in os.walk(folder_path):
try:
for f in filenames:
i = f[:-4]
if i.isdigit() and lower <= int(i) < upper:
if f.endswith(".shp"):
full_path =(str(dirpath) +"\\"+f)
#print(full_path)
l = map.addDataFromPath(full_path)
l.symbology.renderer.symbol.Color = "#824924" #set line color
#l.append(full_path)
except arcpy.ExecuteError:
# Handle geoprocessing errors
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs) # Return error messages for script tools
print(msgs) # Print error messages
continue
Arc Pro: 3.5.2