How can the scale of a mapframe changed with arcpy?

4149
4
Jump to solution
12-20-2016 08:58 AM
ThomasKölbel
New Contributor II

ArcGIS Pro 1.2

2D Map

If tried this code:

print(mf.camera.scale)

>> 125000.0

mf = myMapframe

mf.camera.type = "MAP"
mf.camera.setExtent(extent)
mf.camera.scale = 500000.0

print(mf.camera.scale)

>> 125000.0

so, nothing happend

Any ideas?

Thanks Tom

0 Kudos
1 Solution

Accepted Solutions
ThomasKölbel
New Contributor II

Problem is solved. Setting the viewing options in the mapframe properties to "none" enables the python code to run properly.

View solution in original post

4 Replies
DanPatterson_Retired
MVP Emeritus

ArcMap? Pro? CityEngine? something else?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Looking at the Camera documentation for scale:

scale
(Read and Write)

Provides the ability to either get or set the scale of the data in a map frame. A numerical (double) value must be used. Scales really only apply only to 2D map types because of their

planimetric view of the data. Scales can be returned from 3D maps types but are only an estimation.

Double

Are you working with a 3D map or 2D map?

ThomasKölbel
New Contributor II

Problem is solved. Setting the viewing options in the mapframe properties to "none" enables the python code to run properly.

PaulPanehal
New Contributor III

I am building a Python Toolbox out of ArcPro 2.5 and setting a MapFrame_Element Camera scale as well, and originally had the Layout Map Frame element with a Display Options Constraint of Fixed Scale. If this was set to Fixed, the python code could not change the scale, but if it was set to None, and I saved the Project (important if you're doing arcpy.mp.ArcGISProject('CURRENT'), it would change the map frame scale from the map frame.

The problem is that there is no indication of this fact. It is very implicit (maybe it should seem obvious) Thank you @ThomasKölbel for making this point evident.

0 Kudos