Using applySymbolFromGallery doesn't work for 3D symbols

390
1
04-20-2023 03:09 PM
Labels (1)
TomášAndrš
New Contributor

Hello.

I am trying to change symbology of 3D layer using  arcpy. The final symbology, that I am trying to create is supposed to be Graduated colors with the Centered Cube symbol (e.g. picture bellow). I am using 'GraduatedColorsRenderer' and I am changing the symbol for each class (the symbol is same for each class). I am using  'applySymbolFromGallery' method to change the symbol. The issue is that if I fill in some 3D symbol in this method the symbology is not applied. There is no error and the symbology is changed in content pane and also in symbology pane, but the symbols in Scene are not displayed.  If I use any 2D symbol, everything works just fine. (If i set the 3D symbol in GUI it also works)

 

I have also tried to iterate through the list of symbols (using 'listSymbolsFromGallery' method) and it seems like the 3D symbols are there (that 's how I've found out the name of the desired symbol). I have also checked if the 3D symbology is added in the Add style table and it was. 

 

I would be grateful for any advice.

 

Code:

relpath = os.path.dirname(sys.argv[0])
p = arcpy.mp.ArcGISProject(relpath + 'path.aprx')
l = gen_map.listLayers()[4]
sym = l.symbology

breakValues = [0.3,0.6,0.9,1.4,2.,2.8,3.7,4.6]

sym.updateRenderer('GraduatedColorsRenderer')
if hasattr(sym, 'renderer'):
if sym.renderer.type == 'GraduatedColorsRenderer':
sym.renderer.classificationField = 'grid_code'
sym.renderer.breakCount = 8
sym.renderer.classBreaks[i].upperBound = breakValues[i]
for i in range (8):

#I am changing the symbology here
sym.renderer.classBreaks[i].symbol.applySymbolFromGallery('Centered Cube', 1)

if i == 0:
sym.renderer.classBreaks[i].label = "less than "+str(breakValues[i])
elif i == len(breakValues)-1:
sym.renderer.classBreaks[i].label = "more than "+str(breakValues[i-1]+0.01)
else:
sym.renderer.classBreaks[i].label = str(breakValues[i-1]+0.01)+" - "+ str(breakValues[i])

cr = p.listColorRamps('Yellow to Red')[0]
sym.renderer.colorRamp = cr

l.symbology = sym

 

Desired Outcome:

Problem.PNG

 

0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

The code examples "save" the result

Symbol—ArcGIS Pro | Documentation

they used "saveacopy", but try "save" since you aren't working from a toolbox it appears.


... sort of retired...
0 Kudos