ApplySymbologyFromLayer2

540
1
05-12-2012 09:38 AM
RuiPedroso
New Contributor
Hi, here the whole code from a beginner. Nothing happens when I open ArcMap. The symbology from the input layer did not changed.
Thanks!

import arcpy, sys, traceback, datetime
from arcpy.mapping import *   

CUR_DATE = datetime.date.today().strftime('%m.%d.%Y')

try:


    datapath = 'C:\\GIS\\Vietnam\\'
    mappath = datapath + 'Maps\\'    # output for PDFs
    mxd = MapDocument(datapath + 'Floodplain.mxd')
    #Apply Symbology
    #Set layer to apply symbology
    inputLayer = "commune_zone.lyr"

    #Set layer that output symbology will be based on
    symbologyLayer = "commune_zone_Layer1.lyr"

    #Apply the symbology from the symbology layer to the input layer
    arcpy.ApplySymbologyFromLayer_management(inputLayer, symbologyLayer)

except:
    # http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000q000000
    
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n     " +        str(sys.exc_type) + ": " + str(sys.exc_value) + "\n"
    msgs = "ARCPY ERRORS:\n" + arcpy.GetMessages(2) + "\n"

    arcpy.AddError(msgs)
    arcpy.AddError(pymsg)

    print msgs
    print pymsg
    
    arcpy.AddMessage(arcpy.GetMessages(1))
    print arcpy.GetMessages(1)
Tags (2)
0 Kudos
1 Reply
JeffBarrette
Esri Regular Contributor
I don't see how layer variables know the path to the layer files.  Try setting your workspace.

Jeff
0 Kudos