AnsweredAssumed Answered

Clipping a data frame causes grid to disappear (10.3)

Question asked by pathw0rk3r on Jan 30, 2016

I have some code which worked in 10.1 but no longer works in 10.3.  Here is the code:

 

        /// <summary>

        /// Clip the map by the supplied geometry.  Put a border around the clipped area.  Update the

        /// map's view to commit the changes.

        /// </summary>

        /// <param name="mapView"></param>

        /// <param name="map"></param>

        /// <param name="clipGeometry"></param>

        private static void  clipTheMap(IActiveView mapView, IMap map, IEnvelope extent, IGeometry clipGeometry)

        {

            // Refresh the map so that the changes are committed.

            ArcMapState.SetActiveView(mapView);

            mapView.Extent = extent;

           

            // Clip the map.

            IMapClipOptions clipOptions = map as IMapClipOptions;

            clipOptions.ClipGridAndGraticules = true;

            clipOptions.ClipType = esriMapClipType.esriMapClipShape;

            clipOptions.ClipGeometry = clipGeometry;

 

 

            // Put a border around the clipped region.

            ISymbolBorder symbolBorder = new SymbolBorderClass() as ISymbolBorder;

            ILineSymbol lineSymbol = new SimpleLineSymbolClass() as ILineSymbol;

            lineSymbol.Width = LegendFormatConstants.PRIMARY_MAP_FRAME_WIDTH;

            lineSymbol.Color = Colours.Black;

            ISimpleLineSymbol simpleLineSymbol = lineSymbol as ISimpleLineSymbol;

            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSInsideFrame;

            symbolBorder.LineSymbol = lineSymbol;

            symbolBorder.CornerRounding = 0;

            clipOptions.ClipBorder = symbolBorder as IBorder;

            mapView.Refresh();

        }

 

Notice that the clipOptions.ClipGridAndGraticules is set to true.  After the code is run, the grids all disappear.  If I open up the properties on the data frame I can see the 'Clip Options' are all set correctly, with the 'Clip Grids and Graticules' checkbox set to true, the 'Clip to shape' option selected, and if I click on the Specify shape I can see the bounds are all correctly set.  If I click on 'Ok' inside the specify shape dialog, and close down the properties, the grid paints fine.  This manual intervention however, is not an option, as the routine is part of an extensive batch processor which generates PDFs of a series of standard maps.

 

I've tried all sorts of cleughs to get the grid back programmatically, (eg. changing the order of the updates, multiple map view refreshes, etc) all to no avail!  Does anyone have any idea how to get around this, or to fix this bug!!  (I also note that there is no way to set the extent to 'Other data frame' given there is no way to set a percentage or to name the reference data frame).

 

This is all very frustrating!!!

Outcomes