Sunday 24 February 2019

arcgis desktop - How to get a list of map scales programmatically in ArcMap?


I need to get all map scales, which are shown in the ArcMap scalebar. I need list of value, something like:


1:1500
1:3000
1:6000
1:12000
1:24000
1:50000
1:100000


Does anyone know how to get it?



Answer



Sorry, maybe my question was not clear enough, but I found the solution, and it simple enough.


IDisplayTransformationScales interface provides access to this data.


using .NET it look like:


var mxDocument = (IMxDocument)_application.Document;
var activeView = (IActiveView)mxDocument.FocusMap;
var dts = (IDisplayTransformationScales)activeView.ScreenDisplay.DisplayTransformation;
var scales = Enumerable.Range(0, dts.UserScaleCount)

.Select(x => dts.GetUserScale(x))
.ToArray();

if you want use scale format defined in ArcMap you should use ScaleFormat class.


I would be very appreciated if someone tell me a way to get all scale formats.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...