The code returns me an error Runtime error <type 'exceptions.IOError'>: UNKNOWNlayerName=r'M:\UTILISATEURS\Pierre\SERAIL\MISE_A_JOUR.gdb\TEST'I work from a class annotation. I don�??t want to change the data source, but simply change the label expression or display rather like my data is a class annotation.
layerName=r'M:\UTILISATEURS\Pierre\SERAIL\MISE_A_JOUR.gdb\TEST'
layerName='TEST'
Function FindLabel ( [TextString] ) Label = replace([TextString], "Ec.", "Ecole") Label = replace(Label, "Egl.", "Eglise") Label = replace(Label, "Text to search for", "Text to replace it with") 'etc FindLabel = Label End Function
Hello,I work on a table of about 1200 objects. I wonder if it is possible to write a standalone Python script to replace one word with another without changing the values �??�??of my table. As building label expressions.Exemple:I would like to replace Ec. for Ecoleother exempleI would like to replace Egl. for EgliseThanks for your help
import arcpy mxdPath = r"C:\Project\_LearnPython\Ohio2.mxd" layerName = "OH30" fldName = "yourLabelFieldName" # in case of shapefile of personal geodatabase labelExpression = 'replace(replace([{0}],"Ec.","Ecole"),"Egl.","Eglise")'.format(fldName) # in case of file geodatabase # labelExpression = 'replace(replace("{0}","Ec.","Ecole"),"Egl.","Eglise")'.format(fldName) mxd = arcpy.mapping.MapDocument(mxdPath) for lyr in arcpy.mapping.ListLayers(mxd): if lyr.name == layerName: if lyr.supports("LABELCLASSES"): lyr.showLabels == True for lblClass in lyr.labelClasses: lblClass.expression = labelExpression mxd.save() del mxd
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.