Skip to content

Instantly share code, notes, and snippets.

@gpprojekt-marcin
Created November 18, 2019 20:19
Show Gist options
  • Save gpprojekt-marcin/70380fe99e1ae3aa778959b0f2a006a6 to your computer and use it in GitHub Desktop.
Save gpprojekt-marcin/70380fe99e1ae3aa778959b0f2a006a6 to your computer and use it in GitHub Desktop.
Sync project extents with base
arcpy.env.workspace = "."
current_mxd = arcpy.mapping.MapDocument("CURRENT")
current_dfs = arcpy.mapping.ListDataFrames(current_mxd)
project_filename = current_mxd.filePath.split('\\')[-1]
project_name = project_filename[:-4].split('_')[0]
project_scale = project_filename[:-4].split('_')[-1]
plan_filename = "{}_RysunekPlanu_{}.mxd".format(project_name, project_scale)
plan_mxd = arcpy.mapping.MapDocument(plan_filename)
source_dfs = arcpy.mapping.ListDataFrames(plan_mxd)
for index in range(len(source_dfs)):
current_dfs[index].extent = source_dfs[index].extent
current_mxd.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment