Select to view content in your preferred language

How to stop adding layer to project map

653
2
08-06-2022 04:54 AM
RajeshPatnaik
Emerging Contributor

Hi,

 When I iterate through many feature classes of a GDB to calculate their geometry, all these feature classes are being added to current project map as layers.
I use the following script to calculate geometry.

arcpy.management.CalculateGeometryAttributes(in_features=fc, geometry_property=[["Length_ft", "LENGTH_GEODESIC"]],length_unit='FEET_US')


How to force the processing tool NOT to add the layers to map?

2 Replies
DanPatterson
MVP Esteemed Contributor

on a general basis

addtomap.png

If running from notebooks or the python window, you can control it from environment settings see

env—ArcGIS Pro | Documentation

EnvManager—ArcGIS Pro | Documentation


... sort of retired...
JohannesLindner
MVP Frequent Contributor
current_setting = arcpy.env.addOutputsToMap
arcpy.env.addOutputsToMap = False

# your code

arcpy.env.addOutputsToMap = current_setting

Have a great day!
Johannes