// Get the position and size of the focus map in the layout. IActiveView activeView = ArcMap.Document.ActiveView; // Make sure ArcMap is in layout view if (!(activeView is IPageLayout)) { MessageBox.Show("Please switch to layout view."); return; } // Look at the page layout as a container and loop through all the elements. IGraphicsContainer graphicsContainer = activeView as IGraphicsContainer; graphicsContainer.Reset(); IElement element = null; while ((element = graphicsContainer.Next()) != null) { // Only work with map frames if (element is IMapFrame) { // Get the map frame's map IMap map = (element as IMapFrame).Map; // Only work with the focus map frame in layout if (map.Equals(ArcMap.Document.FocusMap)) { // Display the map frame's layout position/size // which is in reference to lower left corner. IGeometry geometry = element.Geometry; MessageBox.Show( "Left: " + geometry.Envelope.XMin.ToString() + "\nTop: " + geometry.Envelope.YMax.ToString() + "\nRight: " + geometry.Envelope.XMax.ToString() + "\nBottom: " + geometry.Envelope.YMin.ToString()); } } }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.