zoom = arcpy.mapping.ListLayers(mxd,cut,"")[0] # we locate cut layer in TOC. cut is a variable df.extent = zoom.getExtent() # Zoom to Layer zoom df.scale = 20000 # we set the scale to 1:20,000 arcpy.RefreshActiveView() arcpy.RefreshTOC() mxd.save()
Solved! Go to Solution.
hee hee layer files is exactly what I have been trying to get away from for well over a decade.
I have actualy been posting this question ever now and then for a long long time.
I have one particular mxd from which I generate .pdf files for one of my clients. I have 4 levels of visibility for which I want certain features of a feature class to be visible. so as the scale gets larger more features become visible.
I normally have 5 features that would be to clutterd to show all of them at a small scale. So i have them in the mxd 4 times and using definition querys make certain features visible. When I drop below 1:20,000 the first layer goes gray and the second layer is visible with all features from the first and more now visible. It also then controls lables.
The major issue is when someone suddently wants a larger format product I have to redefine all the scale visibility or even worse when they want a change in labels I need to make that change multiple times for each copy of the attribute.
etc....
It has to be possible Your data frame is constantly returning you current scale.
you scroll in and out if is instantly updated. Also when you put in scale text or scale bar that changes. so the system has to be constantly quering it.
Try setting the data_frame parameter of the ExportToPDF function to "PAGE_LAYOUT". This will export the layout view in the mxd. If this parameter in not set it will default to the data frame.
arcpy.mapping.ExportToPDF(mxd, dir + "\file.pdf", "PAGE_LAYOUT")