ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / IMapFactory Interface / CanConvertMapFromItem Method
The map item to test
The type to convert the map item to
Example

In This Topic
    CanConvertMapFromItem Method (IMapFactory)
    In This Topic
    Determines whether the map item can be converted to the specified output type. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Function CanConvertMapFromItem( _
       ByVal mapItem As MapProjectItem, _
       ByVal convertTo As MapConversionType _
    ) As Boolean

    Parameters

    mapItem
    The map item to test
    convertTo
    The type to convert the map item to

    Return Value

    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    The following conversions are supported (the map referenced by the map item is tested): o Map -> Base map, Scene (Global), Scene (Local)
    o BaseMap -> Map
    o Scene (Global) -> Map
    o Scene (Local) -> Map
    Specifying an invalid conversion type will return false
    Note: If MapConversionType.SceneGlobal is specified, if the map item's map spatial reference contains a vertical coordinate system, the VCS is checked to see if it is compatible with a global scene. If it is not, the method will also return false
    Example
    How to access Geoprocessing History
    {
      string openProjectPath = @"D\DATA\IGPHistoryItemTestProject\IGPHistoryItemTestProject.aprx";
      Project.OpenAsync(openProjectPath);
      MapProjectItem mapProjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map", StringComparison.CurrentCultureIgnoreCase));
    
      // Note: Needs QueuedTask to run
      var map = mapProjItem.GetMap();
      var ftrLayer = map.Layers[0] as FeatureLayer;
      string tool1 = "management.GetCount";
      var args1 = Geoprocessing.MakeValueArray(ftrLayer);
      var env = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true);
      GPExecuteToolFlags executeFlags = GPExecuteToolFlags.AddToHistory;
      var t = Geoprocessing.ExecuteToolAsync(tool1, args1, env, null, null, executeFlags);
    
      IEnumerable<IGPHistoryItem> hisItems = Project.Current.GetProjectItemContainer(Geoprocessing.HistoryContainerKey) as IEnumerable<IGPHistoryItem>;
    
      string hitemID = "";
      string hitemToolPath = "";
      IGPResult hitemGPResult = null;
      DateTime hitemTimeStamp;
    
      foreach (var hitem in hisItems)
      {
        // common IGPHistoryItem and Item properties
        hitemID = (hitem as Item).ID;
        hitemToolPath = hitem.ToolPath;
        hitemGPResult = hitem.GPResult;
        hitemTimeStamp = hitem.TimeStamp;
    
        // use the properties as needed
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also