1

I created a Python Toolbox which calculates statisitics about some layers and print a pdf layout.

The layout and table frame elements already exist.

enter image description here

I try to access the table frame elements from my Python script to do some modifcations on fields to show, field order and table frame position.

aprx = arcpy.mp.ArcGISProject("CURRENT") # my project
m = aprx.listMaps("Map2")[0] # my map
lyr = m.listLayers("Clip_Reco_Dissolve1")[0] # source layer for the table frame
lyt = aprx.listLayouts('Tabloid_Paysage_Unique_test')[0] # my layout
fieldNames = ["Categorie", "COUNT_Categorie"] # fields to display
elm = lyt.listElements("GRAPHIC_ELEMENT", "Categorie ressource") # name of the table frame in the layout content

The only way I found in Esri documentation is using last row, but it is not working. I tried again after converting this element to graphic, but it doesn't work either, and anyway I need to manipulate it as table frame to manage fields, before changing its position.

elm = lyt.listElements("GRAPHIC_ELEMENT", "Categorie ressource")
Traceback (most recent call last):
 File "<string>", line 1, in <module>
 File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_
 return fn(*args, **kw)
 File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 1840, in listElements
 return convertArcObjectToPythonObject(self._arc_object.listElements(*gp_fixargs((element_type, wildcard), True)))
RuntimeError
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Sep 13, 2022 at 19:49

1 Answer 1

2

I believe you are going to have to use the CIM access to reach into the table frame structure. Look at the TableFrame examples in the ArcGIS Pro Python CIM Samples.

answered Sep 14, 2022 at 0:02
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.