<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unable to programmatically add (and activate Elevation and Extrusion) 3d layer to local Scene Using ArcPy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/unable-to-programmatically-add-and-activate/m-p/1415158#M70460</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;your extrusion expression- does it return number ?, can you check first based on one field height value ?&lt;/P&gt;&lt;P&gt;Personally, i have not completely managed to do it in python script, but in notebook opened in arcgis pro --&amp;gt; Yes.&lt;/P&gt;&lt;P&gt;sth lik that:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;p = arcpy.mp.ArcGISProject("CURRENT")
my_scene = p.listMaps("Scene")[0]
print(my_scene.name)
# when it adds THE file but it SHOWS ERROR. what does it mean ? i dont know
try:
    my_scene.addDataFromPath(FC_IN_2D)
except:
    print('skipp error, just continue')
    pass

# get the right layer
lyr = my_scene.listLayers(FC_IN_2D)[0]

# extrue data where H_EXTRUSION is the field name , containing float number
# notice the single quotes also....
lyr.extrusion('MIN_HEIGHT','[H_EXTRUSION]')
# convert to 3D layer MultiPatch, notice that I am applying both
# projeciton horizontal and projection vertical
with arcpy.EnvManager(outputCoordinateSystem='GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],VERTCS["NGF_IGN69",VDATUM["Nivellement_General_de_la_France_IGN69"],PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]]'):
        arcpy.ddd.Layer3DToFeatureClass(
            in_feature_layer=fc_in,
            out_feature_class=fc_out,
            group_field=None,
            disable_materials="DISABLE_COLORS_AND_TEXTURES"
        )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Thu, 25 Apr 2024 04:45:18 GMT</pubDate>
    <dc:creator>Tomasz_Tarchalski</dc:creator>
    <dc:date>2024-04-25T04:45:18Z</dc:date>
    <item>
      <title>Unable to programmatically add (and activate Elevation and Extrusion) 3d layer to local Scene Using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/unable-to-programmatically-add-and-activate/m-p/1414890#M70452</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;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. )&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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")&lt;/LI-CODE&gt;&lt;P&gt;- How can I ensure that the elevation and extrusion settings take effect programmatically without needing to open and close the properties dialog?&lt;BR /&gt;- Is there a specific property or method call I am missing that activates or refreshes these settings within a 3D scene?&lt;BR /&gt;- 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*?&lt;BR /&gt;Any insights or suggestions on how to resolve these issues would be greatly appreciated!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 17:51:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unable-to-programmatically-add-and-activate/m-p/1414890#M70452</guid>
      <dc:creator>Alex_Devoid</dc:creator>
      <dc:date>2024-04-24T17:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to programmatically add (and activate Elevation and Extrusion) 3d layer to local Scene Using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/unable-to-programmatically-add-and-activate/m-p/1415158#M70460</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;your extrusion expression- does it return number ?, can you check first based on one field height value ?&lt;/P&gt;&lt;P&gt;Personally, i have not completely managed to do it in python script, but in notebook opened in arcgis pro --&amp;gt; Yes.&lt;/P&gt;&lt;P&gt;sth lik that:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;p = arcpy.mp.ArcGISProject("CURRENT")
my_scene = p.listMaps("Scene")[0]
print(my_scene.name)
# when it adds THE file but it SHOWS ERROR. what does it mean ? i dont know
try:
    my_scene.addDataFromPath(FC_IN_2D)
except:
    print('skipp error, just continue')
    pass

# get the right layer
lyr = my_scene.listLayers(FC_IN_2D)[0]

# extrue data where H_EXTRUSION is the field name , containing float number
# notice the single quotes also....
lyr.extrusion('MIN_HEIGHT','[H_EXTRUSION]')
# convert to 3D layer MultiPatch, notice that I am applying both
# projeciton horizontal and projection vertical
with arcpy.EnvManager(outputCoordinateSystem='GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],VERTCS["NGF_IGN69",VDATUM["Nivellement_General_de_la_France_IGN69"],PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]]'):
        arcpy.ddd.Layer3DToFeatureClass(
            in_feature_layer=fc_in,
            out_feature_class=fc_out,
            group_field=None,
            disable_materials="DISABLE_COLORS_AND_TEXTURES"
        )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 25 Apr 2024 04:45:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unable-to-programmatically-add-and-activate/m-p/1415158#M70460</guid>
      <dc:creator>Tomasz_Tarchalski</dc:creator>
      <dc:date>2024-04-25T04:45:18Z</dc:date>
    </item>
  </channel>
</rss>

