0

I'm trying to apply a Base Height extrusion that's 10 feet in height to all layers in my ArcGIS Pro map document using a python script. Per ESRI's documentation on extrusion, the syntax should be extrusion ({extrusion_type}, {expression}) .

Below is the code that I'm trying to use. It's not that graceful as I'm still trying to learn python:

import arcpy

# Variables to form defintion query
field = 'SUBCODE'
value = "(1152,1153,1154,1155)"

# concatenate query syntax
queryStr = str(field) + '"IN"' + str(value)

# Specify the aprx project (CURRENT), dataframe (Layers)
p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps("Map_3D")[0]

# Apply defintion query to specified layer group
for lyr in m.listLayers("CONDO*"):
if lyr.supports("DEFINITIONQUERY"):
   lyr.definitionQuery = queryStr

# Make copy of selected features
arcpy.MakeFeatureLayer_management("CONDO_1ST","CONDO_1ST_LEVEL")
arcpy.MakeFeatureLayer_management("CONDO_2ND","CONDO_2ND_LEVEL")
arcpy.MakeFeatureLayer_management("CONDO_3RD","CONDO_3RD_LEVEL")
arcpy.MakeFeatureLayer_management("CONDO_4TH","CONDO_4TH_LEVEL")
arcpy.MakeFeatureLayer_management("CONDO_5TH","CONDO_5TH_LEVEL")

# Layer 3D To FeatureClass
arcpy.Layer3DToFeatureClass_3d("CONDO_1ST_LEVEL",'CONDO_1ST_LEVEL_3D')
arcpy.Layer3DToFeatureClass_3d("CONDO_2ND_LEVEL",'CONDO_2ND_LEVEL_3D')
arcpy.Layer3DToFeatureClass_3d("CONDO_3RD_LEVEL",'CONDO_3RD_LEVEL_3D')
arcpy.Layer3DToFeatureClass_3d("CONDO_4TH_LEVEL",'CONDO_4TH_LEVEL_3D')
arcpy.Layer3DToFeatureClass_3d("CONDO_5TH_LEVEL",'CONDO_5TH_LEVEL_3D')

# Apply extrusion
for lyr in m.listLayers("CONDO*"):
if lyr.supports("EXTRUSION"):
   lyr.extrusion('BASE_HEIGHT',10)

I'm not receiving any error when I run the script nor is it making updates to the layers.

  • Can you expand your code snippet so we can see more of what you've defined above for lyr in m.listLayers()? What/where is m? – Midavalo Nov 14 '17 at 0:01
  • Thanks Midavalo for your reply. I've made edits to my original question so that you can see the entire code. – pac_co Nov 14 '17 at 14:12
  • I figured it out - I forgot to apply the Geoprocessing tool "Layer 3D To Feature Class". Thanks again for reaching out to help Midavalo! – pac_co Nov 14 '17 at 14:37
0

I needed to use the Geoprocessing tool "Layer 3D To Feature Class" in order to have the extrusion work. Here's a copy of the syntax I used:

 arcpy.Layer3DToFeatureClass_3d(input, output)
  • updated my code to show where I applied the "Layer 3D To Feature Class" – pac_co Nov 14 '17 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.