I would like to achieve the following functionality through arcpy:
- Querying an existing baselayer on time and create a new layer
- Apply symbology from an existing layer and add the new layer to the current session's data frame on top of the basemap
Have given my code below which gives me an
Assertion Error when I try to add the layer returned from
arcpy.MakeFeature. I am missing something trying to impact the current session. If I run the
arcpy.MakeFeatureLayer_management command on the python console it works fine. But I am not able to get it work through the scripts in the toolbox. Please advice me on this.
import arcpy arcpy.env.overwriteOutput = True mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "*") arcpy.MakeFeatureLayer_management ("base_layer", "new_layer_1","DATE_TIME" = TO_DATE('13-JUL-2010 12:40:00','DD-MON-YYYY HH24:MI:SS')) arcpy.ApplySymbologyFromLayer_management("out_time",r"C:\WIP\Shape files\KARTHIK.TEST_TABLE.lyr") arcpy.mapping.AddLayer(df,out_time) arcpy.RefreshActiveView()