Add option to draw outlines; add outlines to fill symbols
This commit is contained in:
parent
2107947c03
commit
dee854e5c1
1 changed files with 80 additions and 3 deletions
|
@ -169,6 +169,18 @@ class FeatureRenderer:
|
|||
|
||||
heading_field.parameterDependencies = [table_param.name]
|
||||
|
||||
# Define Boolean parameter
|
||||
draw_outlines = arcpy.Parameter(
|
||||
displayName="Draw outlines",
|
||||
name="draw_outlines",
|
||||
datatype="GPBoolean",
|
||||
parameterType="Required",
|
||||
direction="Input",
|
||||
)
|
||||
|
||||
# Default value
|
||||
draw_outlines.value = True
|
||||
|
||||
# Return parameter definitions as a list
|
||||
return [
|
||||
style_files,
|
||||
|
@ -182,6 +194,7 @@ class FeatureRenderer:
|
|||
label_delimiter,
|
||||
label_field_2,
|
||||
heading_field,
|
||||
draw_outlines,
|
||||
]
|
||||
|
||||
def isLicensed(self):
|
||||
|
@ -209,6 +222,7 @@ class FeatureRenderer:
|
|||
label_delimieter = parameters[8].valueAsText
|
||||
label_field_2 = parameters[9].valueAsText
|
||||
heading_field = parameters[10].valueAsText
|
||||
draw_outlines = parameters[11].value
|
||||
|
||||
# Retrieve currently active map
|
||||
active_map = project.activeMap
|
||||
|
@ -377,6 +391,40 @@ class FeatureRenderer:
|
|||
# Retrieve CIM to add colors
|
||||
cim_lyr = layer.getDefinition("V3")
|
||||
|
||||
# Retrieve stroke symbol properties
|
||||
stroke_symbol_props = {"color": {}, "width": 0}
|
||||
if draw_outlines:
|
||||
for group in cim_lyr.renderer.groups:
|
||||
for unique_value_class in group.classes:
|
||||
for (
|
||||
symbol_layer
|
||||
) in unique_value_class.symbol.symbol.symbolLayers:
|
||||
if isinstance(
|
||||
symbol_layer,
|
||||
arcpy.cim.CIMSymbols.CIMSolidStroke,
|
||||
):
|
||||
stroke_symbol_props["color"] = (
|
||||
symbol_layer.color
|
||||
)
|
||||
stroke_symbol_props["width"] = (
|
||||
symbol_layer.width
|
||||
)
|
||||
break
|
||||
|
||||
if stroke_symbol_props["color"]:
|
||||
break
|
||||
|
||||
# Set default stroke width and color if unset
|
||||
if draw_outlines and stroke_symbol_props["width"] == 0:
|
||||
stroke_symbol_props["width"] = 0.7
|
||||
|
||||
if not stroke_symbol_props["color"]:
|
||||
color = arcpy.cim.CreateCIMObjectFromClassName(
|
||||
"CIMCMYKColor", "V3"
|
||||
)
|
||||
color.values = [40, 40, 40, 10, 100]
|
||||
stroke_symbol_props["color"] = color
|
||||
|
||||
for group in cim_lyr.renderer.groups:
|
||||
for unique_value_class in group.classes:
|
||||
|
||||
|
@ -418,6 +466,17 @@ class FeatureRenderer:
|
|||
update_color(symbol_layer, color_value)
|
||||
has_color = True
|
||||
|
||||
if isinstance(
|
||||
symbol_layer,
|
||||
arcpy.cim.CIMSymbols.CIMSolidStroke,
|
||||
):
|
||||
symbol_layer.width = (
|
||||
stroke_symbol_props["width"]
|
||||
)
|
||||
symbol_layer.color = (
|
||||
stroke_symbol_props["color"]
|
||||
)
|
||||
|
||||
elif layer_shape_type == "Polyline":
|
||||
if isinstance(
|
||||
symbol_layer,
|
||||
|
@ -433,23 +492,41 @@ class FeatureRenderer:
|
|||
update_color(symbol_layer, color_value)
|
||||
has_color = True
|
||||
|
||||
# Draw symbol background colors
|
||||
if not has_color and color_value:
|
||||
if layer_shape_type == "Polygon":
|
||||
# Create CIMSolidFill
|
||||
# Add fill and stroke symbol layers
|
||||
fill_symbol = arcpy.cim.CIMSolidFill()
|
||||
update_color(fill_symbol, color_value)
|
||||
|
||||
unique_value_class.symbol.symbol.symbolLayers.append(
|
||||
fill_symbol
|
||||
)
|
||||
|
||||
# Add stroke symbol layer
|
||||
if (
|
||||
draw_outlines
|
||||
and stroke_symbol_props["color"]
|
||||
):
|
||||
stroke_symbol = arcpy.cim.CIMSolidStroke()
|
||||
stroke_symbol.color = stroke_symbol_props[
|
||||
"color"
|
||||
]
|
||||
stroke_symbol.width = stroke_symbol_props[
|
||||
"width"
|
||||
]
|
||||
unique_value_class.symbol.symbol.symbolLayers.append(
|
||||
stroke_symbol
|
||||
)
|
||||
elif layer_shape_type == "Polyline":
|
||||
# Create CIMSolidStroke
|
||||
# Add stroke symbol layer
|
||||
stroke_symbol = arcpy.cim.CIMSolidStroke()
|
||||
update_color(stroke_symbol, color_value)
|
||||
unique_value_class.symbol.symbol.symbolLayers.append(
|
||||
stroke_symbol
|
||||
)
|
||||
elif layer_shape_type == "Point":
|
||||
# Create CIMMarker
|
||||
# Add marker symbol layer
|
||||
marker_symbol = arcpy.cim.CIMMarker()
|
||||
update_color(marker_symbol, color_value)
|
||||
unique_value_class.symbol.symbol.symbolLayers.append(
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue