Sunday 28 May 2017

python - Applying layer file not formating labels in ARCGIS 10


I'm applying layer files in ARCGIS 10 using the ApplySymbologyFromLayer_management command via a python script tool. The symbology part works fine but the lables are not formatting.


It is my understanding that applying a layer file should also format the lables as well. Has anyone else had this issue? Any ideas would be appreciated.


Here is the code I am using.





import arcpy, os
from arcpy import env

## Create parameters for modelbuilder user specified fields.
symbolize_layer = arcpy.GetParameterAsText (0)
symbol_lyrFile = arcpy.GetParameterAsText (1)


arcpy.AddMessage("**** Step 1 ****")
# apply symbology

arcpy.ApplySymbologyFromLayer_management (symbolize_layer, symbol_lyrFile)

arcpy.AddMessage("**** Step 2 ****")
# refresh the view
arcpy.RefreshActiveView()
arcpy.RefreshTOC()

arcpy.AddMessage("**** OK now were Done ****")

Answer



Unless this is a new feature in version 10.1, to my knowledge, until version 10, labels are not imported with layer symblology. There is even an idea on ArcGIS ideas with over 600 votes requesting this feature.



All is not lost as this can be easily done programatically with ArcObject. (not sure about python but I doubt it since python is more focused on geoprocessing) I posted the code on ArcGIS forums a while back.


I have since made it to an ArcGIS add-in and if there is enough interest i will add it to the resource center for public download.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...