From fdd10571d2badfda0c9b71d645df6f796de3bcc1 Mon Sep 17 00:00:00 2001 From: Wolf Date: Thu, 27 Oct 2022 08:25:56 -0700 Subject: [PATCH] ArcGIS Pro SDK 3.0 SDK for .NET --- CoreHost/CoreHostGDB/CoreHostGDB (C#).md | 47 + CoreHost/CoreHostGDB/ReadMe.md | 47 + .../CoreHostResolveAssembly (C#).md | 51 + CoreHost/CoreHostResolveAssembly/ReadMe.md | 51 + .../CoreHostSample/CoreHostSample (C#).md | 50 + CoreHost/CoreHostSample/ReadMe.md | 50 + .../CoreHostTopologyAPI (C#).md | 45 + CoreHost/CoreHostTopologyAPI/ReadMe.md | 45 + CoreHost/ReadMe.md | 4 + Editing/COGOLineFeatures/ReadMe.md | 6 +- .../ExportDiagramToFeatureClasses/Config.daml | 38 + .../CustomField.cs | 417 ++ .../DarkImages/AddInDesktop16.png | Bin 0 -> 1314 bytes .../DarkImages/AddInDesktop32.png | Bin 0 -> 1744 bytes .../ExportDiagramToFeatureClasses16.png | Bin 0 -> 679 bytes .../ExportDiagramToFeatureClasses32.png | Bin 0 -> 885 bytes .../ExportDiagramToFeatureClasses (C#) .md | 59 + .../ExportDiagramToFeatureClasses (C#).md | 82 + .../ExportDiagramToFeatureClasses.csproj | 108 + .../ExportDiagramToFeatureClasses.sln | 25 + .../ExportDiagramToFeatureClassesModule.cs | 376 ++ .../ExportPane.xaml | 134 + .../ExportPane.xaml.cs | 29 + .../ExportPaneViewModel.cs | 3659 +++++++++++++++++ .../Images/AddInDesktop16.png | Bin 0 -> 524 bytes .../Images/AddInDesktop32.png | Bin 0 -> 948 bytes .../ExportDiagramToFeatureClasses16.png | Bin 0 -> 740 bytes .../ExportDiagramToFeatureClasses32.png | Bin 0 -> 885 bytes .../Properties/launchSettings.json | 8 + .../ExportDiagramToFeatureClasses/ReadMe.md | 82 + .../ExportDiagramToFeatureClassesButton.png | Bin 0 -> 11371 bytes ...portDiagramToFeatureClassesPaneWindow1.png | Bin 0 -> 11357 bytes ...portDiagramToFeatureClassesPaneWindow2.png | Bin 0 -> 37809 bytes ...portDiagramToFeatureClassesPaneWindow3.png | Bin 0 -> 14970 bytes ...ortDiagramToFeatureClasses_AddedToAMap.png | Bin 0 -> 78138 bytes ...ExportDiagramToFeatureClasses_OutputFC.png | Bin 0 -> 16081 bytes NetworkDiagram/ReadMe.md | 1 + .../ImportPlatToFabric (C#).md | 4 +- ParcelFabric/ImportPlatToFabric/ReadMe.md | 4 +- README.md | 8 +- Samples.sln | 10 + UtilityNetwork/README.md | 1 + UtilityNetwork/TraceNetworkSample/ReadMe.md | 45 + .../TraceNetworkSample (C#).md | 45 + 44 files changed, 5523 insertions(+), 8 deletions(-) create mode 100644 CoreHost/CoreHostGDB/CoreHostGDB (C#).md create mode 100644 CoreHost/CoreHostGDB/ReadMe.md create mode 100644 CoreHost/CoreHostResolveAssembly/CoreHostResolveAssembly (C#).md create mode 100644 CoreHost/CoreHostResolveAssembly/ReadMe.md create mode 100644 CoreHost/CoreHostSample/CoreHostSample (C#).md create mode 100644 CoreHost/CoreHostSample/ReadMe.md create mode 100644 CoreHost/CoreHostTopologyAPI/CoreHostTopologyAPI (C#).md create mode 100644 CoreHost/CoreHostTopologyAPI/ReadMe.md create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Config.daml create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/CustomField.cs create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/AddInDesktop16.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/AddInDesktop32.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/ExportDiagramToFeatureClasses16.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/ExportDiagramToFeatureClasses32.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses (C#) .md create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses (C#).md create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses.csproj create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses.sln create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClassesModule.cs create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/ExportPane.xaml create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/ExportPane.xaml.cs create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/ExportPaneViewModel.cs create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Images/AddInDesktop16.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Images/AddInDesktop32.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Images/ExportDiagramToFeatureClasses16.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Images/ExportDiagramToFeatureClasses32.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Properties/launchSettings.json create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/ReadMe.md create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Screenshots/ExportDiagramToFeatureClassesButton.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Screenshots/ExportDiagramToFeatureClassesPaneWindow1.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Screenshots/ExportDiagramToFeatureClassesPaneWindow2.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Screenshots/ExportDiagramToFeatureClassesPaneWindow3.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Screenshots/ExportDiagramToFeatureClasses_AddedToAMap.png create mode 100644 NetworkDiagram/ExportDiagramToFeatureClasses/Screenshots/ExportDiagramToFeatureClasses_OutputFC.png create mode 100644 UtilityNetwork/TraceNetworkSample/ReadMe.md create mode 100644 UtilityNetwork/TraceNetworkSample/TraceNetworkSample (C#).md diff --git a/CoreHost/CoreHostGDB/CoreHostGDB (C#).md b/CoreHost/CoreHostGDB/CoreHostGDB (C#).md new file mode 100644 index 00000000..f3664993 --- /dev/null +++ b/CoreHost/CoreHostGDB/CoreHostGDB (C#).md @@ -0,0 +1,47 @@ +## CoreHostGDB + + +WPF application that implements a generic File GDB reader + + + +View it live + + +``` +Language: C# +Subject: Console +Contributor: ArcGIS Pro SDK Team +Organization: Esri, https://www.esri.com +Date: 06/10/2022 +ArcGIS Pro: 3.0 +Visual Studio: 2022 +.NET Target Framework: 4.6.1 +``` + +## Resources + +[Community Sample Resources](https://github.com/Esri/arcgis-pro-sdk-community-samples#resources) + +### Samples Data + +* Sample data for ArcGIS Pro SDK Community Samples can be downloaded from the [Releases](https://github.com/Esri/arcgis-pro-sdk-community-samples/releases) page. + +## How to use the sample + +1. Open this solution in Visual Studio +1. Click the build menu and select Build Solution. +1. Click the Start button to run the WPF app. +1. Specify a valid path to a file geodatabase path in the 'Open a GDB' input field and click the 'Open' button. +1. The 'Open a Dataset' dropdown is filled with all available datasets. +1. Select a dataset on the 'Open a Dataset' dropdown and click the 'Read' button. +1. View the table showing the dataset's content. +![UI](Screenshots/Screen.png) + + + + + +      ArcGIS Pro SDK for Microsoft .NET Framework +             +[Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](https://github.com/Esri/arcgis-pro-sdk/wiki#requirements) | [Download](https://github.com/Esri/arcgis-pro-sdk/wiki#installing-arcgis-pro-sdk-for-net) | Samples diff --git a/CoreHost/CoreHostGDB/ReadMe.md b/CoreHost/CoreHostGDB/ReadMe.md new file mode 100644 index 00000000..f3664993 --- /dev/null +++ b/CoreHost/CoreHostGDB/ReadMe.md @@ -0,0 +1,47 @@ +## CoreHostGDB + + +WPF application that implements a generic File GDB reader + + + +View it live + + +``` +Language: C# +Subject: Console +Contributor: ArcGIS Pro SDK Team +Organization: Esri, https://www.esri.com +Date: 06/10/2022 +ArcGIS Pro: 3.0 +Visual Studio: 2022 +.NET Target Framework: 4.6.1 +``` + +## Resources + +[Community Sample Resources](https://github.com/Esri/arcgis-pro-sdk-community-samples#resources) + +### Samples Data + +* Sample data for ArcGIS Pro SDK Community Samples can be downloaded from the [Releases](https://github.com/Esri/arcgis-pro-sdk-community-samples/releases) page. + +## How to use the sample + +1. Open this solution in Visual Studio +1. Click the build menu and select Build Solution. +1. Click the Start button to run the WPF app. +1. Specify a valid path to a file geodatabase path in the 'Open a GDB' input field and click the 'Open' button. +1. The 'Open a Dataset' dropdown is filled with all available datasets. +1. Select a dataset on the 'Open a Dataset' dropdown and click the 'Read' button. +1. View the table showing the dataset's content. +![UI](Screenshots/Screen.png) + + + + + +      ArcGIS Pro SDK for Microsoft .NET Framework +             +[Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](https://github.com/Esri/arcgis-pro-sdk/wiki#requirements) | [Download](https://github.com/Esri/arcgis-pro-sdk/wiki#installing-arcgis-pro-sdk-for-net) | Samples diff --git a/CoreHost/CoreHostResolveAssembly/CoreHostResolveAssembly (C#).md b/CoreHost/CoreHostResolveAssembly/CoreHostResolveAssembly (C#).md new file mode 100644 index 00000000..e2388225 --- /dev/null +++ b/CoreHost/CoreHostResolveAssembly/CoreHostResolveAssembly (C#).md @@ -0,0 +1,51 @@ +## CoreHostResolveAssembly + + +This sample illustrates how to deploy a standalone CoreHost application that resolves the ArcGIS Pro location in order to load the dependent assemblies such as ArcGIS.Core.dll and ArcGIS.CoreHost.dll from the ArcGIS Pro install location. +Except for the dynamic assembly loading logic this sample is identical to the "CoreHostSample". +The references to ArcGIS.Core.dll and ArcGIS.CoreHost.dll in Visual Studio have the "Copy Local" property set to "false". + + + +View it live + + +``` +Language: C# +Subject: Console +Contributor: ArcGIS Pro SDK Team +Organization: Esri, https://www.esri.com +Date: 06/10/2022 +ArcGIS Pro: 3.0 +Visual Studio: 2022 +.NET Target Framework: 4.6.1 +``` + +## Resources + +[Community Sample Resources](https://github.com/Esri/arcgis-pro-sdk-community-samples#resources) + +### Samples Data + +* Sample data for ArcGIS Pro SDK Community Samples can be downloaded from the [Releases](https://github.com/Esri/arcgis-pro-sdk-community-samples/releases) page. + +## How to use the sample + +1. Download the Community Sample data (see under the "Resources" section for downloading sample data). Make sure that the Sample data is unzipped in c:\data and "C:\Data\SDK\SDK.gdb" is available. +1. Open this solution in Visual Studio +1. Click the build menu and select Build Solution. +1. Specify a valid path to a file geodatabase as your debug command line parameter +1. Click the Start button to run the console app. +1. Note that the AppDomain is modified on startup to resolve the Assembly Paths for ArcGIS.Core.dll and ArcGIS.CoreHost.dll by using the ArcGIS Pro installation location. +1. View the table definition in your file geodatabase +![UI](Screenshots/ConsoleWindow.png) + +1. Once the output stops press any key to close the application. + + + + + +      ArcGIS Pro SDK for Microsoft .NET Framework +             +[Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](https://github.com/Esri/arcgis-pro-sdk/wiki#requirements) | [Download](https://github.com/Esri/arcgis-pro-sdk/wiki#installing-arcgis-pro-sdk-for-net) | Samples diff --git a/CoreHost/CoreHostResolveAssembly/ReadMe.md b/CoreHost/CoreHostResolveAssembly/ReadMe.md new file mode 100644 index 00000000..e2388225 --- /dev/null +++ b/CoreHost/CoreHostResolveAssembly/ReadMe.md @@ -0,0 +1,51 @@ +## CoreHostResolveAssembly + + +This sample illustrates how to deploy a standalone CoreHost application that resolves the ArcGIS Pro location in order to load the dependent assemblies such as ArcGIS.Core.dll and ArcGIS.CoreHost.dll from the ArcGIS Pro install location. +Except for the dynamic assembly loading logic this sample is identical to the "CoreHostSample". +The references to ArcGIS.Core.dll and ArcGIS.CoreHost.dll in Visual Studio have the "Copy Local" property set to "false". + + + +View it live + + +``` +Language: C# +Subject: Console +Contributor: ArcGIS Pro SDK Team +Organization: Esri, https://www.esri.com +Date: 06/10/2022 +ArcGIS Pro: 3.0 +Visual Studio: 2022 +.NET Target Framework: 4.6.1 +``` + +## Resources + +[Community Sample Resources](https://github.com/Esri/arcgis-pro-sdk-community-samples#resources) + +### Samples Data + +* Sample data for ArcGIS Pro SDK Community Samples can be downloaded from the [Releases](https://github.com/Esri/arcgis-pro-sdk-community-samples/releases) page. + +## How to use the sample + +1. Download the Community Sample data (see under the "Resources" section for downloading sample data). Make sure that the Sample data is unzipped in c:\data and "C:\Data\SDK\SDK.gdb" is available. +1. Open this solution in Visual Studio +1. Click the build menu and select Build Solution. +1. Specify a valid path to a file geodatabase as your debug command line parameter +1. Click the Start button to run the console app. +1. Note that the AppDomain is modified on startup to resolve the Assembly Paths for ArcGIS.Core.dll and ArcGIS.CoreHost.dll by using the ArcGIS Pro installation location. +1. View the table definition in your file geodatabase +![UI](Screenshots/ConsoleWindow.png) + +1. Once the output stops press any key to close the application. + + + + + +      ArcGIS Pro SDK for Microsoft .NET Framework +             +[Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](https://github.com/Esri/arcgis-pro-sdk/wiki#requirements) | [Download](https://github.com/Esri/arcgis-pro-sdk/wiki#installing-arcgis-pro-sdk-for-net) | Samples diff --git a/CoreHost/CoreHostSample/CoreHostSample (C#).md b/CoreHost/CoreHostSample/CoreHostSample (C#).md new file mode 100644 index 00000000..e5a7b9fe --- /dev/null +++ b/CoreHost/CoreHostSample/CoreHostSample (C#).md @@ -0,0 +1,50 @@ +## CoreHostSample + + +ArcGIS Pro based console application reading from File Geodatabase + + + +View it live + + +``` +Language: C# +Subject: Console +Contributor: ArcGIS Pro SDK Team +Organization: Esri, https://www.esri.com +Date: 06/10/2022 +ArcGIS Pro: 3.0 +Visual Studio: 2022 +.NET Target Framework: 4.6.1 +``` + +## Resources + +[Community Sample Resources](https://github.com/Esri/arcgis-pro-sdk-community-samples#resources) + +### Samples Data + +* Sample data for ArcGIS Pro SDK Community Samples can be downloaded from the [Releases](https://github.com/Esri/arcgis-pro-sdk-community-samples/releases) page. + +## How to use the sample + +1. Download the Community Sample data (see under the "Resources" section for downloading sample data). Make sure that the Sample data is unzipped in c:\data and "C:\Data\SDK\SDK.gdb" is available. +1. Open this solution in Visual Studio +1. Click the build menu and select Build Solution. +1. Specify a valid path to a file geodatabase as your debug command line parameter +1. Click the Start button to run the console app. +1. View the table definition in your file geodatabase +![UI](Screenshots/ConsoleWindow.png) + +1. Once the output stops press any key to close the application. +1. To reuse the ArcGIS Pro assemblies from the installation path, you can change the reference settings for +ArcGIS.Core.dll and ArcGIS.CoreHost.dll to be "Copy Local = False". + + + + + +      ArcGIS Pro SDK for Microsoft .NET Framework +             +[Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](https://github.com/Esri/arcgis-pro-sdk/wiki#requirements) | [Download](https://github.com/Esri/arcgis-pro-sdk/wiki#installing-arcgis-pro-sdk-for-net) | Samples diff --git a/CoreHost/CoreHostSample/ReadMe.md b/CoreHost/CoreHostSample/ReadMe.md new file mode 100644 index 00000000..e5a7b9fe --- /dev/null +++ b/CoreHost/CoreHostSample/ReadMe.md @@ -0,0 +1,50 @@ +## CoreHostSample + + +ArcGIS Pro based console application reading from File Geodatabase + + + +View it live + + +``` +Language: C# +Subject: Console +Contributor: ArcGIS Pro SDK Team +Organization: Esri, https://www.esri.com +Date: 06/10/2022 +ArcGIS Pro: 3.0 +Visual Studio: 2022 +.NET Target Framework: 4.6.1 +``` + +## Resources + +[Community Sample Resources](https://github.com/Esri/arcgis-pro-sdk-community-samples#resources) + +### Samples Data + +* Sample data for ArcGIS Pro SDK Community Samples can be downloaded from the [Releases](https://github.com/Esri/arcgis-pro-sdk-community-samples/releases) page. + +## How to use the sample + +1. Download the Community Sample data (see under the "Resources" section for downloading sample data). Make sure that the Sample data is unzipped in c:\data and "C:\Data\SDK\SDK.gdb" is available. +1. Open this solution in Visual Studio +1. Click the build menu and select Build Solution. +1. Specify a valid path to a file geodatabase as your debug command line parameter +1. Click the Start button to run the console app. +1. View the table definition in your file geodatabase +![UI](Screenshots/ConsoleWindow.png) + +1. Once the output stops press any key to close the application. +1. To reuse the ArcGIS Pro assemblies from the installation path, you can change the reference settings for +ArcGIS.Core.dll and ArcGIS.CoreHost.dll to be "Copy Local = False". + + + + + +      ArcGIS Pro SDK for Microsoft .NET Framework +             +[Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](https://github.com/Esri/arcgis-pro-sdk/wiki#requirements) | [Download](https://github.com/Esri/arcgis-pro-sdk/wiki#installing-arcgis-pro-sdk-for-net) | Samples diff --git a/CoreHost/CoreHostTopologyAPI/CoreHostTopologyAPI (C#).md b/CoreHost/CoreHostTopologyAPI/CoreHostTopologyAPI (C#).md new file mode 100644 index 00000000..3340efbb --- /dev/null +++ b/CoreHost/CoreHostTopologyAPI/CoreHostTopologyAPI (C#).md @@ -0,0 +1,45 @@ +## CoreHostTopologyAPI + + +Corehost standalone application shows how to open a Topology dataset and inspect the Topology rules and definitions. + + + +View it live + + +``` +Language: C# +Subject: Console +Contributor: ArcGIS Pro SDK Team +Organization: Esri, https://www.esri.com +Date: 06/10/2022 +ArcGIS Pro: 3.0 +Visual Studio: 2022 +.NET Target Framework: 4.6.1 +``` + +## Resources + +[Community Sample Resources](https://github.com/Esri/arcgis-pro-sdk-community-samples#resources) + +### Samples Data + +* Sample data for ArcGIS Pro SDK Community Samples can be downloaded from the [Releases](https://github.com/Esri/arcgis-pro-sdk-community-samples/releases) page. + +## How to use the sample + +1. Download the Community Sample data (see under the "Resources" section for downloading sample data). Make sure that the Sample data is unzipped in c:\data and "C:\Data\Topology\GrandTeton.gdb" is available. +1. Open this solution in Visual Studio +1. Make sure that the path specified in GRAND_TETON_GDB_FULL_PATH is valid +1. Compile and run the application. +1. View the topology’s metadata output by the sample app using the TopologyDefinition object. +![UI](Screenshots/Screen1.png) + + + + + +      ArcGIS Pro SDK for Microsoft .NET Framework +             +[Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](https://github.com/Esri/arcgis-pro-sdk/wiki#requirements) | [Download](https://github.com/Esri/arcgis-pro-sdk/wiki#installing-arcgis-pro-sdk-for-net) | Samples diff --git a/CoreHost/CoreHostTopologyAPI/ReadMe.md b/CoreHost/CoreHostTopologyAPI/ReadMe.md new file mode 100644 index 00000000..3340efbb --- /dev/null +++ b/CoreHost/CoreHostTopologyAPI/ReadMe.md @@ -0,0 +1,45 @@ +## CoreHostTopologyAPI + + +Corehost standalone application shows how to open a Topology dataset and inspect the Topology rules and definitions. + + + +View it live + + +``` +Language: C# +Subject: Console +Contributor: ArcGIS Pro SDK Team +Organization: Esri, https://www.esri.com +Date: 06/10/2022 +ArcGIS Pro: 3.0 +Visual Studio: 2022 +.NET Target Framework: 4.6.1 +``` + +## Resources + +[Community Sample Resources](https://github.com/Esri/arcgis-pro-sdk-community-samples#resources) + +### Samples Data + +* Sample data for ArcGIS Pro SDK Community Samples can be downloaded from the [Releases](https://github.com/Esri/arcgis-pro-sdk-community-samples/releases) page. + +## How to use the sample + +1. Download the Community Sample data (see under the "Resources" section for downloading sample data). Make sure that the Sample data is unzipped in c:\data and "C:\Data\Topology\GrandTeton.gdb" is available. +1. Open this solution in Visual Studio +1. Make sure that the path specified in GRAND_TETON_GDB_FULL_PATH is valid +1. Compile and run the application. +1. View the topology’s metadata output by the sample app using the TopologyDefinition object. +![UI](Screenshots/Screen1.png) + + + + + +      ArcGIS Pro SDK for Microsoft .NET Framework +             +[Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](https://github.com/Esri/arcgis-pro-sdk/wiki#requirements) | [Download](https://github.com/Esri/arcgis-pro-sdk/wiki#installing-arcgis-pro-sdk-for-net) | Samples diff --git a/CoreHost/ReadMe.md b/CoreHost/ReadMe.md index accce31c..f45e13d0 100644 --- a/CoreHost/ReadMe.md +++ b/CoreHost/ReadMe.md @@ -13,6 +13,10 @@ This repository contains ArcGIS Pro Add-In Samples for the ArcGIS Pro 3.0 SDK fo This folder contains ArcGIS Pro Add-In Samples that fall under the 'Core Host' topic: +* [CoreHostGDB (c#)](../../../tree/master/CoreHost/CoreHostGDB) +* [CoreHostResolveAssembly (c#)](../../../tree/master/CoreHost/CoreHostResolveAssembly) +* [CoreHostSample (c#)](../../../tree/master/CoreHost/CoreHostSample) +* [CoreHostTopologyAPI (c#)](../../../tree/master/CoreHost/CoreHostTopologyAPI) ## Instructions diff --git a/Editing/COGOLineFeatures/ReadMe.md b/Editing/COGOLineFeatures/ReadMe.md index baac61cd..348bc7e3 100644 --- a/Editing/COGOLineFeatures/ReadMe.md +++ b/Editing/COGOLineFeatures/ReadMe.md @@ -33,18 +33,18 @@ Visual Studio: 2022 1. In Pro, add a line layer or a COGO enabled line layer to the map. 1. Click the Edit tab and click Create Features button in the Feature group. 1. Click the line feature template in the Create Features pane, and click the COGO Line tool. -![UI](Screenshots/Screen01.png) +![UI] (Screenshots/Screen01.png) 1. Snap to or click in the map for the first point of the COGO line, then snap to or click in the map for the second point. 1. The COGO line dialog shows the measured Direction and Distance values. -![UI](Screenshots/Screen02.png) +![UI] (Screenshots/Screen02.png) 1. Change the values as needed to match the source document; these are usually small changes to the numbers. 1. The first Direction entry box has the focus, you can press the Enter key to move the focus to the Distance field, and press Enter again to create the line. 1. The check box "Hold end point position" is turned on by default. Uncheck the box to have the end point location updated based on changed values. 1. You can type a negative distance to reverse the direction of the line. 1. To create the line you can click the OK button, or you can press Enter when in the Distance entry field. The dialog will automatically close. -![UI](Screenshots/Screen03.png) +![UI] (Screenshots/Screen03.png) diff --git a/NetworkDiagram/ExportDiagramToFeatureClasses/Config.daml b/NetworkDiagram/ExportDiagramToFeatureClasses/Config.daml new file mode 100644 index 00000000..8abe5a4e --- /dev/null +++ b/NetworkDiagram/ExportDiagramToFeatureClasses/Config.daml @@ -0,0 +1,38 @@ + + + ExportDiagramToFeatureClasses + Export a Diagram To Feature Classes + Images\ExportDiagramToFeatureClasses32.png + ArcGIS Pro SDK Team, arcgisprosdk@esri.com + esri, http://www.esri.com + 9/29/2022 12:01:37 PM + NetworkDiagram + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/NetworkDiagram/ExportDiagramToFeatureClasses/CustomField.cs b/NetworkDiagram/ExportDiagramToFeatureClasses/CustomField.cs new file mode 100644 index 00000000..a87f4f60 --- /dev/null +++ b/NetworkDiagram/ExportDiagramToFeatureClasses/CustomField.cs @@ -0,0 +1,417 @@ +/* + + Copyright 2022 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +using ArcGIS.Core.Data; +using ArcGIS.Core.Data.UtilityNetwork; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ExportDiagramToFeatureClasses +{ + /// + /// Custom field used by the view model + /// + internal class CustomField + { + private readonly int _length; + private readonly Type _keyType; + private string _NewModelName; + + /// + /// Constructor + /// + /// Field to customize + public CustomField(Field FieldToAdd) + { + OriginName = FieldToAdd.Name; + OriginType = FieldToAdd.FieldType; + NewType = OriginType; + NewName = OriginName; + + Domain domain = FieldToAdd.GetDomain(); + + if (domain != null && domain is CodedValueDomain valueDomain) + { + Dictionary values = new(); + foreach (var v in valueDomain.GetCodedValuePairs()) + { + if (!values.TryGetValue(v.Key, out _)) + { + values.Add(v.Key, v.Value); + } + } + + FieldDomain = values; + KeyValuePair pair = FieldDomain.First(); + _keyType = pair.Key.GetType(); + HasDomain = true; + } + else + { + FieldDomain = null; + HasDomain = false; + } + + if (OriginName.Contains("UN_", StringComparison.OrdinalIgnoreCase) || OriginName.Contains("TN_", StringComparison.OrdinalIgnoreCase)) + { + NewName = OriginName[(OriginName.LastIndexOf('.') + 1)..]; + if (string.Compare(NewName, "STATUS", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(NewName, "ROTATION", StringComparison.OrdinalIgnoreCase) == 0) + { + if (OriginName.Contains("ASSOCIATION", StringComparison.OrdinalIgnoreCase)) + NewName = "A_" + NewName; + else + { + NewName = "D_" + NewName; + } + } + else if (NewName.Contains("SOURCEID", StringComparison.OrdinalIgnoreCase)) + { + NewName = NewName.Replace("SOURCEID", "SourceName", StringComparison.OrdinalIgnoreCase); + NewType = FieldType.String; + } + else if (NewName.Contains("SRCID", StringComparison.OrdinalIgnoreCase)) + { + NewName = NewName.Replace("SRCID", "SourceName", StringComparison.OrdinalIgnoreCase); + NewType = FieldType.String; + } + else if (string.Compare(NewName, "ASSOCIATIONTYPE", StringComparison.OrdinalIgnoreCase) == 0) + { + NewType = FieldType.String; + } + else if (string.Compare(NewName, "OBJECTID", StringComparison.OrdinalIgnoreCase) == 0) + { + if (OriginName.Contains("_Junctions", StringComparison.OrdinalIgnoreCase) || + OriginName.Contains("_Edges", StringComparison.OrdinalIgnoreCase) || + OriginName.Contains("_Containers", StringComparison.OrdinalIgnoreCase) || + OriginName.Contains("_TmpJunctions", StringComparison.OrdinalIgnoreCase) || + OriginName.Contains("_TmpEdges", StringComparison.OrdinalIgnoreCase) || + OriginName.Contains("_TmpContainers", StringComparison.OrdinalIgnoreCase)) + { + NewName = "D_OBJECTID"; + NewType = FieldType.Integer; + } + else + { + NewName = "S_OBJECTID"; + NewType = FieldType.Integer; + } + } + } + else if (NewName.Contains("OBJECTID", StringComparison.OrdinalIgnoreCase)) + { + NewName = "S_OBJECTID"; + NewType = FieldType.Integer; + } + else if (OriginName.Contains('.')) + { + NewName = OriginName[(OriginName.LastIndexOf('.') + 1)..]; //NewName = qualifiedName; + } + else + { + NewName = OriginName; + } + + if (NewName.Contains("SOURCEID", StringComparison.OrdinalIgnoreCase)) + { + NewName = NewName.Replace("SOURCEID", "SourceName", StringComparison.OrdinalIgnoreCase); + NewType = FieldType.String; + _length = 50; + } + else if (NewName.Contains("SRCID", StringComparison.OrdinalIgnoreCase)) + { + NewName = NewName.Replace("SRCID", "SourceName", StringComparison.OrdinalIgnoreCase); + NewType = FieldType.String; + _length = 50; + } + + if (CompareWithNewName("ASSETTYPE") || CompareWithNewName("ASSETGROUP")) + { + NewType = FieldType.String; + _length = 50; + } + else if (FieldDomain != null) + { + NewType = FieldType.String; + _length = 255; + } + else if (NewType == FieldType.OID) + { + NewType = FieldType.Integer; + } + else + { + _length = FieldToAdd.Length; + } + + Precision = FieldToAdd.Precision; + AliasName = NewName == "S_OBJECTID" ? "Source ObjectId" : FieldToAdd.AliasName; + Scale = FieldToAdd.Scale; + HasDefaultValue = FieldToAdd.HasDefaultValue; + if (HasDefaultValue) + { + // Sometimes it appears that the field type changed, even if the default value is still in the old type + // In this case, there is an error at the feature class creation + switch (NewType) + { + case FieldType.String: + DefaultValue = FieldToAdd.GetDefaultValue().ToString(); + break; + case FieldType.Integer: + DefaultValue = Convert.ToInt32(FieldToAdd.GetDefaultValue()); + break; + case FieldType.SmallInteger: + DefaultValue = Convert.ToInt16(FieldToAdd.GetDefaultValue()); + break; + case FieldType.Single: + DefaultValue = Convert.ToSingle(FieldToAdd.GetDefaultValue()); + break; + case FieldType.Double: + DefaultValue = Convert.ToDouble(FieldToAdd.GetDefaultValue()); + break; + case FieldType.Date: + DefaultValue = Convert.ToDateTime(FieldToAdd.GetDefaultValue()); + break; + } + } + } + + /// + /// Constructor + /// + /// New field name + /// Field type + public CustomField(string FieldName, FieldType TypeField) + { + OriginName = FieldName; + OriginType = TypeField; + NewType = OriginType; + NewName = OriginName; + + } + + /// + /// Field name in the source feature class + /// + public string OriginName { get; } + + /// + /// New name, without qualification, used in the new geodatabase + /// + public string NewName { get; } + + /// + /// Get the source field type + /// This can be changed, if it is a domain field + /// + public FieldType OriginType { get; } + + /// + /// New field type + /// + public FieldType NewType { get; } + + /// + /// Use to change the domain value into domain name + /// + public Dictionary FieldDomain { get; } + + /// + /// Get the length of the new field + /// + public int Length + { + get + { + if (NewType == FieldType.String && OriginType != NewType) + { + return 255; + } + return _length; + } + } + + /// + /// Get the precision of the new field + /// + public int Precision { get; } + + /// + /// Get the alias name of the new field + /// + public string AliasName { get; } + + /// + /// Get the new field name with the qualified name if needed + /// + public string NewModelName + { + get + { + if (string.IsNullOrEmpty(_NewModelName)) + return NewName; + + return _NewModelName; + } + set { _NewModelName = value; } + } + + /// + /// Flag to indicate if the field has a default value + /// + public bool HasDefaultValue { get; } + + /// + /// Default Value + /// + public object DefaultValue { get; } + + /// + /// Scale + /// + public int Scale { get; } + + /// + /// Flag to indicate if the field has a domain name + /// + public bool HasDomain { get; } + + /// + /// Indicate if the field has the search name + /// + /// Search name + /// True if same name + public bool CompareWithNewName(string FieldName) + { + return string.Compare(FieldName, NewName, StringComparison.OrdinalIgnoreCase) == 0; + } + + /// + /// Get the domain name + /// + /// Domain index + /// String + public string GetDomainValue(object Index) + { + string key = ""; + if (typeof(short) == _keyType) + { + FieldDomain.TryGetValue(Convert.ToInt16(Index), out key); + } + else if (typeof(int) == _keyType) + { + FieldDomain.TryGetValue(Convert.ToInt32(Index), out key); + } + else if (typeof(long) == _keyType) + { + FieldDomain.TryGetValue(Convert.ToInt64(Index), out key); + } + + if (string.IsNullOrEmpty(key)) + { + return Index.ToString(); + } + + return key; + } + + /// + /// Flag to indicate whether the field name changed from SourceId To SourceName + /// + public bool IsSourceName + { + get { return NewName.Contains("SourceName", StringComparison.OrdinalIgnoreCase); } + } + + /// + /// Flag to indicate whether the field is the network source class Asset Group field + /// + public bool IsAssetGroup + { + get { return NewName.Contains("AssetGroup", StringComparison.OrdinalIgnoreCase); } + } + + /// + /// Flag to indicate whether the field is the network source class Asset Type field + /// + public bool IsAssetType + { + get { return NewName.Contains("AssetType", StringComparison.OrdinalIgnoreCase); } + } + + /// + /// Flag to indicate whether the field defines an association type + /// + public bool IsAssociationType + { + get { return NewName.Contains("AssociationType", StringComparison.OrdinalIgnoreCase) || string.Compare(NewName, "D_ASSOCIATION", true) == 0; } + } + + /// + /// List of the Asset Group for the feature Class, if the field is an Asset Group field + /// + public IReadOnlyList AssetGroups { get; internal set; } + + /// + /// Get the Asset Group from its code + /// + /// Asset Group code + /// Asset Group + public AssetGroup GetAssetGroup(int Code) + { + if (AssetGroups == null) + return null; + + return AssetGroups.FirstOrDefault(a => a.Code == Code); + } + + /// + /// Get the Asset Group from its name + /// + /// Asset Group name + /// Asset Group + public AssetGroup GetAssetGroup(string Name) + { + if (AssetGroups == null) + return null; + + AssetGroup result = AssetGroups.FirstOrDefault(a => string.Compare(a.Name, Name, StringComparison.OrdinalIgnoreCase) == 0); + if (result == null) + { + List resultList = AssetGroups.Where(a => Name.Contains(a.Name, StringComparison.OrdinalIgnoreCase)).ToList(); + if (resultList.Count == 1) + { + return resultList[0]; + } + + int maxLenght = 0; + foreach (var v in resultList) + { + if (v.Name.Length > maxLenght) + { + maxLenght = v.Name.Length; + result = v; + } + } + + } + return result; + } + } +} \ No newline at end of file diff --git a/NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/AddInDesktop16.png b/NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/AddInDesktop16.png new file mode 100644 index 0000000000000000000000000000000000000000..0118942a923d37745dced41536d71172f7517deb GIT binary patch literal 1314 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m^Cs(B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxOgGuU%v{0TQqR!T z+}y-mN5ROz&{W^RSl`${*T~q)#K6kLNC66zfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr7I$IMft0d=ry1 z^FV@{U|qhxR-SpqC5d^-sh%#jNbn4Gmq*EQ}4@91Trf z9F2`FOx&CdV0vBhlS^|`^GaZPQ-FG%U0huajGRnx>IEf;+ybD@E~!PCWvMA{Mftf3 zV2@j6;&zJxPV=C8Q?R%N>JLMldi8;h(Fa8@Qgp+FfN2QCgeP7g2cG;>^MGl-2$;A{ z^UHoRFfdN=ba4!+xHV_eSudtQk>mf3ADc`I;N%lh@rhWMHCaSu#|rTc+b*73D_z|f zchKzJnb0k|)r|_C3qu72JFMDTIvVAZpRQPZcJC7h=Cdqs6d>g;Fd(<~UJ81^dm+<(73@IuqYmV0m9+Os7i{i0=el#xWp=L=ll zcWrlNR9(*{VE_OC literal 0 HcmV?d00001 diff --git a/NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/AddInDesktop32.png b/NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/AddInDesktop32.png new file mode 100644 index 0000000000000000000000000000000000000000..9713e3b1548cc2ee78c60ad4ffb3a46566609b2b GIT binary patch literal 1744 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%o>>?5hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83 zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s0*lEl2^R8JRMC7?NanVBh8&MvO521ZWi7A`KPhK8g6oCT>m!FugAM$)&lec_lEtDG0q5IQ4=OL~a4lW|!2W%(B!Jx1#)91+d4hGI6`b z6sLJmy(zfeVun+%KF~4xpy)-4ZkP}-4S|^O#0%uWlYeR+FwGYM6ZcJlSNy;{W9RAO z7*cU-Pq?qYaH7Dxw|Vt6-sL_XG#dCA=nEb^pfQtK4{2?@f5-Yn6Pn-PZZfE9Y0HrEx1H z9!!{UoHf^M-t)%bq7T3S{`vE#W^-XsO7HozXLCLFraX~2kgXt)p=H#>-|A#wX*ttK zsyEz0fq7Ti0YpasWR z+$R{k6EQaQOgubCjeVsOtlnOk{w`C6b(O-k z!?%v*K6AM`eR77=`V*;bYYY>29(i2Y;i6QsaMQ#fQ$;238P%!+a}++v7ICVt;*4J- z(t7o6^o7?q*{10_e_A1~bF=-!5qqwE6AORrn%yeg8+zd1YNnkg1x*k3n|IH?7GcRX zm5aSBol`57Z&RkUjQpL}K6dR7mnSsJ-QzxQ+bj^ZpL1#Y`=~J1hg`^%fgqBz3;E zypY`VWYg}1goK7Hr>$HfCJm_;pKI;?o2*r3d5-OQQhbGzDPtR#z=0d{_h&}7^PSf8 zb>5gD)M&Ftrs?+EygIQdKZL&Ay+5huW~Qg(^y=;BTJBYZU1$4y=WKYiF?T?MgwEt` zT`TsR|L}eiBb-#bV0KB@XNO?X7m|OEe!um$R*<1vcj3z0E6+0PZcey)bXUf@iL7he zsyA4hS#t{wI^H6T7(3Ke0lyCJVujWX{t((u~qp@l3TlWoH zzfI9w__aZNhOnDxgV^fc$14>N2duI-*SXET!S?cG;RSYO0%GFg(Vy;~h>>%(s=VC@S26m4%0k2Q>`~uZ6p00i_ I>zopr0LdSn0ssI2 literal 0 HcmV?d00001 diff --git a/NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/ExportDiagramToFeatureClasses16.png b/NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/ExportDiagramToFeatureClasses16.png new file mode 100644 index 0000000000000000000000000000000000000000..db0251f5d75ba7a83aaf12cbcf5028c0fe74bcf2 GIT binary patch literal 679 zcmV;Y0$BZtP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0z64XK~y+TjZ)o9 zQ(+kYofA8)E!%RnNgq=XB&!Kx30+te2os9*A{a#Eb`dBQ&J~syn{BOV(*A>56oGUz z4T9Zt)dyw4sEoP^f>BXY9f|3_-`@9`=S+=3KX`aP-gAEM?|GgV9PEGXi0=|}?cTMj zCWS&FW>#b#*N4Hh34XsHPZ`7Xdmz#4#LsUTI+Ga3%%=iObx0Nq6&!C>AW0JCCx$Md zFER<=mTFD}J$F81tJ#1BRfWZBr2`G~*&?0{wh)2mavW3FM-h0(aMLBB|J+2Cpz+{I zQjkpE!@$5PSUHKx$ppUs_=U>bM?`S?1w-4%8NAxC5Bry1BW*ieCD7#YP?s8uULh}t zqOmyDZ%ohPdAS9~{BPveZ-#4O7JB2&%}(IWV>q{Oqx|A{5MTK1Sv~^|WBuLe$bUeo zp^5xe-%+fa;8>Iu+-@r)GdG8`?TwJ#gXlffgH$R-Kf2v+@*a-|iO2|c8cTR~D}tsS z&YA*NEI~Gzfl@(lL(D=Lzk_@(mqYN{B<{z9ICDOLbUICa(}QR*DvZ5+$Tk{e%C&kT zkspS$x0PIu067|s!e+CftFsf~a2OqX_n=a# z4Nil$R;~z{@ADLESS3qQ6kVS1{5JA;ryl5jxZPI!h7XJq&Fpr2?QlhXtX~Fm3t*q6IDflP{vYl%?~32m~w^3mgsyyk0M@t{zlX#a}}oCatQEfv5lg N002ovPDHLkV1i;HChY(K literal 0 HcmV?d00001 diff --git a/NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/ExportDiagramToFeatureClasses32.png b/NetworkDiagram/ExportDiagramToFeatureClasses/DarkImages/ExportDiagramToFeatureClasses32.png new file mode 100644 index 0000000000000000000000000000000000000000..eca6b2750f5564b3394e0bfbd27daf2afc65728b GIT binary patch literal 885 zcmV-*1B(2KP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0*y&TK~z{r&6G=M z6Hyd~|7na#UHAyr8ljdzDN<15Mny!C5_}<|8>4~+p&(@0mADdj;>Lw5L7`%sg;J=B z4+KF$(UmSLDA6n`^$|3!MUrZhIOpWvVLEefGKm@L2ZwtecXIzb=S&O$71I_C-vkWZ z%_0^FVdI)GcK1X?){Sohj*Yw%9uSW%!`VGuB3g)1F%f=CFbujA@F6#g%=bCmo|wkW zTnQUG!Z@Gk=9(Sf1lTz?f52uhH!i$C!#8oGrxrguF)P}-@wf`KU^XR%2AE5 zX297yIh(4Us&MYNe}*SFN2~+wKH-~y^y{w}dppg(jw5|58*c#}q%tSTcqbpAgKD(L z*BQ`>kcSh>7EIn5Mt1xLP%fh@aTKv+N>uc%(dCJ2uRh~p<|q4mdzRz$)+qagO8_1I zY4{S1Hi`qNl;^Sb&;VkmhPd900D?pi_QMHFfaK|50-@O)*6lk1V@VKG57H>MufVRW zkHn6~sU=o30|6Mpr7!|P(*h#bJoY;}eM+V(JcO%v?niIxf~eH*wO6d)Q3)V)2RZY)ef5yf`T9TL1=m;L z72S8`iL_Lb8 zg~>6Wp+!3by1H{VeK0w-;v}55_DI5R415zlRwX|~q89SiW zYBSxkE=Z<-PTSkt>G=3~PRJRC$=m^!Wl3daWlqQ&8yhosAlLW@81G2wR_0ZY00000 LNkvXXu0mjf&vJ +There are some ArcGIS Pro functions you can use to export diagrams. For example, the Export Diagram Content geoprocessing tool allows you to export a JSON file that describes a network diagram content (see https://pro.arcgis.com/en/pro-app/latest/tool-reference/network-diagram/export-diagram-content.htm). The output JSON file can then be used for network calculation and analysis or to feed external system. +Starting from an open network diagram map, you can also use the Export Map functions available on the Share tab in the Output group, to export the active diagram map as a file including vector and raster formats. + +This add-in demonstrates another way to export a network diagram. It applies to any network diagram present in an active diagram map and exports its content into a set of feature classes in a feature dataset in a local geodatabase (File or Mobile). The output feature dataset can then be added to a map, shared with others, and so on. + +If you want, you can also turn on some extra options to: +- Export the diagram aggregations into a specific table in the output geodatabase +- Add the exported features to a new map under feature layers built with the same layer properties as under the original network diagram layer. + +> NOTE: The ExportDiagramToFeatureClasses add-in code is a generic code sample that performs any network diagram related to any utility or trace network dataset. + +1. In Visual Studio, click the Build menu. Then select Build Solution. +1. Start ArcGIS Pro. +1. Open your favorite utility network or trace network ArcGIS Pro project. +1. Open the network diagram you want to export or generate a new network diagram. +1. In the Add-In tab on the ribbon, click Export Diagram To Feature Classes: + + ![UI](Screenshots/ExportDiagramToFeatureClassesButton.png) + + The Export Diagram To Feature Classes pane window opens: + + ![UI](Screenshots/ExportDiagramToFeatureClassesPaneWindow1.png) + +1. Expand the Output Geodatabase section to specify the output geodatabase into which you want to export your network diagram. +1. Click the browse button next to the Folder text area. Then, browse to and select the output folder where this geodatabase already exists or will be created. +1. From the Type drop down list, pick up the type of output geodatabase you want to create—File or Mobile. +1. In the Name text area, type the name of the output geodatabase. +1. Then, expand the Options section. +1. To export the diagram aggregations, make sure the 'Export aggregations' option is checked. + +1. If you want the exported diagram features to display in a new map once the export completes, check 'Add to a new map'. +The Export Diagram To Feature Classes pane window should look like as follows: + + ![UI](Screenshots/ExportDiagramToFeatureClassesPaneWindow2.png) + +1. Make sure the diagram map you want to export is the active map and click Run. +The export process starts. A message displays at the bottom of the pane window when it completes. + + ![UI](Screenshots/ExportDiagramToFeatureClassesPaneWindow2.png) + +1. In the Catalog pane window, go to the specified output folder and expand the output geodatabase where your diagram should have been exported. The next paragraphs explain how it is exported. + + ![UI](Screenshots/ExportDiagramToFeatureClasses_OutputFC.png) + +In the specified output geodatabase, you should see a new feature dataset whose name corresponds to the exported network diagram layer name. Under this feature dataset, there is a set of feature classes whose names correspond to utility or trace network source class names. There is a feature class with a given network source class name when there is at least one diagram feature representing such a network source feature in the original diagram. For example, if there are structure junctions in the original diagram, the StructureJunction class is created under the exported feature dataset and all the structure diagram junctions are exported in this class. When there is no structure junction in the original diagram, there is no StructureJunction class in the exported feature dataset. + +Any diagram feature whose geometry type changed in the original diagram regarding to its source network feature geometry is exported in a feature class with a specific suffix in its name. This happens for any point network feature that exists as a diagram polygon container in the original diagram. Such a diagram container is exported in a feature class whose name has the _C suffix. For example, a junction box diagram container is exported in the StructureJunction_C feature class. + +In the same way, any polygon network feature or line network feature that exists in the original diagram as a diagram junction is exported in a feature class whose name has the _J suffix. For example a Substation diagram junction is exported in the StructureBoundary_J feature class. +Under this feature dataset, you can also see a ReductionEdges line feature class for any exported reduction diagram edge, a SystemJunctions point feature class for the exported system junctions, and an Associations line feature class for the connectivity associations and structural attachments present in the exported diagram. + +With the 'Export aggregations' option checked, you also get the Aggregations table created in the output geodatabase. This table lists the GlobalIDs of all the network features that are collapsed or reduced in the diagram with the diagram element ID of the diagram feature that aggregates them (AggregationDEID), and +you can export various diagrams in the same output geodatabase. In this case, a feature dataset is created for each exported diagram. Since class names are unique inside the entire geodatabase, the names of the newly created feature classes are automatically suffixed with numbers to avoid duplicated names. + +When the 'Add to a new map' option is checked, the process continues after the diagram export completion. It first creates a new map whose name corresponds to the diagram layer name suffixed with a number. Then, it analyzes the layer definitions on the sublayers under the original network diagram layer and builds new layers with similar layer definitions in the newly open map for the exported diagram features. + +![UI](Screenshots/ExportDiagramToFeatureClasses_AddedToAMap.png) diff --git a/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses (C#).md b/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses (C#).md new file mode 100644 index 00000000..d01a2e95 --- /dev/null +++ b/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses (C#).md @@ -0,0 +1,82 @@ +## ExportDiagramToFeatureClasses + + +There are some ArcGIS Pro functions you can use to export diagrams. For example, the Export Diagram Content geoprocessing tool allows you to export a JSON file that describes a network diagram content (see https://pro.arcgis.com/en/pro-app/latest/tool-reference/network-diagram/export-diagram-content.htm). The output JSON file can then be used for network calculation and analysis or to feed external system. +Starting from an open network diagram map, you can also use the Export Map functions available on the Share tab in the Output group, to export the active diagram map as a file including vector and raster formats. + +This add-in demonstrates another way to export a network diagram. It applies to any network diagram present in an active diagram map and exports its content into a set of feature classes in a feature dataset in a local geodatabase (File or Mobile). The output feature dataset can then be added to a map, shared with others, and so on. + +If you want, you can also turn on some extra options to: +- Export the diagram aggregations into a specific table in the output geodatabase +- Add the exported features to a new map under feature layers built with the same layer properties as under the original network diagram layer. + +> NOTE: The ExportDiagramToFeatureClasses add-in code is a generic code sample that performs any network diagram related to any utility or trace network dataset. + + + +View it live + + +``` +Language: C# +Subject: NetworkDiagram +Contributor: ArcGIS Pro SDK Team +Organization: Esri, https://www.esri.com +Date: 06/10/2022 +ArcGIS Pro: 3.0 +Visual Studio: 2022 +.NET Target Framework: net6.0-windows +``` + +## Resources + +[Community Sample Resources](https://github.com/Esri/arcgis-pro-sdk-community-samples#resources) + +### Samples Data + +* Sample data for ArcGIS Pro SDK Community Samples can be downloaded from the [Releases](https://github.com/Esri/arcgis-pro-sdk-community-samples/releases) page. + +## How to use the sample + +1. In Visual Studio, click the Build menu. Then select Build Solution. +1. Start ArcGIS Pro. +1. Open your favorite utility network or trace network ArcGIS Pro project. +1. Open the network diagram you want to export or generate a new network diagram. +1. In the Add-In tab on the ribbon, click Export Diagram To Feature Classes: +![UI](Screenshots/ExportDiagramToFeatureClassesButton.png) + +1. The Export Diagram To Feature Classes pane window opens: +![UI](Screenshots/ExportDiagramToFeatureClassesPaneWindow1.png) + +1. Expand the Output Geodatabase section to specify the output geodatabase into which you want to export your network diagram. +1. Click the browse button next to the Folder text area. Then, browse to and select the output folder where this geodatabase already exists or will be created. +1. From the Type drop down list, pick up the type of output geodatabase you want to create—File or Mobile. +1. In the Name text area, type the name of the output geodatabase. +1. Then, expand the Options section. +1. To export the diagram aggregations, make sure the 'Export aggregations' option is checked. +1. If you want the exported diagram features to display in a new map once the export completes, check 'Add to a new map'. +1. The Export Diagram To Feature Classes pane window should look like as follows: +![UI](Screenshots/ExportDiagramToFeatureClassesPaneWindow2.png) + +1. Make sure the diagram map you want to export is the active map and click Run. +1. The export process starts. A message displays at the bottom of the pane window when it completes. +![UI](Screenshots/ExportDiagramToFeatureClassesPaneWindow2.png) + +1. In the Catalog pane window, go to the specified output folder and expand the output geodatabase where your diagram should have been exported. The next paragraphs explain how it is exported. +![UI](Screenshots/ExportDiagramToFeatureClasses_OutputFC.png) + +In the specified output geodatabase, you should see a new feature dataset whose name corresponds to the exported network diagram layer name. Under this feature dataset, there is a set of feature classes whose names correspond to utility or trace network source class names. There is a feature class with a given network source class name when there is at least one diagram feature representing such a network source feature in the original diagram. For example, if there are structure junctions in the original diagram, the StructureJunction class is created under the exported feature dataset and all the structure diagram junctions are exported in this class. When there is no structure junction in the original diagram, there is no StructureJunction class in the exported feature dataset. +Any diagram feature whose geometry type changed in the original diagram regarding to its source network feature geometry is exported in a feature class with a specific suffix in its name. This happens for any point network feature that exists as a diagram polygon container in the original diagram. Such a diagram container is exported in a feature class whose name has the _C suffix. For example, a junction box diagram container is exported in the StructureJunction_C feature class. +In the same way, any polygon network feature or line network feature that exists in the original diagram as a diagram junction is exported in a feature class whose name has the _J suffix. For example a Substation diagram junction is exported in the StructureBoundary_J feature class. +Under this feature dataset, you can also see a ReductionEdges line feature class for any exported reduction diagram edge, a SystemJunctions point feature class for the exported system junctions, and an Associations line feature class for the connectivity associations and structural attachments present in the exported diagram. +With the 'Export aggregations' option checked, you also get the Aggregations table created in the output geodatabase. This table lists the GlobalIDs of all the network features that are collapsed or reduced in the diagram with the diagram element ID of the diagram feature that aggregates them (AggregationDEID), and you can export various diagrams in the same output geodatabase. In this case, a feature dataset is created for each exported diagram. Since class names are unique inside the entire geodatabase, the names of the newly created feature classes are automatically suffixed with numbers to avoid duplicated names. +When the 'Add to a new map' option is checked, the process continues after the diagram export completion. It first creates a new map whose name corresponds to the diagram layer name suffixed with a number. Then, it analyzes the layer definitions on the sublayers under the original network diagram layer and builds new layers with similar layer definitions in the newly open map for the exported diagram features. +![UI](Screenshots/ExportDiagramToFeatureClasses_AddedToAMap.png) + + + + + +      ArcGIS Pro SDK for Microsoft .NET Framework +             +[Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](https://github.com/Esri/arcgis-pro-sdk/wiki#requirements) | [Download](https://github.com/Esri/arcgis-pro-sdk/wiki#installing-arcgis-pro-sdk-for-net) | Samples diff --git a/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses.csproj b/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses.csproj new file mode 100644 index 00000000..315e5101 --- /dev/null +++ b/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses.csproj @@ -0,0 +1,108 @@ + + + + net6.0-windows + true + win10-x64 + false + true + CA1416 + True + + + + + + + + + + + + + + + + + + + + + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Ribbon.Wpf.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.DataGrid.Contrib.Wpf.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Resources.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\ESRI.ArcGIS.ItemIndex.dll + False + False + + + C:\Program Files\ArcGIS\Pro\bin\Newtonsoft.Json.dll + False + + + + \ No newline at end of file diff --git a/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses.sln b/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses.sln new file mode 100644 index 00000000..aea06059 --- /dev/null +++ b/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClasses.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32319.34 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExportDiagramToFeatureClasses", "ExportDiagramToFeatureClasses.csproj", "{C26AF634-A8D2-40C7-8636-1920049B4565}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C26AF634-A8D2-40C7-8636-1920049B4565}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C26AF634-A8D2-40C7-8636-1920049B4565}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C26AF634-A8D2-40C7-8636-1920049B4565}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C26AF634-A8D2-40C7-8636-1920049B4565}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {226CBAF4-C547-4564-9726-1F034FFD7E3D} + EndGlobalSection +EndGlobal diff --git a/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClassesModule.cs b/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClassesModule.cs new file mode 100644 index 00000000..34a7a8e5 --- /dev/null +++ b/NetworkDiagram/ExportDiagramToFeatureClasses/ExportDiagramToFeatureClassesModule.cs @@ -0,0 +1,376 @@ +/* + + Copyright 2022 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +using ArcGIS.Core.CIM; +using ArcGIS.Core.Data; +using ArcGIS.Core.Data.UtilityNetwork; +using ArcGIS.Desktop.Core; +using ArcGIS.Desktop.Framework; +using ArcGIS.Desktop.Framework.Contracts; +using ArcGIS.Desktop.Mapping; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace ExportDiagramToFeatureClasses +{ + /// + /// There are some ArcGIS Pro functions you can use to export diagrams. For example, the Export Diagram Content geoprocessing tool allows you to export a JSON file that describes a network diagram content (see https://pro.arcgis.com/en/pro-app/latest/tool-reference/network-diagram/export-diagram-content.htm). The output JSON file can then be used for network calculation and analysis or to feed external system. + /// Starting from an open network diagram map, you can also use the Export Map functions available on the Share tab in the Output group, to export the active diagram map as a file including vector and raster formats. + /// + /// This add-in demonstrates another way to export a network diagram. It applies to any network diagram present in an active diagram map and exports its content into a set of feature classes in a feature dataset in a local geodatabase (File or Mobile). The output feature dataset can then be added to a map, shared with others, and so on. + /// + /// If you want, you can also turn on some extra options to: + /// - Export the diagram aggregations into a specific table in the output geodatabase + /// - Add the exported features to a new map under feature layers built with the same layer properties as under the original network diagram layer. + /// + /// > NOTE: The ExportDiagramToFeatureClasses add-in code is a generic code sample that performs any network diagram related to any utility or trace network dataset. + /// + /// + /// 1. In Visual Studio, click the Build menu. Then select Build Solution. + /// 1. Start ArcGIS Pro. + /// 1. Open your favorite utility network or trace network ArcGIS Pro project. + /// 1. Open the network diagram you want to export or generate a new network diagram. + /// 1. In the Add-In tab on the ribbon, click Export Diagram To Feature Classes: + /// ![UI](Screenshots/ExportDiagramToFeatureClassesButton.png) + /// 1. The Export Diagram To Feature Classes pane window opens: + /// ![UI](Screenshots/ExportDiagramToFeatureClassesPaneWindow1.png) + /// 1. Expand the Output Geodatabase section to specify the output geodatabase into which you want to export your network diagram. + /// 1. Click the browse button next to the Folder text area. Then, browse to and select the output folder where this geodatabase already exists or will be created. + /// 1. From the Type drop down list, pick up the type of output geodatabase you want to create—File or Mobile. + /// 1. In the Name text area, type the name of the output geodatabase. + /// 1. Then, expand the Options section. + /// 1. To export the diagram aggregations, make sure the 'Export aggregations' option is checked. + /// 1. If you want the exported diagram features to display in a new map once the export completes, check 'Add to a new map'. + /// 1. The Export Diagram To Feature Classes pane window should look like as follows: + /// ![UI](Screenshots/ExportDiagramToFeatureClassesPaneWindow2.png) + /// 1. Make sure the diagram map you want to export is the active map and click Run. + /// 1. The export process starts. A message displays at the bottom of the pane window when it completes. + /// ![UI](Screenshots/ExportDiagramToFeatureClassesPaneWindow2.png) + /// 1. In the Catalog pane window, go to the specified output folder and expand the output geodatabase where your diagram should have been exported. The next paragraphs explain how it is exported. + /// ![UI](Screenshots/ExportDiagramToFeatureClasses_OutputFC.png) + /// + /// In the specified output geodatabase, you should see a new feature dataset whose name corresponds to the exported network diagram layer name. Under this feature dataset, there is a set of feature classes whose names correspond to utility or trace network source class names. There is a feature class with a given network source class name when there is at least one diagram feature representing such a network source feature in the original diagram. For example, if there are structure junctions in the original diagram, the StructureJunction class is created under the exported feature dataset and all the structure diagram junctions are exported in this class. When there is no structure junction in the original diagram, there is no StructureJunction class in the exported feature dataset. + /// Any diagram feature whose geometry type changed in the original diagram regarding to its source network feature geometry is exported in a feature class with a specific suffix in its name. This happens for any point network feature that exists as a diagram polygon container in the original diagram. Such a diagram container is exported in a feature class whose name has the _C suffix. For example, a junction box diagram container is exported in the StructureJunction_C feature class. + /// In the same way, any polygon network feature or line network feature that exists in the original diagram as a diagram junction is exported in a feature class whose name has the _J suffix. For example a Substation diagram junction is exported in the StructureBoundary_J feature class. + /// Under this feature dataset, you can also see a ReductionEdges line feature class for any exported reduction diagram edge, a SystemJunctions point feature class for the exported system junctions, and an Associations line feature class for the connectivity associations and structural attachments present in the exported diagram. + /// With the 'Export aggregations' option checked, you also get the Aggregations table created in the output geodatabase. This table lists the GlobalIDs of all the network features that are collapsed or reduced in the diagram with the diagram element ID of the diagram feature that aggregates them (AggregationDEID), and + /// you can export various diagrams in the same output geodatabase. In this case, a feature dataset is created for each exported diagram. Since class names are unique inside the entire geodatabase, the names of the newly created feature classes are automatically suffixed with numbers to avoid duplicated names. + /// When the 'Add to a new map' option is checked, the process continues after the diagram export completion. It first creates a new map whose name corresponds to the diagram layer name suffixed with a number. Then, it analyzes the layer definitions on the sublayers under the original network diagram layer and builds new layers with similar layer definitions in the newly open map for the exported diagram features. + /// ![UI](Screenshots/ExportDiagramToFeatureClasses_AddedToAMap.png) + /// + internal class ExportDiagramToFeatureClassesModule : Module + { + private static ExportDiagramToFeatureClassesModule _this = null; + + /// + /// Retrieve the singleton instance to this module here + /// + public static ExportDiagramToFeatureClassesModule Current => _this ??= (ExportDiagramToFeatureClassesModule)FrameworkApplication.FindModule("ExportDiagramToFeatureClasses_Module"); + + #region Overrides + /// + /// Called by the framework when ArcGIS Pro is closing + /// + /// False to prevent Pro from closing, otherwise True + protected override bool CanUnload() + { + //TODO - add your business logic + //return false to ~cancel~ Application close + return true; + } + + #endregion Overrides + + + /// + /// Show a message + /// + /// Message + /// Title + internal static void ShowMessage(string Message, string Title = "") + { + if (string.IsNullOrEmpty(Title)) + { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(Message); } + else + { + ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(Message, Title); + } + } + + /// + /// Format the message return by the SchemaBuilder + /// + /// List of error messages + /// string + internal static string FormatErrors(IReadOnlyList ErrorMessages) + { + if (ErrorMessages.Count == 0) + return ""; + + StringBuilder sb = new(); + foreach (string errorMessage in ErrorMessages) + sb.AppendLine(errorMessage); + + return sb.ToString(); + } + + /// + /// Format exception and InnerException + /// + /// Exception + /// Return exception and InnerException as string + internal static string ExceptionFormat(Exception ex) + { + if (ex.InnerException != null) + { + string s = ExceptionFormat(ex.InnerException); + + if (s.Length > 0) + return string.Format("{0}\n{1}\n{2}", ex.Message, s, ex.StackTrace); + } + + string msg = string.Format("{0}\n{1}", ex.Message, ex.StackTrace); + System.Diagnostics.Debug.WriteLine(msg); + return msg; + } + + /// + /// Open a dataset + /// + /// Type of dataset + /// Dataset name + /// A dataset of T type + internal static T OpenDataset(Geodatabase Database, string Name) where T : Dataset + { + if (Database == null) + return default; + + GeodatabaseType geodatabaseType = Database.GetGeodatabaseType(); + if (geodatabaseType == GeodatabaseType.Service) + { + Type t = typeof(T); + + if (t == typeof(Table)) + { + IReadOnlyList allTables = Database.GetDefinitions(); + foreach (TableDefinition tableDef in allTables) + { + string aliasName = tableDef.GetAliasName(); + if (aliasName.Replace(" ", "").Equals(Name, StringComparison.OrdinalIgnoreCase)) + { + return Database.OpenDataset(tableDef.GetName()); + } + } + } + else if (t == typeof(FeatureClass)) + { + IReadOnlyList allFeatureClasses = Database.GetDefinitions(); + foreach (FeatureClassDefinition fcDef in allFeatureClasses) + { + string aliasName = fcDef.GetAliasName(); + if (!String.IsNullOrEmpty(aliasName)) + { + if (aliasName == Name || aliasName.Replace(" ", "").Equals(Name, StringComparison.OrdinalIgnoreCase)) + { + return Database.OpenDataset(fcDef.GetName()); + } + } + else + { + //Weird case, where the alias name is empty (Error Tables, Dirty Areas) + string fullName = fcDef.GetName(); + if (fullName.Replace("_", "").Contains(Name)) //the Point errors, line errors, polygon errors and dirty areas come back as Dirty_Areas (want to compare to DirtyAreas). + { + return Database.OpenDataset(fullName); + } + } + } + } + else if (t == typeof(RelationshipClass)) + { + IReadOnlyList allRelationshipClasses = Database.GetDefinitions(); + foreach (RelationshipClassDefinition rcDef in allRelationshipClasses) + { + string aliasName = rcDef.GetAliasName(); + if (aliasName.Replace(" ", "").Equals(Name, StringComparison.OrdinalIgnoreCase)) + { + return Database.OpenDataset(rcDef.GetName()); + } + } + } + else if (t == typeof(UtilityNetwork)) + { + IReadOnlyList unDefinition = Database.GetDefinitions(); + foreach (UtilityNetworkDefinition unDef in unDefinition) + { + return Database.OpenDataset(unDef.GetName()); + } + } + else + { + //There is no type supported in the Feature Service DB, have to return null + return null; + } + } + else if (geodatabaseType == GeodatabaseType.LocalDatabase) + { + return Database.OpenDataset(Name); + } + else + { + if (Name.Contains('.')) + { + Name = Name[(Name.LastIndexOf(".") + 1)..]; + } + + return Database.OpenDataset(Name); + } + return null; + } + + /// + /// Get the diagram layer in the active map + /// + /// Diagram map where the diagram layer is + /// DiagramLayer + internal static DiagramLayer GetDiagramLayerFromMap(Map ActiveMap) + { + if (ActiveMap == null || ActiveMap.MapType != MapType.NetworkDiagram) + return null; + + IReadOnlyList myLayers = ActiveMap.Layers; + if (myLayers == null) + return null; + + foreach (Layer l in myLayers) + { + if (l.GetType() == typeof(DiagramLayer)) + return l as DiagramLayer; + } + + return null; + } + + /// + /// Create a new output map for the exported diagram + /// + /// Map name + /// Shown after its creation or not + /// Map + internal static async Task CreateNewMap(string Name, bool ShowMap = false) + { + Map newMap = MapFactory.Instance.CreateMap(Name, MapType.Map, MapViewingMode.Map, Basemap.ProjectDefault); + if (newMap == null) + return null; + + if (ShowMap) + { + await FrameworkApplication.Panes.CreateMapPaneAsync(newMap, MapViewingMode.Map); + } + return newMap; + } + + /// + /// Show the new output map + /// + /// Map + /// Pane + internal static Task ShowMap(Map MapToShow) + { + if (MapToShow != null) + { + return FrameworkApplication.Panes.CreateMapPaneAsync(MapToShow, MapViewingMode.Map); + } + + return null; + } + + /// + /// Create a new group layer in the output map + /// + /// Map + /// New group layer name + /// GroupLayer + internal static GroupLayer CreateGroupLayerInMap(Map MapToAdd, string GroupName) + { + int index = MapToAdd.Layers.Count - 2; + if (index < 0) + { + index = 0; + } + + return LayerFactory.Instance.CreateGroupLayer(MapToAdd, index, GroupName); + } + + /// + /// Add a layer to a layer container + /// + /// Layer container + /// Layer name + /// Associated feature class to show + /// Definition query + /// Filter name + /// Layer renderer + /// FeatureLayer + internal static FeatureLayer AddFeatureLayerToGroup(ILayerContainerEdit ParentLayer, string Name, FeatureClass AssociatedFeatureClass, string WhereClause, string FilterName, RendererDefinition Renderer) + { + if (Name.Contains('.')) + { + Name = Name.Substring(Name.LastIndexOf('.') + 1); + } + FeatureLayerCreationParams flyrCreatnParam = new(AssociatedFeatureClass) + { + Name = Name, + IsVisible = true, + MinimumScale = 0, + MaximumScale = 0, + DefinitionQuery = new DefinitionQuery(whereClause: WhereClause, name: FilterName), + RendererDefinition = Renderer + }; + + return LayerFactory.Instance.CreateLayer(flyrCreatnParam, ParentLayer); + } + + /// + /// Add a table to a parent container + /// + /// Parent container + /// Table name + /// Associated table to show + /// Definition query + /// Filter name + internal static void AddTableLayerToMap(IStandaloneTableContainerEdit ParentLayer, string Name, Table AssociatedTable, string WhereClause, string FilterName) + { + DefinitionQuery definitionQuery = new(whereClause: WhereClause, name: FilterName); + StandaloneTableCreationParams flyrCreatnParam = new(AssociatedTable) + { + Name = Name + }; + + StandaloneTable standaloneTable = StandaloneTableFactory.Instance.CreateStandaloneTable(flyrCreatnParam, ParentLayer); + + if (standaloneTable != null && string.IsNullOrEmpty(standaloneTable.DefinitionQuery)) + { + standaloneTable.SetDefinitionQuery(WhereClause); + } + } + } +} diff --git a/NetworkDiagram/ExportDiagramToFeatureClasses/ExportPane.xaml b/NetworkDiagram/ExportDiagramToFeatureClasses/ExportPane.xaml new file mode 100644 index 00000000..99ff3b84 --- /dev/null +++ b/NetworkDiagram/ExportDiagramToFeatureClasses/ExportPane.xaml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +