Sub ClipMapWithGraphic() Dim pMxDocument As IMxDocument Dim pMap As IMap Dim pViewManager As IViewManager Dim pEnumElement As IEnumElement Dim pElement As IElement Dim pActiveView As IActiveView Dim pBorder As IBorder Dim mco As IMapClipOptions Set pMxDocument = Application.Document Set pMap = pMxDocument.FocusMap Set pViewManager = pMap Set pEnumElement = pViewManager.ElementSelection pEnumElement.Reset Set pElement = pEnumElement.Next If pElement Is Nothing Then MsgBox "No element selected" Exit Sub End If If pElement.Geometry.GeometryType = esriGeometryPolygon Then Set pBorder = New SymbolBorder 'Use default line symbol Set mco = pMap mco.ClipType = esriMapClipMapExtent pMap.ClipBorder = pBorder pMap.ClipGeometry = pElement.Geometry Set pActiveView = pMap pActiveView.Refresh End If End Sub
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.