Hi,
I am rewriting ArcObjects .NET Console Application using the Pro SDK. I want to dynamically create / delete shape file in my console application using Pro SDK but i am not finding any documentation for Pro SDK for such requirements.
Can you please provide any code sample for same ?
You will need to use geoprocessing tools probably.
Run a geoprocessing task and python script | ArcGIS for Developers
I personally use python to do these types of task. If I want a gui aspect to it I will just put the python script in the solution and run it from there.
public async Task<IGPResult> ExecuteModel()
{
var progDlg = new ProgressDialog("Running Geoprocessing Tool", "Cancel");
progDlg.Show();
var progSrc = new CancelableProgressorSource(progDlg);
var pathPython = System.IO.Path.GetDirectoryName((new
System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath);
pathPython = Uri.UnescapeDataString(pathPython);
System.Diagnostics.Debug.WriteLine(pathPython);
var tool_path = System.IO.Path.Combine(pathPython, @"PytonToolbox.pyt\Tool");
var parameters = Geoprocessing.MakeValueArray();
IGPResult gp_result = await Geoprocessing.ExecuteToolAsync(tool_path,
parameters, null, new CancelableProgressorSource(progDlg).Progressor);
Geoprocessing.ShowMessageBox(gp_result.Messages, tool_path,
gp_result.IsFailed ? GPMessageBoxStyle.Error : GPMessageBoxStyle.Default);
return gp_result;
}
Anuj,
Matt is correct. The Pro SDK does not yet support Data Definition Language (DDL) operations directly. If you are writing a Pro Add-in, you need to use the geoprocessing API. In a stand-alone CoreHost application, you need to shell out to a Python script.
--Rich
Thanks Rich, Can we use ArcObjects .NET SDK & Pro SDK together in a CoreHost application ?
Anuj,
The Pro SDK is implemented in terms of ArcObjects. While I've never tried it personally, I expect the two APIs would interfere with each other. It's definitely not supported.
--Rich
@RichRuh, I have the same question. I have created a console application using template "ArcGIS Pro CoreHost application" in Visual Studio 2022. I am going to use this application work as a console application to update some feature's attributes in a feature class. I have added bunch of assemblies from C:\Program Files\ArcGIS\Pro\bin and C:\Program Files\ArcGIS\Pro\bin\Extensions folder. I have changed the Platform Target in Visual Studio from "Any CPU" to "x64". When run the application, I am able to connect to the enterprise geodatabase and the feature class. But when running at line "EditOperation editOperation = new EditOperation();", I get different assembly error. I am running ArcGIS Pro 3.0.3 and SDK 3.0. Is the a stand-alone CoreHost application not yet able to run such task? Thanks
Helen,
The only supported assemblies in CoreHost applications are `ArcGIS.Core.dll` and `ArcGIS.CoreHost.dll`. More detailed instructions for creating CoreHost applications can be found here.
--Rich
Thanks @RichRuh , do you mean other dll like ArcGIS.Desktop.Editing will not be supported? If that is the case, I have to create Microsoft VS Console app and add dll like ArcGIS.Desktop.Editing from there?
Hi Helen,
Sorry for the delayed response.
The only assemblies that work outside of ArcGIS Pro are `ArcGIS.Core.dll` and `ArcGIS.CoreHost.dll`. You can only use ArcGIS.Desktop.Editing if you are building a Pro add-in.
You can edit features using the geodatabase routines described here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Geodatabase#editing-in-stand-alone-mode
I hope this helps,
--Rich
Thanks @RichRuh . That has made things clear.