frankv3

applying label expressions, a clunky work around

Discussion created by frankv3 on Oct 11, 2011
Latest reply on Dec 21, 2011 by mbd7878
is there a better way to apply a label exprssion to a layer in arcmap besides the workaround posted below? there is a layer in arcmap that needs to be symbolized and labeled in the same manner as a layer file and doing an updateLayer TRUE won't do it, so the updateLayer is used with FALSE
then the source and name of the layer gets reset
the layer file was created from a template of the edit feature class in the MXD so that all fields and spatial attributes match

#### Description: Changes the symbology and labels fot the footprint layer

## Import standard modules
import sys, os

## Set the necessary product code
import arcinfo

## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env

## Get the selection layer
SetLayer = arcpy.GetParameterAsText(0)


## Sets the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")

## Sets the Dataframe
DF = arcpy.mapping.ListDataFrames(IMXD, "Layers")[0]

## Set a Layer
ILayer = arcpy.mapping.ListLayers(IMXD, SetLayer, DF)[0]


SymbolLayer = arcpy.mapping.Layer(r"C:\WorkSpace\Bldg_Footprints\HollowFootprints.lyr")

KeepName = ILayer.name
KeepDataset = ILayer.datasetName
KeepSource = ILayer.workspacePath

arcpy.mapping.UpdateLayer(DF, ILayer, SymbolLayer, False)

ILayer = arcpy.mapping.ListLayers(IMXD, "Footprints_Layer", DF)[0]

ILayer.replaceDataSource(KeepSource, "FILEGDB_WORKSPACE", KeepDataset)
ILayer.name = KeepName


arcpy.RefreshTOC()
arcpy.RefreshActiveView()
del IMXD, ILayer

Outcomes