Having trouble on disabling the scale option while using ArcGIS pro SDK

673
4
Jump to solution
08-26-2021 02:22 AM
by Anonymous User
Not applicable

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:

ShabinaBano_0-1629968267312.png

 we want to greyed it out(disabled) as below screenshot using C#

expected output:

ShabinaBano_1-1629969292067.png

Thanks in advance!

 

0 Kudos
1 Solution

Accepted Solutions
UmaHarano
Esri Regular Contributor

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);
        
      });

  

View solution in original post

4 Replies
Wolf
by Esri Regular Contributor
Esri Regular Contributor

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?

Wolf_0-1629992833065.png

 

0 Kudos
by Anonymous User
Not applicable

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.

0 Kudos
UmaHarano
Esri Regular Contributor

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);
        
      });

  

by Anonymous User
Not applicable

Hi @UmaHarano,

It worked like a miracle for me, much appreciated.

Thanks 🙂

0 Kudos