Greetings,
I've been wrestling with this for most of the day and am flummoxed!
I am going through a "For Loop" adding 5 (ultimately will be ~150 after testing) feature classes in a Feature Dataset (named "GroundwaterBasins") in a geodatabase, and trying to change the symbology for each dataset based upon a layer file that I have already saved ("PORSymbologyLayer"). I have inserted "arcpy.RefreshTOC" and "arcpy.RefreshActiveView". I've even broken it down into two "For Loops (one for adding the
feature class, and one for changing the symbology). I've even tried "ApplySymbologyFromLayer_mangement" which also doesn't change the symbology.
Can anyone see what I'm doing wrong?
Thanks,
Jonathan Mulder
Engineering Geologist
California Department of Water Resources
I've been wrestling with this for most of the day and am flummoxed!
I am going through a "For Loop" adding 5 (ultimately will be ~150 after testing) feature classes in a Feature Dataset (named "GroundwaterBasins") in a geodatabase, and trying to change the symbology for each dataset based upon a layer file that I have already saved ("PORSymbologyLayer"). I have inserted "arcpy.RefreshTOC" and "arcpy.RefreshActiveView". I've even broken it down into two "For Loops (one for adding the
feature class, and one for changing the symbology). I've even tried "ApplySymbologyFromLayer_mangement" which also doesn't change the symbology.
Can anyone see what I'm doing wrong?
Thanks,
Jonathan Mulder
Engineering Geologist
California Department of Water Resources
Code:
##Reference the Current map document.
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
arcpy.env.workspace = os.path.join(GeoDatabaseNameAndLocation,"GroundwaterBasins")
CurrentWorkspacePath = os.path.join(GeoDatabaseNameAndLocation,"GroundwaterBasins")
PORSymbologyLayer = arcpy.mapping.Layer(os.path.join(GeoDatabaseLocation,"GIS","PeriodOfRecord.lyr"))
arcpy.AddMessage(PORSymbologyLayer)
BasinList = arcpy.ListFeatureClasses("*")
arcpy.AddMessage(BasinList)
for Basin in BasinList:
BasinFeatureClass = arcpy.mapping.Layer(Basin)
arcpy.AddMessage(BasinFeatureClass)
arcpy.mapping.AddLayer(df, BasinFeatureClass, "TOP")
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
for Basin in BasinList:
BasinFeatureClass = arcpy.mapping.Layer(Basin)
## arcpy.ApplySymbologyFromLayer_management (BasinFeatureClass, PORSymbologyLayer)
arcpy.mapping.UpdateLayer(df,BasinFeatureClass,PORSymbologyLayer)
arcpy.RefreshTOC()
arcpy.RefreshActiveView()