ArcGIS Pro SDK 内容
内容
项目
创建一个空项目
1 | //Create an empty project. The project will be created in the default folder |
创建具有指定名称的新项目
1 | //Settings used to create a new project |
使用 Pro 的默认设置创建新项目
1 | //Get Pro's default project settings. |
使用自定义模板文件新建项目
1 | //Settings used to create a new project |
使用 ArcGIS Pro 提供的模板创建工程
1 | //Settings used to create a new project |
打开现有项目
1 | //Opens an existing project or project package |
获取当前项目
1 | //Gets the current project |
获取当前项目的位置
1 | //Gets the location of the current project; that is, the path to the current project file (*.aprx) |
获取项目的默认 gdb 路径
1 | var projGDBPath = Project.Current.DefaultGeodatabasePath; |
保存项目
1 | //Saves the project |
检查是否需要保存项目
1 | //The project's dirty state indicates changes made to the project have not yet been saved. |
另存为项目
1 | //Saves a copy of the current project file (*.aprx) to the specified location with the specified file name, |
关闭项目
1 | //A project cannot be closed using the ArcGIS Pro API. |
如何向工程添加新地图
1 | await QueuedTask.Run(() => |
项目项
将文件夹连接项添加到当前项目
1 | //Adding a folder connection |
获取所有项目项
1 | IEnumerable<Item> allProjectItems = Project.Current.GetItems<Item>(); |
获取项目的所有“MapProjectItems”
1 | IEnumerable<MapProjectItem> newMapItemsContainer = project.GetItems<MapProjectItem>(); |
获取特定的“MapProjectItem”
1 | MapProjectItem mapProjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals("EuropeMap")); |
获取所有“样式项目项”
1 | IEnumerable<StyleProjectItem> newStyleItemsContainer = null; |
获取特定的“样式项目项”
1 | var container = Project.Current.GetItems<StyleProjectItem>(); |
获取“收藏夹”样式项目项
1 | var fav_style_item = await QueuedTask.Run(() => |
获取所有“GDBProjectItems”
1 | IEnumerable<GDBProjectItem> newGDBItemsContainer = null; |
获取特定的“GDBProjectItem”
1 | GDBProjectItem GDBProjItem = Project.Current.GetItems<GDBProjectItem>().FirstOrDefault(item => item.Name.Equals("myGDB")); |
获取所有“服务器连接项目项”
1 | IEnumerable<ServerConnectionProjectItem> newServerConnections = null; |
获取特定的“服务器连接项目项”
1 | ServerConnectionProjectItem serverProjItem = Project.Current.GetItems<ServerConnectionProjectItem>().FirstOrDefault(item => item.Name.Equals("myServer")); |
获取项目中的所有文件夹连接
1 | //Gets all the folder connections in the current project |
获取特定文件夹连接
1 | //Gets a specific folder connection in the current project |
删除特定文件夹连接
1 | // Remove a folder connection from a project; the folder stored on the local disk or the network is not deleted |
获取特定的“布局项目项”
1 | LayoutProjectItem layoutProjItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("myLayout")); |
获取项目中的所有布局
1 | //Gets all the layouts in the current project |
获取特定的“地理处理项目项”
1 | GeoprocessingProjectItem GPProjItem = Project.Current.GetItems<GeoprocessingProjectItem>().FirstOrDefault(item => item.Name.Equals("myToolbox")); |
获取工程中的所有地理处理工程项
1 | //Gets all the GeoprocessingProjectItem in the current project |
在项目中搜索特定项目
1 | List<Item> _mxd = new List<Item>(); |
获取默认项目文件夹
1 | //Get Pro's default project settings. |
刷新文件夹连接项的子项
1 | var contentItem = Project.Current.GetItems<FolderConnectionProjectItem>().First(); |
获取项目类别
1 | // Get the ItemCategories with which an item is associated |
使用项目类别
1 | // Browse items using an ItemCategory as a filter |
使用模板创建项目
1 | var projectFolder = System.IO.Path.Combine( |
选择项目容器 - 用于 SelectItemAsync
1 | //Use Project.Current.ProjectItemContainers |
项目项:获取项或查找项
1 | //GetItems searches project content |
在目录窗格中选择一个项目
1 | //Get the catalog pane |
地理数据库内容
浏览对话框中的地理数据库内容
1 | var openDlg = new OpenItemDialog |
目录中的地理数据库内容
1 | // subscribe to event |
收藏 夹
添加收藏夹 - 文件夹
1 | var itemFolder = ItemFactory.Instance.Create(@"d:\data"); |
插入收藏夹 - 地理数据库路径
1 | string gdbPath = "@C:\\myDataFolder\\myData.gdb"; |
添加收藏夹 - 设置项目项的样式
1 | StyleProjectItem styleItem = Project.Current.GetItems<StyleProjectItem>(). |
切换标志是添加到所有新项目为收藏夹
1 | var itemFolder = ItemFactory.Instance.Create(@"d:\data"); |
获取收藏夹集并迭代
1 | var favorites = FavoritesManager.Current.GetFavorites(); |
删除所有收藏夹
1 | var favorites = FavoritesManager.Current.GetFavorites(); |
收藏夹更改事件
1 | ArcGIS.Desktop.Core.Events.FavoritesChangedEvent.Subscribe((args) => |
元数据
项目:获取其 IMetadata 接口
1 | Item gdbItem = ItemFactory.Instance.Create(@"C:\projectAlpha\GDBs\regionFive.gdb"); |
项目:获取项目的元数据:获取XML
1 | string gdbXMLMetadataXmlAsString = string.Empty; |
项目:设置项目的元数据:设置XML项
1 | await QueuedTask.Run(() => |
项目:检查元数据是否可以编辑:可以编辑
1 | bool canEdit1; |
项目:使用项目的当前属性更新元数据:同步
1 | string syncedMetadataXml = string.Empty; |
项目:从源项目的元数据复制元数据:复制元数据从项目
1 | Item featureClassItem = ItemFactory.Instance.Create(@"C:\projectAlpha\GDBs\regionFive.gdb\SourceFeatureClass"); |
项目:从当前项目的元数据中删除某些内容:删除元数据内容
1 | Item featureClassWithMetadataItem = ItemFactory.Instance.Create(@"C:\projectBeta\GDBs\regionFive.gdb\SourceFeatureClass"); |
项目:使用导入的元数据更新元数据 - 输入路径可以是包含元数据的项目的路径,也可以是 XML 文件的 URI:导入元数据
1 | // the input path can be the path to an item with metadata, or a URI to an XML file |
项目:使用导入的元数据更新元数据:导入元数据
1 | // the input path can be the path to an item with metadata, or a URI to an XML file |
项目:导出当前选定项目的元数据:导出元数据
1 | await QueuedTask.Run(() => metadataItemExport1.ExportMetadata(@"E:\Temp\OutputXML.xml", MDImportExportOption.esriCurrentMetadataStyle, MDExportRemovalOption.esriExportExactCopy)); |
项目:导出当前选定项目的元数据:导出元数据
1 | await QueuedTask.Run(() => metadataItemExport2.ExportMetadata(@"E:\Temp\OutputXML.xml", MDImportExportOption.esriCustomizedStyleSheet, MDExportRemovalOption.esriExportExactCopy, @"E:\StyleSheets\Export\MyExportStyleSheet.xslt")); |
项目:将当前项目的元数据另存为 XML:将元数据另存为 XML
1 | await QueuedTask.Run(() => metadataItemToSaveAsXML.SaveMetadataAsXML(@"E:\Temp\OutputXML.xml", MDSaveAsXMLOption.esriExactCopy)); |
项目:将当前项目的元数据另存为 HTML:将元数据另存为HTML
1 | await QueuedTask.Run(() => metadataItemToSaveAsHTML.SaveMetadataAsHTML(@"E:\Temp\OutputHTML.htm", MDSaveAsHTMLOption.esriCurrentMetadataStyle)); |
项目:使用自定义 XSLT 保存当前项目的元数据:保存元数据作为使用自定义 XSLT
1 | await QueuedTask.Run(() => metadataItemToSaveAsUsingCustomXSLT.SaveMetadataAsUsingCustomXSLT(@"E:\Data\Metadata\CustomXSLT.xsl", @"E:\Temp\OutputXMLCustom.xml")); |
项目:升级当前项目的元数据:升级元数据
1 | var fgdcItem = ItemFactory.Instance.Create(@"C:\projectAlpha\GDBs\testData.gdb"); |
项目单位
获取所有可用单位格式的完整列表
1 | //Must be on the QueuedTask.Run() |
获取当前项目的单位格式列表
1 | //Must be on the QueuedTask.Run() |
获取当前项目的特定单位格式列表
1 | //Must be on the QueuedTask.Run() |
获取当前项目的默认格式列表
1 | //Must be on the QueuedTask.Run() |
获取当前项目的特定默认单位格式
1 | //Must be on the QueuedTask.Run() |
为当前项目设置特定的单位格式列表
1 | //Must be on the QueuedTask.Run() |
设置项目单位格式的默认值
1 | //Must be on the QueuedTask.Run() |
更新项目的单位格式
1 | //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, |
应用选项
获取常规选项
1 | var startMode = ApplicationOptions.GeneralOptions.StartupOption; |
将“常规选项”设置为使用自定义设置
1 | //Set the application to use a custom project, home folder, gdb, and toolbox |
设置常规选项以使用默认值
1 | //Default options can be set regardless of the value of the "companion" |
获取下载选项
1 | var staging = ApplicationOptions.DownloadOptions.StagingLocation; |
设置共享和发布的暂存位置
1 | ApplicationOptions.DownloadOptions.StagingLocation = @"D:\data\staging"; |
设置 PPKX 的下载选项
1 | //Options are mutually exclusive. |
设置解压缩的下载选项其他
1 | //UnpackOther settings control unpacking of anything _other than_ |
设置离线地图的下载选项
1 | //OfflineMaps settings control where map content that is taken |
``
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 WineMonk!
评论