{"id":18513114,"url":"https://github.com/cody-scott/arcgis_layout_manager","last_synced_at":"2025-04-09T06:32:42.674Z","repository":{"id":57411334,"uuid":"83709242","full_name":"cody-scott/ArcGIS_Layout_Manager","owner":"cody-scott","description":null,"archived":false,"fork":false,"pushed_at":"2021-05-19T21:30:44.000Z","size":40,"stargazers_count":5,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T00:09:39.924Z","etag":null,"topics":["arcgis","arcmap","arcpy","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cody-scott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-02T18:06:20.000Z","updated_at":"2022-04-18T09:48:42.000Z","dependencies_parsed_at":"2022-09-09T16:02:10.224Z","dependency_job_id":null,"html_url":"https://github.com/cody-scott/ArcGIS_Layout_Manager","commit_stats":null,"previous_names":["cody-scott/arcgis_layout_manager","namur007/arcgis_layout_manager"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cody-scott%2FArcGIS_Layout_Manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cody-scott%2FArcGIS_Layout_Manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cody-scott%2FArcGIS_Layout_Manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cody-scott%2FArcGIS_Layout_Manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cody-scott","download_url":"https://codeload.github.com/cody-scott/ArcGIS_Layout_Manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247992791,"owners_count":21029971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arcgis","arcmap","arcpy","python"],"created_at":"2024-11-06T15:36:33.227Z","updated_at":"2025-04-09T06:32:37.661Z","avatar_url":"https://github.com/cody-scott.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\nThis package was created to help with the issues of managing multiple map layouts within a single ArcMap document. \nAs it stands currently, the arcpy.mapping package provides many great tools to manipulate map documents to create map books, and manage multiple layouts, but it is cumbersome to create each time.\n\nThe LayoutManager attempts to help this by tracking the location and details of Layout Objects on your map document, as well as table of contents items including if it is turned on/off, and transparency.\n\nThe intended method is that the layouts are authored within ArcMap manually, then can be easily switched between and updated. Nothing limiting doing by code though.\n\nThe data associated with the LayoutManager is stored in JSON which can be easily changed outside of ArcMap.\n\nFinally, the package is usable from within ArcMap's python window, or incorporated into exernal scripts.\n\n# Use Cases\n\nSome potential uses for this would include creating multiple maps that toggle layers on and off in the table of contents.\nCreating Data Driven pages that require moving items on and off the map layout.\n\nMany More!\n\n# Installation\nArcGIS installation is required\n\nInstall package via pip\n\n    pip install ArcGIS-Layout-Manager\n    \nTo use within ArcMap, install to the global site packages or if you wish to keep in a virtual environment but use arcpy, toggle global site packages on your virtual environment\n\n    toggleglobalsitepackages -q\n    \n    \n# Usage\n\n## Initialize\nCan function from within ArcMap or within a separate script\n\nWithin ArcMap\n\n    from ArcGIS_Layout_Manager import LayoutManager\n    lm = LayoutManager()\n\nFrom script\n\nUsing path to mxd file\n\n    from ArcGIS_Layout_Manager import LayoutManager\n    mxd_path = r'C:\\sample.mxd'\n    lm = LayoutManager(mxd_path=mxd_path)\n    \nor using arcpy.mapping.MapDocument class\n\n    from ArcGIS_Layout_Manager import LayoutManager\n    mxd = already started arcpy.mapping.MapDocument\n    lm = LayoutManager(mxd=mxd)\n\nA layout.json file is created within the same folder as the map document taking the map document name as the beginning\nUsing the above example, the file would be called sample_layout.json in the folder\n\n* C:\\sample.mxd\n* C:\\sample_layout.json\n\n## Create New Layout\n\nEach layout you would like to use requires a layout to be created.\n\n    lm.create_layout(\"Layout Name\")\n\nEach layout name must be unique. To check existing names call\n\n    lm.list_layouts()\n    \n## Changing Layouts\n\nTo change between your created layouts call\n\n    lm.switch_layout(\"Layout Name\")\n    \n## Updating Layouts\n\nOnce you made one or many changes to a layout within ArcMap, you'll need to update the current layout data.\nFor your currently activate layout:\n\n    lm.update_layout()\n    \nFor a specific layout\n\n    lm.update_layout(\"Layout Name\")\n\n## Saving Layout Manually\nTo save JSON manually\n\n    lm.save_layout_json()\n\n# Properties\n\nThe LayoutManager has a number of properties that can be set according to your want and needs\n\n### Auto Save\nAuto Save JSON file when changing to a new layout, updating current layout, or creating new layout.\n    \n    lm.auto_save = True/False\n    \n### Move Missing Off Screen\nIf the LayoutManager encounters a new item that you have added to the layout, but have not updated the active layout to include (such as a new text box or scale bar), then you can chose to either keep it in place in the new layout, or move it off screen.\nYou can also affix it to a new location and call update_layout() to save its place for future.\n\n    lm.move_missing_off_screen = True/False\n\n### Table of Contents Active\nFlag if you want the LayoutManager to change your table of contents items when update_layout is called\n\n    lm.toc_active = True/False\n    \n### Layouts Active\nFlag if you want the LayoutManager to change your map layout items when update_layout is called\n\n    lm.lyr_active = True/False\n    \n### Get Active Layout\nGet your currently active layout property\n\n    lm.active_layout\n    \n# Examples\n\nAll of these assuming the following\n\n    from ArcGIS_Layout_Manager import LayoutManager\n    mxd = arcpy.mapping.MapDocument(r'C:\\sample.mxd')\n    lm = LayoutManager(mxd=mxd)\n\n### Mapbook of two different locations\n\ncreate two layouts\n\n    lm.create_layout(\"Layout One\")\n    lm.create_layout(\"Layout Two\")\n\nActivate Layout One\n\n    lm.switch_layout(\"Layout One\")\n\nZoom map to one location\n\nActivate Layout Two\n\n    lm.switch_layout(\"Layout Two\")\n    \nZoom map to second location\n\nExport both layouts\n\n    for item in lm.list_layouts():\n        lm.switch_layout(item)\n        arcpy.mapping.ExportToJPEG(mxd, r'C:\\{}'.format(item))\n        \n### Two Maps with Imagery layer toggled on and off\n\ncreate two layouts\n\n    lm.create_layout(\"Layout One\")\n    lm.create_layout(\"Layout Two\")\n\nActivate Layout One\n\n    lm.switch_layout(\"Layout One\")\n  \nEnsure imagery layer is enabled\n\nActivate Layout Two\n\n    lm.switch_layout(\"Layout Two\")\n    \ndisable the imagery layer\n\nExport both layouts\n\n    for item in lm.list_layouts():\n        lm.switch_layout(item)\n        arcpy.mapping.ExportToJPEG(mxd, r'C:\\{}'.format(item))\n\n\n### Create layout on existing data driven pages map\n\n    idx_lyr = mxd.dataDrivenPages.indexLayer\n    name_field = mxd.dataDrivenPages.pageNameField\n    with arcpy.da.SearchCursor(idx_lyr, name_field.name) as sc:\n        for row in sc:\n            page_name = row[0]\n            page_id = mxd.dataDrivenPages.getPageIDFromName(page_name)\n\n            mxd.dataDrivenPages.currentPageID = page_id\n            arcpy.RefreshActiveView()\n\n            lm.create_layout(page_id)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcody-scott%2Farcgis_layout_manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcody-scott%2Farcgis_layout_manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcody-scott%2Farcgis_layout_manager/lists"}