|
IDEA
|
@RonnieRichards this should be possible using Python CIM Access Here is a code snippet that could be used to find if a layer is a query layer. aprx = arcpy.mp.ArcGISProject('current')
m = aprx.listMaps()[0]
qlyr = m.listLayers('MyQueryLayer')[0]
cim_qlyr = qlyr.getDefinition("V3")
if type(cim_qlyr.featureTable.dataConnection).__name__ == 'CIMSqlQueryDataConnection':
print('Ureka, its a query layer') Next you could continue with modifying other CIM property, like the SQLQuery l_cim.featureTable.dataConnection.sqlQuery = "select OBJECTID,Shape,STATE_NAME,STATE_FIPS,SUB_REGION,STATE_ABBR,POP1990,POP2000,POP90_SQMI from ARCPYMAPPING_01.APM_PRO_states WHERE SUB_REGION = 'Mtn'"
qlyr.setDefinition(cim_qlyr) Data connection info is also there. Does this work for you? Jeff - Layout and arcpy.mp teams
... View more
07-26-2024
12:53 PM
|
0
|
0
|
413
|
|
IDEA
|
I just started to build a more complete solution to this specific workflow and other workflows that came up during the User Conference. I'll combine several solutions into one downloadable sample. While I was building this workflow I realized a couple of extra steps. First, if you simply disable a map series, any dynamic map series text or queries, etc will not work so your resulting duplicated layout will not display correctly. Second, I found it better to remove the map series instead of disable it because once you replace the dynamic nature of these elements, re-enabliing the map series will not re-create the dynamic capabilities. In the script below, you can see I have code to first remove the dynamic nature of map series to be hard coded BEFORE I remove the map series from the layout using Python CIM access. pageList = arcpy.GetParameter(0) #List of selected pages via script tool
removeMS = arcpy.GetParameter(1) #Boolean to remove map series from copied layout
#Reference the current project and layout
p = arcpy.mp.ArcGISProject('CURRENT')
lyt = p.listLayouts('Duplicate')[0]
#Confirm there is a map series
if not lyt.mapSeries is None:
ms = lyt.mapSeries
#Confirm the map series is enabled
if ms.enabled:
#Iterate through each choosen page
for page in pageList:
#Set the current map series page based on page name
ms.currentPageNumber = ms.getPageNumberFromName(page)
#Make the duplicate copy with new name
cpLyt = p.copyItem(lyt, 'Copy_' + page)
#Optional - remove the map series
if removeMS:
#Must convert title text from dynamic to static
title = cpLyt.listElements('Text_Element', 'Title')[0]
title.text = page
#Must convert table frame from dynamic to static
m = p.listMaps('Duplicate')[0]
lyr = m.listLayers('State Outlines')[0]
lyr.definitionQuery = f"STATE_NAME = '{page}'"
#Remove map series
cpLyt_cim = cpLyt.getDefinition('V3')
cpLyt_cim.mapSeries = None
cpLyt.setDefinition(cpLyt_cim) I hope to make the samples available soon, Jeff - Layout and arcpy.mp teams
... View more
07-24-2024
10:52 AM
|
0
|
0
|
664
|
|
IDEA
|
@HaydenWelch I completely understand your point of view. Are you also saying that in the UI, you have to refresh to ensure you get the proper export? That would definitely be a bug (the UI export or arcpy.mp export should always render proper output). Pro should automatically update and we purposely did not include a refresh option (like we had in ArcMap arcpy.mapping) because Pro's underlying architecture/services should do the automatic refresh. If they are not working, then we need to address that. It might be possible to provide a refresh option but I want to make sure we are providing the correct solution. Refresh my be a workaround but also an unnecessary step that will also be a performance hit. I hope this make sense. If I could get some clarification on your workflow and possible repro steps, then we can make sure a proper fix/solution is provided.
... View more
07-24-2024
08:57 AM
|
0
|
0
|
2208
|
|
IDEA
|
@HaydenWelch , thanks for the feedback. I'd like to know what type of layout elements are not updating for you. Ideally, layouts should automatically refresh on their own without having force a refresh. There are some core geoprocessing operations that may update data behind the scenes that doesn't trigger components in the app to refresh. At Pro 3.3 the core Arcpy team introduced arcpy.RefreshLayer() that should trigger the appropriate updates in the App when data is being modified. Another way to get the Layout to redraw is to use something like: p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts('Some Layout')[0]
lyt_cim = lyt.getDefinition('V3')
lyt.setDefinition(lyt_cim) The code above forces the layout and its elements to redraw BUT DOES NOT force underlying data to update. That is what arcpy.RefreshLayer(). MapSeries.refresh() is for situations where data in the index layer has been updated. Think of it as a specialized version of arcpy.RefreshLayer(). If this helps solve your issue, great, but if you there is a reason you really need to refresh a layout that is not data specific, please let us know. Jeff - Layout and arcpy.mp teams
... View more
07-24-2024
08:01 AM
|
0
|
0
|
2215
|
|
IDEA
|
@ShannonJ Below is a snippet of code. Keep in mind that there are number of different approaches and things to consider. In the example below, I'm exporting a Layout, not a map series. If you have dynamic text and other features managed by the map series, then you could need to update that using arcpy. import arcpy, os, sys relpath = os.path.dirname(sys.argv[0]) p = arcpy.mp.ArcGISProject(os.path.join(relpath, 'MapSeriesExamples.aprx')) m = p.listMaps('StatesWithRegions')[0] l = m.listLayers('States_WithRegions')[0] #unique values in layer all_values = [row[0] for row in arcpy.da.SearchCursor(l, 'sub_region')] unique_values = set(all_values) print(unique_values) #reference layout and map frame lyt = p.listLayouts('BasedOnSelection')[0] mf = lyt.listElements('MapFrame_Element', 'ZoomToRegion')[0] #create comboPDF = arcpy.mp.PDFDocumentCreate(os.path.join(relpath, 'Output', 'CombinedOutput.pdf')) #iterate through the unique list of field values and: # - create a selection # - set the map frame extent to that selection # - export to temp PDF, combine into combo pdf, then delete the temp pdf # - clear the selection for value in unique_values: query = f"SUB_REGION = '{value}'" arcpy.SelectLayerByAttribute_management(l, 'NEW_SELECTION', query) mf.camera.setExtent(mf.getLayerExtent(l, True, True)) lyt.exportToPDF(os.path.join(relpath, 'Output', 'temp.pdf')) comboPDF.appendPages(os.path.join(relpath, 'Output', 'Temp.pdf')) os.remove(os.path.join(relpath, 'Output', 'Temp.pdf')) arcpy.SelectLayerByAttribute_management(l, 'CLEAR_SELECTION') comboPDF.saveAndClose() os.startfile(os.path.join(relpath, 'Output','CombinedOutput.pdf')) print('Finished') Jeff
... View more
07-08-2024
07:45 AM
|
0
|
0
|
1071
|
|
IDEA
|
@ShannonJ would you be interested in an Python Map Automation (arcpy.mp) snippet. What it would do is get a list of unique field values to iterate over, select all features with that value, set the extent of the map frame to the selected features, and export before moving onto the next unique value. Individual pages could be generated or, if a PDF, optional, appended all into a single PDF. Jeff - arcpy.mp and Layout teams
... View more
07-05-2024
02:11 PM
|
0
|
0
|
1108
|
|
IDEA
|
This will be implemented in Pro 3.4. We added a lowerBound property to the GraduatedColorsRenderer, GraduatedSymbolsRenderer and the RasterClassifyColorizer classes. The upperBound property already exists on the ClassBreak class. We also modified the behavior so if you want to show values out of range (using Python CIM Access), we automatically generate a default symbol so you don't need to test for and and potentially build it yourself. Here is a Pro 3.4 code snippet: #New Pro 3.4 lowerBound property and behavior to show values out of range
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('LowerBoundResult')[0]
l = m.listLayers()[0]
if hasattr(l.symbology, 'renderer'):
if l.symbology.renderer.type == 'GraduatedColorsRenderer':
sym = l.symbology
sym.renderer.lowerBound = 5 #3.4 lowerBound set on Renderer
sym.renderer.classBreaks[-1].upperBound = 96 #upperBound set on upper ClassBreak
l.symbology = sym
#Show values out of range using Python CIM Access
l_cim = l.getDefinition('V3')
l_cim.renderer.useDefaultSymbol = True #3.4 auto creates if not present
l_cim.renderer.defaultLabel = "Out of range"
l.setDefinition(l_cim)
... View more
06-13-2024
09:03 AM
|
0
|
0
|
2346
|
|
IDEA
|
Hello @AR_GISNinja , Have you looked at: ArcGISProject.copyItem() https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm You can easily iterate over however many times you want to duplicate a layout and give each one a unique name. Jeff - arcpy.mp and Layout teams
... View more
05-31-2024
07:36 AM
|
0
|
0
|
2791
|
|
IDEA
|
This is functionality we would like to provide in the arcpy.mp API but need to overcome a few technical hurdles.
... View more
04-16-2024
09:01 AM
|
0
|
0
|
1922
|
|
IDEA
|
@FredSpataro there is an ArcGISProject.homeFolder property. In fact when trying to rebuild a project using the techniques above by importing into a blank project, there are many other items to consider. ArcGISProject.databases / updateDatabases ArcGISProject.defaultGeodatabase ArcGISProject.defaultToolbox ArcGISProject.folderConnections / updateFolderConnections ArcGISProjec.homeFolder ArcGISProject.styles / updateStyles (Pro 3.3) ArcGISProject.toolboxes / updateToolboxes (Pro 3.3) ArcGISProject.updateConnectionProperties We are considering creating New Project but there are some technical hurdles we need to resolve. Jeff - arcpy.mp team
... View more
04-16-2024
08:59 AM
|
0
|
0
|
1924
|
|
IDEA
|
@FourCornersMapping the importDocument method can be found under the ArcGISProject help topic: https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm This is not a replacement for your idea, it is a possible workaround for now. Python is great at automation. If you are not familiar with using Python for automation, I understand. The logic will need to be extended further if you want to set {reuse_existing_maps=False} because the object returned is a layout (for import PAGX) so you would need to know how to find the additiona, newly added maps that are also imported and then rename them accordingly. If there is a way to predict the names of the imported maps, then you could reference them and rename them using arcpy.mp. Here is an introductory help topic: https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/introduction-to-arcpy-mp.htm Jeff m = p.listMaps('imported map name')[0]
m.name = "New Name"
... View more
04-16-2024
08:48 AM
|
0
|
0
|
1417
|
|
IDEA
|
Hello @FourCornersMapping, I can't speak to doing this in the User Interface but this might be automated using Python. For example, p = arcpy.mp.ArcGISProject('current')
newLyt = p.importDocument(r"C:\temp\Layout.pagx", True, True)
newLyt.name = "New Layout" This technique only allows you to rename one object at a time. In the above example, I'm using reuse existing maps = True so if the map already exists, it doesn't get recreated as a project item. The importDocument function can also be used to import mapx and many other file types. Jeff - arcpy.mp and Layout teams
... View more
04-12-2024
09:50 AM
|
0
|
0
|
1496
|
|
IDEA
|
With Pro 3.3, we added applyStyle(style_Item) to all Layout Elements that can be created using styles. This allows you to apply a style to an existing element in a layout. This does NOT include borders, shadows, etc because those properties are not persisted in a style BUT Python CIM access can be used to set these properties. Thanks, Jeff - arcpy.mp and Layout SDK teams
... View more
04-10-2024
11:38 AM
|
0
|
0
|
1158
|
|
IDEA
|
This will be available with Pro 3.3. Layer.createLabelClass(name, expression, {sql_query}, {labelclass_language}) Jeff - arcpy.mp and Layout SDK teams
... View more
04-10-2024
11:32 AM
|
0
|
0
|
1671
|
|
IDEA
|
This will be made available in Pro 3.3. The following members were added to the API: Layer.pageQuery - r/o Layer.setPageQuery({field_name}, {match}) Jeff - arcpy.mp and Layout SDK teams
... View more
04-10-2024
11:30 AM
|
0
|
0
|
1307
|
| 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 |
a week ago
|