<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Cells succesfully running in Notebook but actions not visible in the ArcGIS Pro Layout in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/cells-succesfully-running-in-notebook-but-actions/m-p/1179381#M64694</link>
    <description>&lt;P&gt;Hmmm... This code works for me. No matter if the layout is opened or not, no matter the element (eg north arrow works too), and no matter whether I execute in a notebook or in the Python Window.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lyt = arcpy.mp.ArcGISProject("current").listLayouts()[0]
print(f"Layout name: {lyt.name}")

e = lyt.listElements(wildcard="Table Frame")[0]
print(f"Element name: {e.name}")

print(f"{e.name} is visible: {e.visible}")
e.visible = not e.visible
print(f"{e.name} is visible: {e.visible}")

cim = lyt.getDefinition("V2")
print(f"CIM: {cim}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Element name: Table Frame
Table Frame is visible: False
Table Frame is visible: True
CIM: &amp;lt;arcpy.cim.CIMLayout.CIMLayout object at 0x00000265A2EA4CC8&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you sure you're manipulating the correct layout?&lt;/P&gt;&lt;P&gt;Can you share the whole code?&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jun 2022 10:53:49 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-06-02T10:53:49Z</dc:date>
    <item>
      <title>Cells succesfully running in Notebook but actions not visible in the ArcGIS Pro Layout</title>
      <link>https://community.esri.com/t5/python-questions/cells-succesfully-running-in-notebook-but-actions/m-p/1179354#M64693</link>
      <description>&lt;P&gt;I have been trying to automate the map production in ArcGIS Pro 2.9.1&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a point in the production where it has to turn on and off some of the elements in the layout and I figured how to do it as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is the code I'm using:&lt;/P&gt;&lt;P&gt;am_lyt=lyt.listElements(wildcard="Name_of_the_table")[0]&lt;BR /&gt;print(am_lyt.visible)&lt;BR /&gt;am_lyt.visible=True&lt;BR /&gt;print(am_lyt.visible)&lt;/P&gt;&lt;P&gt;This gives the result:&lt;/P&gt;&lt;P&gt;False&lt;BR /&gt;True&lt;/P&gt;&lt;P&gt;But the table is not turning on and there's no error either. Surpisingly, when I executed the below code, I could see the action on the layout, its just the visibility not working&lt;/P&gt;&lt;P&gt;mf.camera.setExtent(mf.getLayerExtent(sitelyr, False, True))&lt;BR /&gt;print ("x")&lt;/P&gt;&lt;P&gt;I tried using the CIM:&lt;/P&gt;&lt;P&gt;cim_lyt=lyt.getCIM()&amp;nbsp;&lt;/P&gt;&lt;P&gt;but this line of code is not executing, so I tried the below:&lt;/P&gt;&lt;P&gt;cim_lyt=lyt.getDefinition('V2')&lt;/P&gt;&lt;P&gt;Sadly getDefinition kept giving me it has to attribute error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to resolve this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 07:57:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cells-succesfully-running-in-notebook-but-actions/m-p/1179354#M64693</guid>
      <dc:creator>Sahaja</dc:creator>
      <dc:date>2022-06-02T07:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Cells succesfully running in Notebook but actions not visible in the ArcGIS Pro Layout</title>
      <link>https://community.esri.com/t5/python-questions/cells-succesfully-running-in-notebook-but-actions/m-p/1179381#M64694</link>
      <description>&lt;P&gt;Hmmm... This code works for me. No matter if the layout is opened or not, no matter the element (eg north arrow works too), and no matter whether I execute in a notebook or in the Python Window.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lyt = arcpy.mp.ArcGISProject("current").listLayouts()[0]
print(f"Layout name: {lyt.name}")

e = lyt.listElements(wildcard="Table Frame")[0]
print(f"Element name: {e.name}")

print(f"{e.name} is visible: {e.visible}")
e.visible = not e.visible
print(f"{e.name} is visible: {e.visible}")

cim = lyt.getDefinition("V2")
print(f"CIM: {cim}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Element name: Table Frame
Table Frame is visible: False
Table Frame is visible: True
CIM: &amp;lt;arcpy.cim.CIMLayout.CIMLayout object at 0x00000265A2EA4CC8&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you sure you're manipulating the correct layout?&lt;/P&gt;&lt;P&gt;Can you share the whole code?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 10:53:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cells-succesfully-running-in-notebook-but-actions/m-p/1179381#M64694</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-06-02T10:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Cells succesfully running in Notebook but actions not visible in the ArcGIS Pro Layout</title>
      <link>https://community.esri.com/t5/python-questions/cells-succesfully-running-in-notebook-but-actions/m-p/1179668#M64701</link>
      <description>&lt;P&gt;Thank you for waiting. I believe I'm manipulating the correct layout. Here's the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import pandas as pd
import os

abspath=os.path.abspath
abspath=os.path.abspath("__file__")
dname=os.path.dirname(abspath)
os.chdir(dname)
ProjectFolder=dname
print(dname)
arcpy.env.workspace=ProjectFolder

project=ProjectFolder +"\ContamCertificates.aprx"
aprx=arcpy.mp.ArcGISProject(project)

mapName= "Map"
layoutName="CTXX"
site= "siteboundary"
m=aprx.listMaps(mapName)[0]
sitelyr=m.listLayers(site)[0]
lyt=aprx.listLayouts(layoutName)[0]
mf = lyt.listElements("mapframe_element", "Map")[0]

mf.camera.setExtent(mf.getLayerExtent(sitelyr, False, True))
print ("x")

arcpy.env.overwriteOutput = True

NSW_CLR_STATUS_IN_Current = "NSW_CLR_STATUS_IN_Current"
siteboundary = "siteboundary"

# Process: Select Layer By Location (Select Layer By Location) (management)
NSW_CLR_STATUS_IN_Current, Output_Layer_Names, Count = arcpy.management.SelectLayerByLocation(in_layer=[NSW_CLR_STATUS_IN_Current], overlap_type="INTERSECT", select_features=siteboundary, search_distance="500 Meters", selection_type="NEW_SELECTION", invert_spatial_relationship="NOT_INVERT")

print (arcpy.GetCount_management(NSW_CLR_STATUS_IN_Current))

if arcpy.GetCount_management(NSW_CLR_STATUS_IN_Current) != 0:
    print("the site is medium risk")
    #Results = lyt.listElements("GRAPHIC_ELEMENT", "Results")[0]
    #Print(results)
    rslt_within500=lyt.listElements("TEXT_ELEMENT", "Note_within_500m")[0]
    rslt_within500.visible=True
    print(rslt_within500.visible)

am_lyt=lyt.listElements(wildcard="Name_of_the_table")[0]
print (am_lyt.visible)
am_lyt.visible=True
print(am_lyt.visible)

fn = ProjectFolder+"\ContaminationCertificate.pdf"
lyt.exportToPDF(fn)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your style&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;am_lyt.visible = not am_lyt.visible&lt;/LI-CODE&gt;&lt;P&gt;This isn't working either.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for looking at this&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 23:57:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cells-succesfully-running-in-notebook-but-actions/m-p/1179668#M64701</guid>
      <dc:creator>Sahaja</dc:creator>
      <dc:date>2022-06-02T23:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Cells succesfully running in Notebook but actions not visible in the ArcGIS Pro Layout</title>
      <link>https://community.esri.com/t5/python-questions/cells-succesfully-running-in-notebook-but-actions/m-p/1179703#M64702</link>
      <description>&lt;P&gt;Funny enough, I tried running the same code as a python script and the visibility feature works but not the zoom to the feature extents, in fact, it zooms out to the entire world with this line&lt;/P&gt;&lt;LI-CODE lang="c"&gt;mf.camera.setExtent(mf.getLayerExtent(sitelyr, False, True))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Jun 2022 02:05:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cells-succesfully-running-in-notebook-but-actions/m-p/1179703#M64702</guid>
      <dc:creator>Sahaja</dc:creator>
      <dc:date>2022-06-03T02:05:37Z</dc:date>
    </item>
  </channel>
</rss>

