Hi,
We'd like to disable the scaling option in ArcGIS Pro, but we're not sure how to do so using the SDK. Before generating the sheets in layout view, we must disable the scale option to prevent further scale edits in MapFrame from occurring. Is there a method to use that I'm not aware of?
Currently the scale option is editable as shown below
current output:
we want to greyed it out(disabled) as below screenshot using C#
expected output:
Thanks in advance!
Solved! Go to Solution.
To disable or "lock in" the scale for a MapFrame in a Layout, the CIM definition of the Layout Map Frame has to be configured. CIM is Pro's Cartographic Information Model.
The code snippet below illustrates this. I get the Camera and Extent of the MapView associated with the Map Frame. The Map Frame is then "locked" to this scale.
QueuedTask.Run( () => {
var layoutMapFrame = LayoutView.Active.ActiveMapFrame;
//Get the CIM Definition of the Map Frame
var cimMapFrame = layoutMapFrame.GetDefinition() as CIMMapFrame;
//Get the Camera and Extent properties on the associated Map View of the map frame.
var mapView = layoutMapFrame.GetMapView(LayoutView.Active);
var mapViewCamera = mapView.Camera;
var mapViewExtent = mapView.Extent;
//Create a new CIMAutoCamera
//using the mapview's camera and extent.
//Create CIMViewCamera first.
//This is used in the CIMAutoCamera
var cimViewCamera = new CIMViewCamera
{
Heading = mapViewCamera.Heading,
Pitch = mapViewCamera.Pitch,
Roll = mapViewCamera.Roll,
Scale = mapViewCamera.Scale,
ViewportHeight = mapViewCamera.ViewportHeight,
ViewportWidth = mapViewCamera.ViewportWidth,
X = mapViewCamera.X,
Y = mapViewCamera.Y,
Z = mapViewCamera.Z
};
//Create CIMAutoCamera
var autoCamera = new CIMAutoCamera
{
Camera = cimViewCamera,
Extent = mapViewExtent,
AutoCameraType = AutoCameraType.Scale,
Source = AutoCameraSource.Fixed,
SyncRotation = true
};
//Set the MapFrame's auto camera to the new CIMAutoCamera
cimMapFrame.AutoCamera = autoCamera;
//Set the CIM Definition
layoutMapFrame.SetDefinition(cimMapFrame);
});
Do you want to 'lock in' a single fixed scale on you map display so that the map view only allows a that scale and hence all user zoom in/out actions as disabled? As if you were configuring a single scale option and checking the 'only display this scale' option?
Hi @Wolf Yes you got it right, I want to 'lock in' a single fixed scale on my layout view so that it will only allows that scale and hence all user zoom in/out actions will disabled.
Suppose at the time of sheet generation the scale is 1:6000 (coming from the database), so the user should be unable to change the scale to 1:500 or whatever scale he desires, and the scale customization option should be disabled.
To disable or "lock in" the scale for a MapFrame in a Layout, the CIM definition of the Layout Map Frame has to be configured. CIM is Pro's Cartographic Information Model.
The code snippet below illustrates this. I get the Camera and Extent of the MapView associated with the Map Frame. The Map Frame is then "locked" to this scale.
QueuedTask.Run( () => {
var layoutMapFrame = LayoutView.Active.ActiveMapFrame;
//Get the CIM Definition of the Map Frame
var cimMapFrame = layoutMapFrame.GetDefinition() as CIMMapFrame;
//Get the Camera and Extent properties on the associated Map View of the map frame.
var mapView = layoutMapFrame.GetMapView(LayoutView.Active);
var mapViewCamera = mapView.Camera;
var mapViewExtent = mapView.Extent;
//Create a new CIMAutoCamera
//using the mapview's camera and extent.
//Create CIMViewCamera first.
//This is used in the CIMAutoCamera
var cimViewCamera = new CIMViewCamera
{
Heading = mapViewCamera.Heading,
Pitch = mapViewCamera.Pitch,
Roll = mapViewCamera.Roll,
Scale = mapViewCamera.Scale,
ViewportHeight = mapViewCamera.ViewportHeight,
ViewportWidth = mapViewCamera.ViewportWidth,
X = mapViewCamera.X,
Y = mapViewCamera.Y,
Z = mapViewCamera.Z
};
//Create CIMAutoCamera
var autoCamera = new CIMAutoCamera
{
Camera = cimViewCamera,
Extent = mapViewExtent,
AutoCameraType = AutoCameraType.Scale,
Source = AutoCameraSource.Fixed,
SyncRotation = true
};
//Set the MapFrame's auto camera to the new CIMAutoCamera
cimMapFrame.AutoCamera = autoCamera;
//Set the CIM Definition
layoutMapFrame.SetDefinition(cimMapFrame);
});