|
POST
|
Here is a snippet of code that works in the application using the current keyword. I'm using a point FC in the first map and using the linkID to zoom to another layer in the second map using the ID. p = arcpy.mp.ArcGISProject('current') m1 = p.listMaps('Map')[0] m2 = p.listMaps('Map1')[0] #M1/layer1 - point FC assuming 1 feature is selected lyr1 = m1.listLayers('PointFC')[0] cursor = arcpy.SearchCursor(lyr1) for row in cursor: linkID = row.getValue("LinkID") print(linkID) #M2/layer2 - zoom to polygon feature lyr2 = m2.listLayers('PolygonFC')[0] lyr2.definitionQuery = "LinkID = linkID" view = m2.openView() view.camera.setExtent(view.getLayerExtent(lyr2, True))
... View more
09-12-2022
07:51 PM
|
1
|
0
|
3589
|
|
IDEA
|
Have you considered Python Map Automation? Groups are based on a field in the index layer. You can simply query for each group to create a selection set and use the selected export option. Here is a snippet of code for the above project: import arcpy, os, sys
p = arcpy.mp.ArcGISProject("CURRENT")
l = p.listLayouts('Layout')[0]
if not l.mapSeries is None:
ms = l.mapSeries
if ms.enabled:
ms = l.mapSeries
indexLyr = ms.indexLayer
#AFC-EAST
arcpy.management.SelectLayerByAttribute(indexLyr, "NEW_SELECTION", "TeamInfo.Conf_Div = 'AFC-EAST'")
ms.exportToPDF(r"C:\Temp\AFC_EAST.pdf", "SELECTED")
#AFC-NORTH
arcpy.management.SelectLayerByAttribute(indexLyr, "NEW_SELECTION", "TeamInfo.Conf_Div = 'AFC-NORTH'")
ms.exportToPDF(r"C:\Temp\AFC_NORTH.pdf", "SELECTED")
... View more
09-12-2022
07:16 PM
|
0
|
0
|
8655
|
|
POST
|
I'd like to learn more about your workflow and why you need to activate a map. Are you working with maps in map views or maps in map frames (on a layout)? At 3.0, we have new functions that allow you to call Map.OpenView() or Layout.OpenView() - this command will open and activate the current view. In terms of referencing multiple maps and passing variable information from one map to another map for the purposes of cursors, changing extents, etc, that all works. Jeff - Layout and arcpy.mp teams.
... View more
09-12-2022
10:53 AM
|
0
|
2
|
3610
|
|
IDEA
|
We are testing a fix for this issue for ArcGIS Pro version 3.1
... View more
09-02-2022
01:37 PM
|
0
|
0
|
2745
|
|
IDEA
|
Greg, Thanks for the clarification. I personally wouldn't give up on python automation, but that's me, a Python automation guy. The second sample was based on a customer project I built for a customer with the exact issue you had. They had 400 individual MXDs and they had such a hard time managing those MXDs. I built a database solution where the misfit layouts configurations were persisted in a table. If the table record existed for that index feature, then the Python script would do its reconfiguration for that page, etc (all run from a single MXD). Anyway, having a tool to create a layout / map for each page in a map series does NOT exist yet BUT at 3.1 implemented a way to createMap() and copyItem. This would allow you to copyItem(Layout) for each map series index feature and createMap for each mapframe, when needed. This seams like a fun project to solve, Jeff - Layout and arcpy.mp teams
... View more
08-25-2022
10:54 AM
|
0
|
0
|
7812
|
|
IDEA
|
Hello Greg, Have you considered Python Map Automation? https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/introduction-to-arcpy-mp.htm I don't know the details of your project but I personally think creating a layout for each map series page can be a bit too much for the project and difficult to make the same updates to all layouts, if ever needed. I'm not clear on how your need "annotate" from page to page but there could be a solution with a single layout. If you are using annotation, those layers could be duplicated, one for each layout, or use a definition query to control the visible anno features. By using python code along with your map series you can customize what happens from page to page. Arcpy.mp can easily control the visibility of layers or set properties like definition query, etc. If you are familiar with Python, we have a couple of samples you might want to evaluate: Go to: https://esriurl.com/arcpy.mp/samples (for all our samples) Then check out: Thematic Map Series and MultipleElementLayoutManager samples The later is a bit more advances in that all information is persisted in a table that controls exactly what gets displayed on a layout. Jeff - Layout and arcpy.mp teams.
... View more
08-25-2022
09:16 AM
|
0
|
0
|
7838
|
|
IDEA
|
Thanks Brett for clarifying the issue. I was able to reproduce your issue and submitted a bug. I noticed that with map.exportToMAPX doesn't throw an error but I don't think the export happens - at least the timestamp isn't updated. exportToPDF(r"C:\Temp\ABC") exportToPDF(r"C:\Temp\ABC") Auto creates the .pdf ext, overwrites output and updates the timestamp. We will make the export experience similar. Thanks again, Jeff - Layout and arcpy.mp teams
... View more
08-24-2022
02:19 PM
|
0
|
0
|
2773
|
|
POST
|
Because the pasted code does NOT show indentation, which is critical for Python code blocks, here is a screen shot of the same code above.
... View more
08-19-2022
09:03 AM
|
0
|
1
|
1888
|
|
POST
|
Hello JMitchell, Have you considered using Python Map Automation? https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/introduction-to-arcpy-mp.htm It is an API that allows you to automate the contents of projects such as maps, layers, layouts and much more. The devil is in the detail but here is a very generic script that exports a PDF for each unique set of DefQueries. The code obviously needs to be modified to work with your project/data and depending on your specific needs, more logic most likely needs to be added. I hope this helps, Jeff - Layout and arcpy.mp teams p = arcpy.mp.ArcGISProject('current') lyt = p.listLayouts('Yosemite National Park')[0] #Build a list of definition queries defQuery1 = "NAME = 'Arch Rock Entrance'" defQuery2 = "NAME = 'Big Oak Flat Entrance'" defQuery3 = "NAME = 'Hetch Hetchy Entrance'" defQueryList = [defQuery1, defQuery2, defQuery3] #Iterate through all the def queries for all the maps #and update layer def queries IF one is present for dq in defQueryList: for m in p.listMaps(): for lyr in m.listLayers(): if lyr.supports("DEFINITIONQUERY"): if lyr.definitionQuery != None: lyr.definitionQuery = dq #build unique outout name based on the defquery string start = "NAME = '" end = " Entrance'" lytNamePath = "C:\\Temp\\" + (dq.split(start))[1].split(end)[0] + ".pdf" #export to PDF before using the next def query lyt.exportToPDF(lytNamePath)
... View more
08-19-2022
09:00 AM
|
0
|
2
|
1888
|
|
POST
|
Map/Report/Layout.openView() Jeff - Layout and arcpy.mp teams
... View more
08-16-2022
04:47 PM
|
0
|
0
|
2042
|
|
IDEA
|
Add ArcGISProject.closeViews() at 3.0. Jeff - Layout and arcpy.mp teams
... View more
08-12-2022
09:49 AM
|
0
|
0
|
3760
|
|
IDEA
|
Hello everyone and thank you for your feedback! I missed this thread because it wasn't labelled arcpy.mp. We exposed Python CIM Access to be able to accommodate these finer grained requests. Please review this topic: https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/python-cim-access.htm You should be able to accomplish now using arcpy.mp and CIM access. Also in the pipeline on the Layout team (post 3.1) that you might find useful is we plan on adding scale thresholds to layout map surrounds elements so, for example, you can have multiple, stacked scalebars with different settings, scale will control visibility and if you sent the thresholds up correctly, just one scale bar would display at a time. As for arcpy, here is a script from a downloadable sample that has 30 CIM snippets. I modified it slightly to also update divisions and subdivisions I saw mentioned in the thread. Here is a before and after scale bar. Code sample: p = arcpy.mp.ArcGISProject('current') lyt = p.listLayouts('GreatLakes')[0] lyt_cim = lyt.getDefinition("V2") #Get the layout's CIM definition #Iterate though all layout elements to find the ScaleBar element for elm in lyt_cim.elements: if elm.name == "Scale Bar": #Change the number of divisions and subdivision elm.divisions = 3 elm.subdivisions = 2 #Flip the scale bar so markers and labels appear below the line elm.labelPosition = "Below" elm.markPosition = "Below" #Remove the first midpoint division label by labeling only divisions elm.labelFrequency = "Divisions" lyt.setDefinition(lyt_cim) #Set the layout's CIM definition The CIM samples can be located here: https://esriurl.com/arcpy.mp/samples Then scroll to the one called CIM Samples
... View more
08-12-2022
08:22 AM
|
0
|
0
|
3506
|
|
POST
|
Hello, The X/Y Min/Max values represent a rectangle like you suggest. Rectangles are just one way of controlling extent and are not always the best. For example, if the data in a map frame is rotated, the extent that gets returned will not match what you see in the UI because a rotated rectangle has a larger extent. There are other techniques for zooming to a layer, selected features in a layer, etc. Check out the first sample located in the MapFrame help topic. The same logic will work with a MapView. The second parameter is to use the layers's selection. if False, use all features, if True, use selection. So you can first perform a SelectLayerByAttributes or ByLocation to create a selection and then use the selection to control your zoom level. mf.camera.setExtent(mf.getLayerExtent(lyr, False, True)) https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapframe-class.htm
... View more
08-11-2022
10:21 AM
|
0
|
0
|
3789
|
|
IDEA
|
Given you can use importDocument(path to mapx), change data sources, then export back to mapx, this lessens the priority of creating additional classes and members given a fair amount of other planned development work. If the above workflow does NOT work for you, please describe in detail you scenario and we could reconsider. Jeff - Layout and arcpy.mp teams
... View more
08-10-2022
02:40 PM
|
0
|
0
|
2658
|
|
IDEA
|
Thank you for your feedback. There is a long answer to this. First, the Layout team is developing commands for 3.1 that allow you to resize a layout AND have an option to scale layout elements proportionally. The same resize boolean is available to copying a layout. Second, arcpy.mp (NOT arcpy.mapping in ArcMap) is also being expanded. At 3.1 we are adding content management functions to copy project items like maps, layouts, and reports. This allows you to make a copy and then automate changes to the copy. arcpy.mp already allow you to change the page size - the problem is that is does NOT automatically resize elements. That option can't come until after the Layout commands are completed. At 3.1 arcpy.mp is also adding the ability to CREATE new maps but NOT layouts (yet). That is because arcpy.mp traditionally doesn't allow you to create new objects so why create a layout when you can't create things like map frames, scalebars, etc. This is definitely something we want to get to longer term. Jeff - Layout and arcpy.mp teams
... View more
08-10-2022
07:54 AM
|
0
|
0
|
4748
|
| 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 |
Online
|
| Date Last Visited |
yesterday
|