0

Is there a way to close the table without removing it from the Map? It feels like a such a simple process but I could not find a way to do so.

2 Answers 2

3

You can do it with some cheating:

name = "LINKS"
clone_name = name+"_"
def from_to(A,B):
    arcpy.MakeFeatureLayer_management(A, B)
    arcpy.management.ApplySymbologyFromLayer(B, A)
    arcpy.management.Delete(A)
from_to (name,clone_name)
from_to (clone_name,name)

here is another version of code that would work with table and layers.

def close_operation(X):
    def checkInputType(X):
        desc = arcpy.Describe(X)
        try:
            desc.shapeType
            return "LAYER"
        except:
            return "TABLE"
    
    result=checkInputType(X)
    
    if result == "TABLE":
        nameoflayer = X
        clone_name = X + "_clone"
        arcpy.management.MakeTableView(nameoflayer, clone_name)
        arcpy.management.Delete(nameoflayer)

        nameoflayer = clone_name
        clone_name = X
        arcpy.management.MakeTableView(nameoflayer, clone_name)
        arcpy.management.Delete(nameoflayer)
    
    elif result == "LAYER":
        nameoflayer = X
        clone_name = X + "_clone"
        arcpy.MakeFeatureLayer_management(nameoflayer, clone_name)
        arcpy.management.ApplySymbologyFromLayer(clone_name, nameoflayer)
        arcpy.management.Delete(nameoflayer)

        nameoflayer = clone_name
        clone_name = X
        arcpy.MakeFeatureLayer_management(nameoflayer, clone_name)
        arcpy.management.ApplySymbologyFromLayer(clone_name, nameoflayer)
        arcpy.management.Delete(nameoflayer)
    else:
        pass
0
1

From What is ArcPy?

ArcPy is a Python site package that provides a useful and productive way to perform geographic data analysis, data conversion, data management, and map automation with Python.

ArcPy does not have methods on its classes which would enable you to close any ArcGIS Pro views.

2
  • I see, i was wondering if there could b eany workaround of this by using python.
    – Fatih Enes
    May 31, 2022 at 7:00
  • 1
    I think the only Python access to the ArcGIS Pro GUI and its functions is ArcPy and it addresses far from all conceivable workflows. Closing views in the ArcGIS Pro GUI is something you may have more luck finding amongst ArcGIS Pro Tasks or by using the ArcGIS Pro SDK.
    – PolyGeo
    May 31, 2022 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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