public class ItemFactory : IItemFactory
Public Class ItemFactory Implements IItemFactory
public class ItemFactory : IItemFactory
Public Class ItemFactory Implements IItemFactory
/// Import a mxd Item mxdToImport = ItemFactory.Instance.Create(@"C:\Projects\RegionalSurvey\LatestResults.mxd"); var addedMxd = await QueuedTask.Run( () => Project.Current.AddItem(mxdToImport as IProjectItem)); /// Add map package Item mapPackageToAdd = ItemFactory.Instance.Create(@"c:\Data\Map.mpkx"); var addedMapPackage = await QueuedTask.Run( () => Project.Current.AddItem(mapPackageToAdd as IProjectItem)); /// Add an exported Pro map Item proMapToAdd = ItemFactory.Instance.Create(@"C:\ExportedMaps\Election\Districts.mapx"); var addedMapProjectItem = await QueuedTask.Run( () => Project.Current.AddItem(proMapToAdd as IProjectItem));
//Adding a folder connection string folderPath = "@C:\\myDataFolder"; var folder = await QueuedTask.Run(() => { //Create the folder connection project item var item = ItemFactory.Instance.Create(folderPath) as IProjectItem; //If it is successfully added to the project, return it otherwise null return Project.Current.AddItem(item) ? item as FolderConnectionProjectItem : null; }); //Adding a Geodatabase: string gdbPath = "@C:\\myDataFolder\\myData.gdb"; var newlyAddedGDB = await QueuedTask.Run(() => { //Create the File GDB project item var item = ItemFactory.Instance.Create(gdbPath) as IProjectItem; //If it is successfully added to the project, return it otherwise null return Project.Current.AddItem(item) ? item as GDBProjectItem : null; });
//Import a pagx into a project. //Create a layout project item from importing a pagx file await QueuedTask.Run(() => { IProjectItem pagx = ItemFactory.Instance.Create( @"C:\Temp\Layout.pagx") as IProjectItem; Project.Current.AddItem(pagx); });
//Note: Call within QueuedTask.Run() Item reportToImport = ItemFactory.Instance.Create(reportFile); Project.Current.AddItem(reportToImport as IProjectItem);
System.Object
ArcGIS.Desktop.Core.ItemFactory
Target Platforms: Windows 11, Windows 10