I am creating a tool to automate a data standardization process. Part of this process is saving the feature class (variable "filename") as a layer file, projecting it into another coordinate system (variable "wmsde"), and then saving that one as a copy as well. I want the user to symbolize the feature class and then run the script/tool which would take the symbology they designated and apply it to the layers created. I realize it is incredibly easy to right click the layer and click Save As Layer, but I want as much as possible of this process to be automated. I am trying to use representations but a layer with the symbology needs to exist before the tool is used, which would be fine if I could find a way to save the symbology to a layer file. I have tried arcpy's Make Feature Layer and Save to Layer File (Management) to create a layer from the data but it does not save the symbology. I read on an answer to another question on here that this may be normal. I think the representation tool is working because the second layer's symbology is the same color as the first's (and they are usually assigned random colors). However the Drop Representation tool is failing and I'm not sure why. I get error 000252. Here is the (edited) code I have for it. Other tools that create symbology for a layer such as Apply Symbology From Layer (Data Management) also requires a symbolized layer.
Does anybody have any ideas as to what I can do to save the user's symbology designations or even another route aside from representations?
arcpy.env.workspace = r'C:\Data\Data.gdb' worksde = r"C:\Users\me\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\DatabaseName.sde" lyrFolder = r"C:\Layers" ws = arcpy.env.workspace filename = r"PlayAndTest" sdefilename = r"PlayAndTest" infile = os.path.join(ws, filename) sdefile = os.path.join(worksde, sdefilename) # Create a DD layer file print "Creating DD LYR" DDlyr = os.path.join(lyrFolder, filename + "_DD.lyr") arcpy.SaveToLayerFile_management(filename, DDlyr) # Reproject as WM print "Projecting to WM" wmsde = sdefile + "_WM" prjfile = os.path.join(arcpy.GetInstallInfo()["InstallDir"], "Coordinate Systems\Projected Coordinate Systems\World\WGS 1984 Web Mercator (auxiliary sphere).prj") spatialRef = arcpy.SpatialReference(prjfile) arcpy.Project_management(infile, wmsde, spatialRef) # Make the WM Layer WMlyr = os.path.join(lyrFolder, sdefilename + "_WM.lyr") arcpy.SaveToLayerFile_management(sdefilename, WMlyr) arcpy.ApplySymbologyFromLayer_management(WMlyr,DDlyr)