Hello everyone,
I am trying to change the visibility of some layers via an ArcPy script.
It seems like the property visible of the layer object is the property to go. I found multiple articles on how it works in ArcMap, for example this one: https://support.esri.com/en-us/knowledge-base/how-to-toggle-the-visibility-of-a-specific-sublayer-of-000013577.
Within ArcGIS Pro 3+ and with ArcPy 3+, I am able to set the property to either True or False for a layer without problems.
However, it seems like you actually need to somehow refresh the view in order to have some visual effect on the map rendering and also in the Contents pane.
For older versions of ArcPy/with ArcMap, it seems like calling the following two methods was sufficient:
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
However, when I call these methods now on arcpy, I receive an error: "AttributeError: module 'arcpy' has not attribute 'RefreshTOC'". Hence, it seems like these two methods do no longer exist in ArcPy 3+.
Does anybody have an idea how I can change the visibility of a layer such that it actually also is displayed accordingly in the map rendering and in the Contents pane?