|
POST
|
Probably a bit overkill but you can find what you need after line 120: namespace LayerGeodatabaseVersion
{
/// <summary>
/// Extension methods for feature layer
/// </summary>
internal static class FeatureLayerExtensions
{
public static GeodatabaseType? GetGeodatabaseType(this BasicFeatureLayer layer)
{
if (layer.ConnectionStatus == ConnectionStatus.Broken)
return null;
GeodatabaseType? gdbType = GeodatabaseType.FileSystem;
using (var dataset = layer.GetTable())
{
using (var gdb = dataset.GetDatastore())
{
//new at 2.3
if (gdb is PluginDatastore)
{
return null;
}
//Note shapefile will be "FileSystemDatastore"
if (gdb is Geodatabase)
{
gdbType = ((Geodatabase)gdb).GetGeodatabaseType();
}
}
}
return gdbType;
}
public static RegistrationType? GetRegistrationType(this BasicFeatureLayer layer)
{
if (layer.ConnectionStatus == ConnectionStatus.Broken)
return null;
RegistrationType? regType = null;
using (var dataset = layer.GetTable())
{
regType = dataset.GetRegistrationType();
}
return regType;
}
public static EditOperationType? GetEditOperationType(this BasicFeatureLayer layer)
{
if (layer.ConnectionStatus == ConnectionStatus.Broken)
return null;
var gdbType = layer.GetGeodatabaseType();
var regType = layer.GetRegistrationType();
//Plugin - new at 2.3
if (gdbType == null)
return null;
//FileSystem
if (gdbType == GeodatabaseType.FileSystem)
return EditOperationType.Long;
//LocalDatabase
if (gdbType == GeodatabaseType.LocalDatabase)
return EditOperationType.Long;
//RemoteDatabase, Versioned
if (gdbType == GeodatabaseType.RemoteDatabase && (
regType == RegistrationType.Versioned || regType == RegistrationType.VersionedWithMoveToBase))
return EditOperationType.Long;
//RemoteDatabase, NonVersioned
if (gdbType == GeodatabaseType.RemoteDatabase && regType == RegistrationType.Nonversioned)
return EditOperationType.Short;
//Service, NonVersioned
if (gdbType == GeodatabaseType.Service && regType == RegistrationType.Nonversioned)
return EditOperationType.Short;
//Service, Versioned, Default
EditOperationType forBranch = EditOperationType.Long;
if (gdbType == GeodatabaseType.Service && regType == RegistrationType.Versioned)
{
using (var dataset = layer.GetTable())
using (var gdb = dataset.GetDatastore() as Geodatabase)
using (var vmgr = gdb.GetVersionManager())
using (var vers = vmgr.GetCurrentVersion())
using (var parent = vers.GetParent())
{
//non-default supports undo/redo and save/discard. Default does not
forBranch = parent != null ? EditOperationType.Long : EditOperationType.Short;
}
}
return forBranch;
}
}
internal class ShowLayerGDBVersion : Button
{
protected override async void OnClick()
{
try
{
await QueuedTask.Run(() =>
{
FeatureLayer theLayer = null;
var selectedLayers = MapView.Active.GetSelectedLayers();
if (selectedLayers.Count > 0)
{
theLayer = selectedLayers[0] as FeatureLayer;
}
if (theLayer == null)
{
theLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
}
if (theLayer == null)
{
throw new Exception("A Feature Layer is required.");
}
var gdbType = theLayer.GetGeodatabaseType();
var regType = theLayer.GetRegistrationType();
switch (gdbType.Value)
{
case GeodatabaseType.LocalDatabase:
MessageBox.Show($@"Feature Layer {theLayer.Name} is a local GDB datasource");
break;
case GeodatabaseType.RemoteDatabase:
using (Geodatabase geodatabase = theLayer.GetTable().GetDatastore() as Geodatabase)
using (Table table = theLayer.GetTable())
{
if (geodatabase == null)
{
throw new Exception($@"Feature Layer {theLayer.Name} is not stored in a Geodatabase");
}
var dbConnectionProps = (DatabaseConnectionProperties)geodatabase.GetConnector();
var nl = System.Environment.NewLine;
var dbConnectionDisp = $@"{theLayer.Name}:{nl} Database:{dbConnectionProps.Database}";
dbConnectionDisp += $@" Instance: {dbConnectionProps.Instance}";
dbConnectionDisp += $@" DBMS: {dbConnectionProps.DBMS}";
dbConnectionDisp += $@" RegType: {regType}";
dbConnectionDisp += $@" Version: {dbConnectionProps.Version}";
MessageBox.Show(dbConnectionDisp);
}
break;
case GeodatabaseType.FileSystem:
MessageBox.Show($@"Feature Layer {theLayer.Name} is a file system datasource");
break;
case GeodatabaseType.Service:
MessageBox.Show($@"Feature Layer {theLayer.Name} is a service based datasource");
break;
case GeodatabaseType.Memory:
MessageBox.Show($@"Feature Layer {theLayer.Name} is a memory datasource");
break;
default:
MessageBox.Show($@"Feature Layer {theLayer.Name} is a plugin datasource");
break;
}
});
}
catch (Exception ex)
{
MessageBox.Show (ex.Message);
}
}
}
}
... View more
04-27-2023
09:29 PM
|
1
|
0
|
1068
|
|
POST
|
Sorry about the delay. I noticed a problem with the variation of "Geoprocessing.ExecuteToolAsync" that you are using. It turns out that the 'progressor' parameter cannot be null. You can create a Progressor using this snippet: CancelableProgressorSource cps = new CancelableProgressorSource("Run GP", "Canceled");
var progressor = cps.Progressor; This variation of your code worked for me: protected async override void OnClick()
{
try
{
var intersectInputLyr1 = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(fl => fl.Name.Equals("TestPolygons")).FirstOrDefault();
var intersectInputLyr2 = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(fl => fl.Name.Equals("TestLines")).FirstOrDefault();
var intersectOutputFC = System.IO.Path.Combine(Project.Current.DefaultGeodatabasePath, "IntersectFc");
var intersectOutputSortFC = System.IO.Path.Combine(Project.Current.DefaultGeodatabasePath, "IntersectSortFc");
var AggregateField = "Description";
CancelableProgressorSource cps = new CancelableProgressorSource("Run GP", "Canceled");
var in_features = new List<FeatureLayer>() { intersectInputLyr1, intersectInputLyr2 };
var argsSortedIntersect = Geoprocessing.MakeValueArray(in_features,
intersectOutputFC,
"ALL",//join_attributes = "ALL",
null,//cluster_tolerance = None,
"INPUT"//output_type = "INPUT"
);
GPExecuteToolFlags noMapOutput = GPExecuteToolFlags.None;
// set overwrite flag
var env = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true);
await GPRun("analysis.Intersect", argsSortedIntersect, env, cps.Progressor, noMapOutput);
var Agg_para = Geoprocessing.MakeValueArray(intersectOutputFC, intersectOutputSortFC, AggregateField);
await GPRun("management.Sort", Agg_para, env, cps.Progressor);
var intersectInputLyr3 = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(fl => fl.Name.Equals("TestPoints")).FirstOrDefault();
var intersectOutputFc2 = System.IO.Path.Combine(Project.Current.DefaultGeodatabasePath, "IntersectPointFc");
var in_features2 = new List<FeatureLayer>() { intersectInputLyr3, intersectInputLyr2 };
var argsIntersect2 = Geoprocessing.MakeValueArray(in_features2, intersectOutputFc2);
GPExecuteToolFlags flag = GPExecuteToolFlags.GPThread;
await GPRun("analysis.Intersect", argsIntersect2, env, cps.Progressor, flag);
}
catch (Exception ex)
{
MessageBox.Show($@"Exception: {ex.ToString()}");
}
}
public async Task GPRun(string GPTool,
IReadOnlyList<string> parameters,
IEnumerable<KeyValuePair<string, string>> env = null,
CancelableProgressor prog = null,
GPExecuteToolFlags flag = GPExecuteToolFlags.Default)
{
try
{
var gp_result = await Geoprocessing.ExecuteToolAsync(GPTool, parameters, env, prog, flag);
if (gp_result != null) Geoprocessing.ShowMessageBox(gp_result.Messages, "Geoprocessing Result",
gp_result.IsFailed ? GPMessageBoxStyle.Error :
GPMessageBoxStyle.Default);
}
catch
{
var gp_result = await Geoprocessing.OpenToolDialogAsync(GPTool, parameters, env);
if (gp_result != null) Geoprocessing.ShowMessageBox(gp_result.Messages, "Geoprocessing Result",
gp_result.IsFailed ? GPMessageBoxStyle.Error :
GPMessageBoxStyle.Default);
}
}
... View more
04-27-2023
10:52 AM
|
0
|
0
|
1031
|
|
POST
|
You can get the envelope of the graphic element as described here: Solved: How to get 'envelope' from layout GraphicElement - Esri Community
... View more
04-27-2023
08:27 AM
|
0
|
1
|
622
|
|
POST
|
Sorry about that, somebody from Product Development will look at this issue and try to fix the problem with an upcoming 3.2 patch.
... View more
04-27-2023
08:18 AM
|
2
|
0
|
1486
|
|
POST
|
I use a helper method to output my event log info that is prefixing the output string with the assembly's name (i.e. Add-in name): internal static void WriteWarning (string line) => ArcGIS.Desktop.Framework.Utilities.EventLog.Write
(ArcGIS.Desktop.Framework.Utilities.EventLog.EventType.Warning,
$@"{System.Reflection.Assembly.GetExecutingAssembly().FullName.Split(',')[0]}: {line}"); Then I can filter using my Add-in name 'TableViewerTest':
... View more
04-26-2023
07:45 AM
|
0
|
0
|
662
|
|
POST
|
Regarding: "So we need 1 version of esriAddinX for each version of Pro 3.x that we support?" Answer: No. Regarding: "We were able to use the same file for all of Pro 2.x." If by saying the 'same file' you mean the 'esriaddinx' file (resulting from a build), then the same rules apply for Pro 3.x as for Pro 2.x. If you developed a 3.0 release of an Add-in using Pro 3.0 that Add-in (esriaddinx file) doesn't have to be rebuilt for all subsequent releases of 3.x. You don't have to touch those Add-ins at all, they will work for all 3.x releases of ArcGIS Pro. From your replies above i had assumed that you want to develop under a newer release of ArcGIS Pro (i.e. 3.1) and then deploy the esriaddinx on an older release (i.e. 3.0) then you might have a problem due to the reasons i stated above.
... View more
04-19-2023
03:29 PM
|
0
|
1
|
3612
|
|
POST
|
That's recommended: you develop using the same ArcGIS Pro version as your minimum target ArcGIS Pro version. Needless to say, if you know for sure that you're not using any newly introduced 3.1 API enhancements, you can just set the desktopVersion to 3.0 and test your Add-in's functionalities on a 3.0 machine. I actually do this quite often because i am always on the latest daily build (3.2.x now) and often i have to make a sample add-in for somebody on this forum who is still using 3.0 or 3.1. But i also know what functionality we added in the latest releases. If i have to make a sample for 2.9 or earlier i use a Virtual machine with an ArcGIS Pro 2.x environment.
... View more
04-19-2023
11:57 AM
|
0
|
1
|
3617
|
|
POST
|
You are correct as SaveItemDialog doesn't validate the path at all. I guess the designers of SaveItemDialog allowed for invalid paths to be entered assuming the caller would verify the validity. I tried this in ArcGIS Pro trying to save a layer by entering a path that doesn't exist: After i clicked save i get this message in Pro: i guess it's conceivable that the calling business logic could attempt to create the path if it doesn't exist. However, in ArcGIS Pro after the error is displayed, the caller immediately pops up the SaveItemDialog again with the 'bad path entry' using the bad path as the initial location:
... View more
04-19-2023
08:19 AM
|
0
|
1
|
1630
|
|
POST
|
Not sure what your code is doing, but i attached a project with two Modal ProWindows. One is WinForms based and one is Mvvm based. Please build and run this project and see if this satisfies your needs. Here is one of these 'modal' Pro Windows, and no user input for ArcGIS Pro is accepted until you close the Pro Window.
... View more
04-18-2023
08:00 PM
|
0
|
0
|
3296
|
|
POST
|
You should ONLY develop and test your add-in with the MINIMUM ArcGIS Pro version that your add-in targets. So for example, if you develop with ArcGIS Pro version 3.1 your AddInInfo tag in the config.daml should only be reading like this: <AddInInfo id="..." version="x.x" desktopVersion="3.1.41833"> You cannot simply change the desktopVersion attribute to 3.0 because the ArcGIS Pro API is enhanced with each release and new API classes, properties, and methods are ADDED to the API. To maintain compatibility no API classes, properties, etc are removed with a new release, since that would break compatibility. So if you develop under ArcGIS Pro 3.1 and use any property, class or method that was added with the 3.1 release and you set desktopVersion to 3.0, your add-in will not work with a ArcGIS Pro 3.0 desktop release. See ProConcepts Advanced Topics · Esri/arcgis-pro-sdk Wiki (github.com)
... View more
04-18-2023
02:23 PM
|
4
|
2
|
3667
|
|
POST
|
the AddInInfo attribute desktopVersion="2.9.0" shows the MINUMUM 2.x release number your add-in is compatible with. This means that your add-in only works with 2.9.0, 2.9.1, 2.9.2 ... 2.10.0 etc. NOT with 2.6
... View more
04-18-2023
02:09 PM
|
0
|
0
|
1520
|
|
POST
|
If you develop an add-in under version 2.3 it will work for all newer 2.x releases (including 2.9), without having to rebuild the 2.3 add-in under 2.9. ProConcepts Advanced Topics · Esri/arcgis-pro-sdk Wiki (github.com) The compatibility is defined by the 'desktopVersion' attribute of the 'AddInInfo' tag in config.daml. 'desktopVersion' defines the oldest release your add-in is compatible with, however, compatibility is only maintained within each mayor version number (1.x, 2.x, 3.x). So a 2.3 desktopVersion will not work with 3.x.
... View more
04-18-2023
01:49 PM
|
0
|
1
|
1535
|
|
POST
|
You can use the AddOverlay and AddOverlayAsync methods that are available for the MapView class: ProConcepts Map Exploration · Esri/arcgis-pro-sdk Wiki (github.com) AddOverlay Method (MappingExtensions)—ArcGIS Pro Or you can look at the attached sample that stores a reference to the MapTool in the Module class and uses the MapTools AddOverlay method. However, when you switch the tool the map point on the map will disappear. The tool looks like this:
... View more
04-18-2023
07:55 AM
|
0
|
1
|
1575
|
|
POST
|
The input geometry is not passed through to the event handler. You can easily write your own tool by creating a MapTool, then changing the SketchType (Rectangle, Line, Polygon etc.), and adding these lines to the OnSketchCompleteAsync method: protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
QueuedTask.Run(() =>
{
var selectionSet = MapView.Active.SelectFeatures(geometry);
OnMySelectionEvent(geometry, selectionSet);
});
return base.OnSketchCompleteAsync(geometry);
} Now you call your own event handler passing in the selection and the geometry.
... View more
04-17-2023
04:57 PM
|
0
|
1
|
728
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-07-2025 07:27 AM | |
| 2 | 2 weeks ago | |
| 1 | 07-30-2025 12:03 PM | |
| 1 | 10-06-2025 01:19 PM | |
| 1 | 10-06-2025 10:37 AM |
| Online Status |
Offline
|
| Date Last Visited |
18 hours ago
|