I have been unable to programmatically add (and activate Elevation and Extrusion properties) a layer to the 3d section of a local Scene Using ArcPy.
I am able to programmatically set elevation and extrusion properties for layers in a scene, but I have not been able to programmatically add these layers to a 3d scene. Despite setting the elevation and extrusion properties, the layers do not display in 3D until I manually move them from the “2d” section to the “3d” section. Then to activate the elevation properties so they display appropriately I must open the layer properties dialog, go to the Elevation tab, open the expression dialog where I see my programmatically set expression and click OK. (without making any changes to the expression).
def execute(self, parameters, messages):
aprx = arcpy.mp.ArcGISProject("CURRENT")
local_scene = next((scene for scene in aprx.listMaps() if scene.name == "The3DSceneName" and scene.mapType == "SCENE"), None)
group_layer = local_scene.createGroupLayer("TheGroupName")
group_layer_cim = group_layer.getDefinition('V3')
group_layer_cim.layer3DProperties = arcpy.cim.CIM3DLayerProperties()
# Setting the layer3DProperties properties
group_layer_cim.layer3DProperties.castShadows = True
#... ect set layer3DProperties
# Push the updated CIM definition back to the group layer
group_layer.setDefinition(group_layer_cim)
#'partition_layer' is previously defined and configured
cim_definition = partition_layer.getDefinition('V3')
cim_definition.layer3DProperties = arcpy.cim.CIM3DLayerProperties()
cim_definition.layer3DProperties.applyAsElevationLayer = True
# Additional code for setting extrusion and elevation...
elevation_definition = arcpy.cim.CIMSymbolizers.CIMExpressionInfo()
elevation_definition.title = "Custom"
elevation_definition.expression = f"$feature.{field2_name} / {user_defined_number}"
elevation_definition.name = ""
elevation_definition.returnType = "Default"
cim_definition.featureElevationExpressionInfo = elevation_definition
partition_layer.setDefinition(cim_definition)
extrusion_expression = f"([{field1_name}] - [{field2_name}]) / {user_defined_number_meters}"
partition_layer.extrusion('BASE_HEIGHT', extrusion_expression)
local_scene.addLayerToGroup(group_layer, partition_layer, "BOTTOM")
Again, when I inspect the properties of the layer, the elevation and extrusion properties are set correctly, but it’s like they are not activated (especially in the case of elevation, as I have to click OK through the elevation dialogs without changing anything for it to take effect. )
- How can I ensure that the elevation and extrusion settings take effect programmatically without needing to open and close the properties dialog?
- Is there a specific property or method call I am missing that activates or refreshes these settings within a 3D scene?
- By setting the group layer’s 3d properties
group_layer_cim.layer3DProperties
in the CIM I am able to programmatically add all layers to the 3d section of the Scene, but the layers within the group are only rendered as 2d, despite having their extrusion properties set. How can I render all in the 3d Scene as 3d programmatically?
Any insights or suggestions on how to resolve these issues would be greatly appreciated!