Hello there,
I am asking if anyone knows the correct syntax for arcpy to call on and bring in any feature layer open in a local scene into a Jupyer notebook to run through a geoprocessing tool. I have dozens of layers open in the scene and need to use the Create3DObjectSceneLayerPackage tool, and I have the rest of the code to automate the process, but I need a way to grab them. And I need them all open in the scene and not stored in a geodatabase because they are 3D multipatches with vertical exaggeration and symbology that are not captured when they are not open in a scene.
I cannot find anyone who knows the proper way to do this, but surely there must be a way!?
Would love an Esri rep's input especially!
Thank you!
Solved! Go to Solution.
Yes, in the automation case you'll want to work with arcpy.mp to determine what layers you're using and passing to the downstream functions. Here's an example which shows some basic information about scene layers in the project:
project = arcpy.mp.ArcGISProject("CURRENT")
for project_map in project.listMaps():
map_type = project_map.mapType
print(f"Found {project_map.name} of type {map_type}")
if map_type == 'SCENE':
scene = project_map
print(f"Working with scene {scene.name}")
for layer in scene.listLayers():
fl_str = 'is' if layer.isFeatureLayer else 'is not'
print(f" found {layer.name}, {fl_str} a feature layer")
Once you've used code like that to identify the layers you'd like to work with, you can then feed them into the GP tools you'd like to call.
Cheers, Shaun
If you've already run the package tool once, you can visit the history pane of the application, and select "Copy Python command" as described in the Geoprocessing history documentation. That will give you a code snippet that you should be able to paste into your existing Notebook. If you're using Pro 3.1, you can also open your notebook directly in Pro, and drag and drop the layer names into cells, and that will similarly work against the active map.
If you need to work with the scenes from a standalone Notebook or in a context where Pro isn't directly involved, you'd want to start with arcpy.mp to first load the project, find your local scene, then work against the layers present in that scene, once you have the layer paths, you can use them as geoprocessing inputs as normal.
Cheers, Shaun
Hi Shaun,
I do really like the new drag and drop code history in 3.1, it's been a big help.
And I have been using my Notebook in ArcPro with a Local scene open and manually inputting each layer from my scene into my code to run. This works fine, but I have DOZENS of layers to run through a single geoprocessing tool, is there a way to have it *automatically* call in each layer from the Scene, like you would for calling in everything from a geodatabase?
My issue is automation, I just want the layers open in the scene.
Thanks!
Yes, in the automation case you'll want to work with arcpy.mp to determine what layers you're using and passing to the downstream functions. Here's an example which shows some basic information about scene layers in the project:
project = arcpy.mp.ArcGISProject("CURRENT")
for project_map in project.listMaps():
map_type = project_map.mapType
print(f"Found {project_map.name} of type {map_type}")
if map_type == 'SCENE':
scene = project_map
print(f"Working with scene {scene.name}")
for layer in scene.listLayers():
fl_str = 'is' if layer.isFeatureLayer else 'is not'
print(f" found {layer.name}, {fl_str} a feature layer")
Once you've used code like that to identify the layers you'd like to work with, you can then feed them into the GP tools you'd like to call.
Cheers, Shaun