|
POST
|
Hello MingCao, Below is a snippet of code that modifies a layer's legend item label size using Python CIM access. Note - you may not get the results you expect if your Legend is using a fitting strategy that involves automatically adjusting font size. Also be careful about setting LayerNames vs Labels font size. It depends on the properties of the legend which ones are displayed. Uncomment the last two lines if you want to change the font size. p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts('Layout_MS')[0]
lyt_cim = lyt.getDefinition('V2')
for elm in lyt_cim.elements:
if elm.name == "Legend":
print(elm.fittingStrategy)
for itm in reversed(elm.items):
if itm.name == "GreatLakes":
print(itm.labelSymbol.symbol.height)
#itm.labelSymbol.symbol.height = 9.99
#lyt.setDefinition(lyt_cim)
... View more
05-10-2021
02:05 PM
|
0
|
0
|
7473
|
|
POST
|
Were you able to find the PDFDocument class help which includes a sample on how to append PDFs together? https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/pdfdocument-class.htm Jeff - arcpy.mp and Layout teams
... View more
05-05-2021
07:29 AM
|
0
|
1
|
3504
|
|
POST
|
Becca, with a little digging and team help, the following may be your solution (without having to use a Python script to update the value). On layout, insert Dynamic Text --> Value Click on the Value to open the Insert Table Attribute dialog. Set the table to be the index layer (doesn't really matter) Click the expression button next to field and set the expression to: var relDate = Now();
var start = DateAdd(relDate, -8, "days");
var end = DateAdd(relDate, -2, "days");
Text(start, 'M/D/Y') + ' to ' + Text(end, 'M/D/Y');
... View more
04-29-2021
03:15 PM
|
4
|
1
|
5743
|
|
POST
|
Hello Becca, Can you please provide a screenshot of where you set this in ArcMap? I tried in both ArcMap and Pro and could not get this to work. Jeff - arcpy.mp and Layout teams
... View more
04-29-2021
01:04 PM
|
1
|
1
|
5794
|
|
POST
|
Here is a snippet that changes the group layer name size and color. For more information on Python CIM access: https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/python-cim-access.htm lyt.setDefinition(lyt_cim)
arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts('Layout_MS')[0]
lyt_cim = lyt.getDefinition('V2')
for e in lyt_cim.elements:
if e.name == 'Legend':
for itm in e.items:
if itm.name == 'GreatLakes':
itm.groupLayerNameSymbol.symbol.height = 24 #Change font size
itm.groupLayerNameSymbol.symbol.symbol.symbolLayers[0].color.values = [255,255,20, 100] #change RGB color
lyt.setDefinition(lyt_cim) Jeff - arcpy.mp and Layout teams
... View more
04-27-2021
02:45 PM
|
1
|
0
|
2829
|
|
POST
|
Anamanvil, I can provide a sample Python script using Python CIM access but 1) I really want to know more about the UI and why it is automatically readjusting. What is your fitting strategy? If you have auto adjust font size, I would expect font size to ignore your settings because the legend was set to auto adjust. 2) Python CIM access is slightly more advanced. Are you familiar with arcpy.mp? Again, I'm a happy to send a snippet but I want to make sure there is not a bug in the application. Jeff - arcpy.mp and Layout teams
... View more
04-27-2021
01:44 PM
|
0
|
1
|
2837
|
|
POST
|
Yeah, you had me scratching my head on the missing parameters. 🙂 Again, its a great idea to build the query in the Definition Query dialog and look at the SQL string. Good luck moving forward. Jeff
... View more
04-22-2021
11:43 AM
|
1
|
0
|
1090
|
|
POST
|
Jeff, I see two mistakes. 1) your where clause is forcing single quotes around the field name. I don't think you want them. A simple way to validate your where clause is to try to build the same query via the Definition Query interface. Build the query you want there and click the SQL button to see the correct formatting. Then use print statements in your code to make sure the query is correct. 2) You are exporting the LAYOUT object, NOT the MS object. The layout does NOT support page_range_type, the MS object does. Jeff - arcpy.mp and Layout teams
... View more
04-22-2021
08:50 AM
|
1
|
2
|
6143
|
|
POST
|
Jeff, There are no hidden parameters in Python. The autocomplete should should you the full list of parameter names and their order. What makes this function a little unique is that you won't always specify all parameters in their order because some are conditional. For example page_range_string is ONLY evaluated IF page_range_type is set to RANGE. This is documented in the help but I certainly understand your confusion. I'm happy to see you got it figured out. I realized after that example 3 is very similar to the code I sent you. Jeff - arcpy.mp and Layout teams
... View more
04-21-2021
03:56 PM
|
2
|
0
|
6179
|
|
POST
|
Hello Jeff. We unfortunately don't have samples for all possible parameter combinations but this would be a good one. Here is a snippet that I just recently used for a project I was working on: map_series = layout.mapSeries
if map_series.enabled:
output = os.path.join(policy_folder, layout_name + ".pdf")
indexLyr = map_series.indexLayer
where_clause = f"{policy_field} = {policy_number}"
arcpy.SelectLayerByAttribute_management(in_layer_or_view=indexLyr,
selection_type="NEW_SELECTION",
where_clause=where_clause)
map_series.exportToPDF(out_pdf=output,
page_range_type="SELECTED",
resolution=300) I hope this helps you, Jeff - arcpy.mp and Layout teams
... View more
04-21-2021
02:07 PM
|
1
|
0
|
6188
|
|
POST
|
Hello and thank you for reporting this issue. It has been addressed for Pro version 2.8.
... View more
04-15-2021
03:47 PM
|
0
|
0
|
1828
|
|
POST
|
I understand the catch-22. The CIM was designed to be an efficient storage mechanism for quickly recreating the content in a project. The CIM was not designed specifically to support APIs but rather can be used by APIs to access properties that may not be available to the published API. This "known limitation" means that we need to add field management capabilities to the published API. That will take time and in some cases, may not happen. Jeff - arcpy.mp and Layout Teams
... View more
04-14-2021
02:01 PM
|
2
|
0
|
6134
|
|
POST
|
I want to thank you Marvis for sending me your data. I was able to reproduce and then checked in with our CIM experts. I learned something too. "We only write field descriptions if they differ from the default for that field. Once you make some change (to the field visibility, or alias, or formatting, etc.) to any field, then we populate that entire collection. Doing it this way keeps the layer representation small. Think of them as overrides." So to get this to work, I simply went into the fields view and changed the visibility of OID. I made it not visible. Then I saved the project and ran the same code and I could see ALL fields. Jeff - arcpy.mp and Layout teams
... View more
04-13-2021
03:15 PM
|
2
|
6
|
6147
|
|
POST
|
I'm not sure what to say. Does your FC have an attribute table? I just tried the following on a simple polygon layer. p = arcpy.mp.ArcGISProject('current')
m = p.listMaps()[0]
l = m.listLayers()[0]
c = l.getDefinition('V2')
fields = c.featureTable.fieldDescriptions
len(fields)
15 You are welcome to send me a layer package to [email protected] and I can take a look. Jeff - arcpy.mp and Layout teams
... View more
04-13-2021
01:29 PM
|
0
|
7
|
6151
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-05-2025 11:20 AM | |
| 3 | 06-05-2025 09:21 AM | |
| 1 | 05-14-2025 01:19 PM | |
| 2 | 04-24-2025 07:54 AM | |
| 1 | 03-15-2025 07:19 PM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|