Tuesday, March 10, 2015

Draw features in ArcMap using ArcGIS Addin tool (Arcobject's IRubberband Interface)

 protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)  
 {  
      //create geometery  
      if (ArcMap.Document != null)  
      {  
           IScreenDisplay screenDisplay = ArcMap.Document.ActiveView.ScreenDisplay;  
           // Constants  
           screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)esriScreenCache.esriNoScreenCache);  
           // Explicit Cast  
           IRgbColor rgbColor = new RgbColorClass();  
           rgbColor.Red = 255;  
           rgbColor.Transparency = 75;  
           IColor color = rgbColor; // Implicit Cast  
           ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();  
           simpleFillSymbol.Color = color;  
           //Draw geometry  
           ISymbol symbol = simpleFillSymbol as ISymbol; // Dynamic Cast  
           IRubberBand rubberBand = new RubberPolygonClass();  
           IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol);  
           //check for valid geometery  
           if (geometry != null)  
           {  
                screenDisplay.SetSymbol(symbol);  
                screenDisplay.DrawPolygon(geometry);  
                screenDisplay.FinishDrawing();  
                //Open addattributes wpf form  
                AddAtrributesView addAtrributesView = new AddAtrributesView(geometry);  
                addAtrributesView.ShowInTaskbar = false;  
                addAtrributesView.ShowDialog();  
                ArcMap.Document.ActivatedView.Refresh();  
           }  
      }       
 }  

arcobject , C#

0 comments :

Post a Comment

 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me