I need place labels regardless of collisions with other layers. I use ArcPy and CIM. I need to place the label in the center of the polygon. At the same time, I need it not to change its position or disappear if it collides with another labels or feature. I try this code, but some labels are placed outside the polygons.
show_labels = m.listLayers("polygon23*")[0]
show_labels.showLabels = True
for lyr in m.listLayers("polygon23*"):
if lyr.supports("SHOWLABELS"):
if lyr.showLabels:
for lblClass in lyr.listLabelClasses():
lblClass.expression = ''' "<FNT size='6'>" + $feature.label + "</FNT>"'''
label_show = m.listLayers('polygon23*')[0]
l_cim = label_show.getDefinition('V2')
lc = l_cim.labelClasses[0]
lc.maplexLabelPlacementProperties.polygonPlacementMethod = 'StraightInPolygon'
lc.maplexLabelPlacementProperties.placeOnlyInsidePolygon = True
lc.CIMStandardLabelPlacementProperties = 'allowOverlappingLabels'