This content has been marked as final. Show 7 replies
Thanks for that. But actually I just want to copy a layer within my map template itself, I do not want to copy any shapefiles or feature classes.
Any idea how to do this?
I dont think there is. You can copy a layer to disk using arcpy.mapping but not copy a layer in the TOC. Is that what you are doing?
Instead of copy, you can use arcpy.mapping's AddLayer function to add the same layer again.
It worked using your suggestion.
Unfortunately I can't get the symbology I want. Neither arcpy.ApplySymbologyFromLayer_management nor arcpy.mapping.UpdateLayer are working for me. The symbology remains however it came into my map.
Thanks for the reply!
Unfortunately rendering your data is difficult in python and I'm experiencing similar concerns. UpdateLayer seems to be the best approach but you will have to have to pre-create 'template' layers that you reference to do that, which depending on your application may obviate the whole point of writing code to do this. The ability to render from code seems to be one of those things that ESRI wants you to use ArcObjects for.
How are you referencing the layer you want to change symbology to?
If you are using arcpy.mapping's Layer function, try using arcpy.mapping's ListLayers function instead.
Thanks for the replies!
I have no idea what I did, but after several attempts of trial and error I eventually got it. Now to figure out how to order my layers properly
#newcontours for LGA in LGAlist: inContours = LGAtoContours[LGA] outContours = 'Contours 10m - ' + str(LGA) # arcpy.AddMessage(outContours) arcpy.MakeFeatureLayer_management(inContours,outContours) contourlayer = arcpy.mapping.Layer(outContours) arcpy.mapping.AddLayer(df, contourlayer, "Top") updateContoursLayer = arcpy.mapping.ListLayers(mxd,outContours, df) sourceContoursLayer = arcpy.mapping.Layer(r"U:\Layers\Contours 10m.lyr") arcpy.mapping.UpdateLayer(df, updateContoursLayer, sourceContoursLayer, True)