p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Trail Routes')[0]
lyr = m.listLayers('Loops')[0]
# Return the layer's CIM definition
cim_lyr = lyr.getDefinition('V2')
# Modify the color, width and dash template for the SolidStroke layer
symLvl1 = cim_lyr.Renderer.Symbol.Symbol.SymbolLayers[0]
symLvl1.Color.Values = [250, 250, 40, 50]
symLvl1.Width = 8
ef1 = symLvl1.Effects[0] #Note, deeper indentation
ef1.DashTemplate = [20, 30]
# Modify the color/transparency for the SolidFill layer
symLvl2 = cim_lyr.Renderer.Symbol.Symbol.SymbolLayers[1]
symLvl2.Color.Values = [140, 70, 20, 20]
# Push the changes back to the layer object
lyr.setDefinition(cim_lyr)
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Trail Routes')[0]
lyr = m.listLayers('Loops')[0]
# Return the layer's CIM definition
cim_lyr = lyr.getDefinition('V2')
# Modify the color, width and dash template for the SolidStroke layer
symLvl1 = cim_lyr.renderer.symbol.symbol.symbolLayers[0]
symLvl1.color.values = [250, 250, 40, 50]
symLvl1.width = 8
symLvl1.effects = [arcpy.cim.CIMGeometricEffectDashes()]
ef1 = symLvl1.effects[0] #Note, deeper indentation
ef1.dashTemplate = [20, 30]
# Modify the color/transparency for the SolidFill layer
symLvl2 = cim_lyr.renderer.symbol.symbol.symbolLayers[1]
symLvl2.color.values = [140, 70, 20, 20]
# Push the changes back to the layer object
lyr.setDefinition(cim_lyr)
Thank you for reporting this! You are correct; late in 2.4 development we changed the CamelBack format of the object members to be consistent with the managed API. I failed to update example 3 and you caught it. The script was corrected and will appear in the next help publication.
The missing line that you added is NOT required if the symbol already has a dashed effect. What the line did essentially was generate the effect. This is something you need to be very careful about doing. The Developer Summit plenary video does show the line you added. That particular example is a simple use case but due to the complexity of object creation where new objects have dependencies on addition objects, it is easy to create objects that may fail in the application.
The arcpy.cim module is necessary for CIM support but we intentionally did not document it. We hope that with future builds we will provide helper functions that will make it easier and more reliable to create new objects.
Thanks again,
Jeff