I was recently creating and standardizing settings for layouts in bulk and one thing I was hoping to do was set specific guides for them. If this was possible with python I could have set the vertical and horizontal guides to a offset of 0.25 inches for 50 maps with one click.
Marking as Already Offered based on the example Jeff provided showing how to achieve this.
Hi Brett,
This is a great example of using Python CIM Access: https://pro.arcgis.com/en/pro-app/2.8/arcpy/mapping/python-cim-access.htm
p = arcpy.mp.ArcGISProject("CURRENT")for lyt in p.listLayouts():lyt_cim = lyt.getDefinition('V2')newGuides = []#Bottom horizontal guidebotHorz = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V2')botHorz.position = 0.25botHorz.orientation = "Horizontal"newGuides.append(botHorz)#Top horizontal guidetopHorz = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V2')topHorz.position = lyt.pageHeight - 0.25topHorz.orientation = "Horizontal"newGuides.append(topHorz)#Left vertical guideleftVert = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V2')leftVert.position = 0.25leftVert.orientation = "Vertical"newGuides.append(leftVert)#Right vertical guiderightVert = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V2')rightVert.position = lyt.pageWidth - 0.25rightVert.orientation = "Vertical"newGuides.append(rightVert)#Add guides and make sure they are turned onlyt_cim.page.guides = newGuideslyt_cim.page.showGuides = True#Set back to layerlyt.setDefinition(lyt_cim)
p = arcpy.mp.ArcGISProject("CURRENT")
for lyt in p.listLayouts():lyt_cim = lyt.getDefinition('V2')
newGuides = []
#Bottom horizontal guidebotHorz = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V2')botHorz.position = 0.25botHorz.orientation = "Horizontal"newGuides.append(botHorz)
#Top horizontal guidetopHorz = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V2')topHorz.position = lyt.pageHeight - 0.25topHorz.orientation = "Horizontal"newGuides.append(topHorz)
#Left vertical guideleftVert = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V2')leftVert.position = 0.25leftVert.orientation = "Vertical"newGuides.append(leftVert)
#Right vertical guiderightVert = arcpy.cim.CreateCIMObjectFromClassName('CIMGuide', 'V2')rightVert.position = lyt.pageWidth - 0.25rightVert.orientation = "Vertical"newGuides.append(rightVert)
#Add guides and make sure they are turned onlyt_cim.page.guides = newGuideslyt_cim.page.showGuides = True
#Set back to layerlyt.setDefinition(lyt_cim)
Jeff - arcpy.mp and Layout teams
Melden Sie sich an, um zu posten, Inhalte zu folgen und mehr. Neu hier? Kostenlos registrieren.