pedroso1971

ApplySymbologyFromLayer2

Discussion created by pedroso1971 on May 12, 2012
Latest reply on May 14, 2012 by jbarrette-esristaff
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)

Outcomes