ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / BasicFeatureLayer Class / GetDrawingOutline Method
Object id of the feature to lookup
The viewer whose current reference scale will be used
The type of outline to be generated
Example

In This Topic
    GetDrawingOutline Method
    In This Topic
    Get the outline geometry for the corresponding feature identified by the object id. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public Geometry GetDrawingOutline( 
       long oid,
       MapView view,
       DrawingOutlineType outlineType
    )
    Public Function GetDrawingOutline( _
       ByVal oid As Long, _
       ByVal view As MapView, _
       ByVal outlineType As DrawingOutlineType _
    ) As Geometry

    Parameters

    oid
    Object id of the feature to lookup
    view
    The viewer whose current reference scale will be used
    outlineType
    The type of outline to be generated

    Return Value

    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    MapView is null
    Unsupported geometry type
    GetDrawingOutline supported in 2D only
    Remarks
    GetDrawingOutline is supported for 2D map views only. The view must be initialized or null will be returned. The returned geometry outline for points, lines, and polygons takes into consideration the current view extent (2D) and current map reference scale. If there is no map reference scale set then the current mapscale is used. For annotation the annotation reference scale is used.
    For Polygon and Polyline geometry features the output outline will always be Exact. The outlineType parameter is ignored.
    Multipatch geometry type is not supported.
    Example
    Get the Mask Geometry for a Feature
    var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList()
                               .OfType<BasicFeatureLayer>().FirstOrDefault();
    if (featureLayer == null)
      return;
    
    var mv = MapView.Active;
    
    QueuedTask.Run(() =>
    {
      using (var table = featureLayer.GetTable())
      {
        using (var rc = table.Search())
        {
          //get the first feature...
          //...assuming at least one feature gets retrieved
          rc.MoveNext();
          var oid = rc.Current.GetObjectID();
    
          //Use DrawingOutlineType.BoundingEnvelope to retrieve a generalized
          //mask geometry or "Box". The mask will be in the same SpatRef as the map
          //At 2.x - var mask_geom = featureLayer.QueryDrawingOutline(oid, mv, DrawingOutlineType.Exact);
          var mask_geom = featureLayer.GetDrawingOutline(oid, mv, DrawingOutlineType.Exact);
    
          //TODO - use the mask geometry...
        }
      }
    });
    Get the Mask Geometry for an Annotation
    var annoLayer = MapView.Active.Map.GetLayersAsFlattenedList()
                             .OfType<AnnotationLayer>().FirstOrDefault();
    if (annoLayer == null)
        return;
    var mv = MapView.Active;
    
    QueuedTask.Run(() =>
    {
        //get the first annotation feature...
        //...assuming at least one feature gets selected
        using (var fc = annoLayer.GetFeatureClass())
        {
            using (var rc = fc.Search())
            {
                rc.MoveNext();
                using (var row = rc.Current)
                {
                    var oid = row.GetObjectID();
    
                    //Use DrawingOutlineType.BoundingEnvelope to retrieve a generalized
                    //mask geometry or "Box". The mask will be in the same SpatRef as the map.
                    //The mask will be constructed using the anno class reference scale
                    //At 2.x - var mask_geom = annoLayer.QueryDrawingOutline(oid, mv, DrawingOutlineType.Exact);
    
                    var mask_geom = annoLayer.GetDrawingOutline(oid, mv, DrawingOutlineType.Exact);
                }
            }
        }
    });
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also