I've added a shapefile to an MXD and Edited the symbolization of it with ArcObjects. Now I'm trying to edit the labeling with ArcObjects. I've successfully been able to edit the default class in the IAnnotateLayerPropertiesCollection2 object. I've also successfully added two more label classes to that collection object.
The default class that I edited is displaying correctly, but the extra two Label Classes aren't displaying after the script is run. When I manually open the properties of the layer and open the properties for each label class that I added and choose OK or Apply, then they show up. So I know that they are being added properly, but how do I get them to display through the script?
I've tried MxDoc.UpdateContets(), MxDoc.ActiveView.Refresh(), arcpy.RefreshActiveView() and none of them work for this.
I'm using Python to handle the ArcObjects, but if you know how to do it in VB or C#, I can interpolate it. Thanks
def ApplyLabels_arcobjects(layersource, pFLayer, pStyleGallery, carto): # If there are no labels in the custom symbology object if not layersource.symbology.labels: return # Get Annotation Properties Collection geofeaturelayer = Snippets.CType(pFLayer, carto.IGeoFeatureLayer) pAnnoPropColl = geofeaturelayer.AnnotationProperties pAnnoPropColl2 = Snippets.CType(pAnnoPropColl, carto.IAnnotateLayerPropertiesCollection2) # Loop through each label in the custom symbology object i = 0 for labelsource in layersource.symbology.labels: print("This is label number {0}".format(i+1)) # TODO Remove, for debugging # Get the premade Label Style from the style file pStyleGallery.LoadStyle(labelsource.style_filename, labelsource.label_classname) gallerystyle = getLabelSymbol(labelsource, pStyleGallery, carto) pLabelStyle = Snippets.CType(gallerystyle, carto.ILabelStyle2) # If I can get a Annotation Property that is already there, great: if i
The default class that I edited is displaying correctly, but the extra two Label Classes aren't displaying after the script is run. When I manually open the properties of the layer and open the properties for each label class that I added and choose OK or Apply, then they show up. So I know that they are being added properly, but how do I get them to display through the script?
I've tried MxDoc.UpdateContets(), MxDoc.ActiveView.Refresh(), arcpy.RefreshActiveView() and none of them work for this.
I'm using Python to handle the ArcObjects, but if you know how to do it in VB or C#, I can interpolate it. Thanks
def ApplyLabels_arcobjects(layersource, pFLayer, pStyleGallery, carto): # If there are no labels in the custom symbology object if not layersource.symbology.labels: return # Get Annotation Properties Collection geofeaturelayer = Snippets.CType(pFLayer, carto.IGeoFeatureLayer) pAnnoPropColl = geofeaturelayer.AnnotationProperties pAnnoPropColl2 = Snippets.CType(pAnnoPropColl, carto.IAnnotateLayerPropertiesCollection2) # Loop through each label in the custom symbology object i = 0 for labelsource in layersource.symbology.labels: print("This is label number {0}".format(i+1)) # TODO Remove, for debugging # Get the premade Label Style from the style file pStyleGallery.LoadStyle(labelsource.style_filename, labelsource.label_classname) gallerystyle = getLabelSymbol(labelsource, pStyleGallery, carto) pLabelStyle = Snippets.CType(gallerystyle, carto.ILabelStyle2) # If I can get a Annotation Property that is already there, great: if i