Adjusting line width?

376
1
Jump to solution
11-09-2023 10:40 AM
Labels (3)
Davec43
Occasional Contributor

I have a portion of a script that changes the symbology of everything that isn't a point into uniquevalues using uniquevaluesrenderer. The part I'm having a hard time with is changing the line width to 2.

 

#isolate the symbology of the selected layer
sym = lyr.symbology #set the symbology as unique values
sym.updateRenderer('UniqueValueRenderer')
#specify the desired fields for the symbolizing
sym.renderer.fields = ['insert_attribute']
#select a colour ramp
colorRamp = p.listColorRamps("Voxel Tracks")[0]
#set the colour ramp
sym.renderer.colorRamp = colorRamp
#update the layer symbology
lyr.symbology = sym
symbol = lyr.symbology
0 Kudos
1 Solution

Accepted Solutions
Davec43
Occasional Contributor
## get the definition, like JSON. 
cim_lyr = lyr.getDefinition('V2')
## access the classes for the grouped symbology
group_classes = cim_lyr.renderer.groups[0].classes
## for each symbology class
for group_class in group_classes:
## access the symbology
symb = group_class.symbol.symbol.symbolLayers[0]
## set the width to whatever number you want here
symb.width = 2
## update the definition
lyr.setDefinition(cim_lyr)

View solution in original post

0 Kudos
1 Reply
Davec43
Occasional Contributor
## get the definition, like JSON. 
cim_lyr = lyr.getDefinition('V2')
## access the classes for the grouped symbology
group_classes = cim_lyr.renderer.groups[0].classes
## for each symbology class
for group_class in group_classes:
## access the symbology
symb = group_class.symbol.symbol.symbolLayers[0]
## set the width to whatever number you want here
symb.width = 2
## update the definition
lyr.setDefinition(cim_lyr)
0 Kudos