POST
|
I have experienced this issue myself and traced it back to some random issue with the XAML designer. The errors you are seeing are only 'XAML Designer' errors and usually the errors go away when you close the 'XAML Designer'. The error output is caused by a bug in the 'XAML Designer' and therefore you can 'build and run' the app and bring up your dockpane, even with these 'XAML Designer' errors. Sometimes i was able to fix the issue by closing the solution, deleting the obj and bin folders, reopening the solution and then performing a 'rebuild all'.
... View more
01-06-2025
02:39 PM
|
0
|
0
|
86
|
POST
|
It looks like there's a gap in the ArcGIS Pro API. Normally you would call FrameworkApplication.ContextMenuDataContext to get the 'underlying' (to your right click) tool. The problem is that the returned object is an ArcGIS Pro internal class and hence you can't use that class in your add-in. There is a workaround using reflection that allows you to access the underlying 'tool' context. However, be advised that this solution is outside the Pro API framework and hence subject to change. We will submit a new requirement to the Geoprocessing team for consideration. In order to get the current (right clicked) tool insert this code inside your 'OnClick' button function: protected override void OnClick()
{
try
{
var toolInfo = FrameworkApplication.ContextMenuDataContext; //as ArcGIS.Desktop.GeoProcessing.ToolInfoViewModel;
// internal class ToolInfo:
// public string Name
// public string Description
// public string ToolType
// public bool IsValid
// public string ToolBoxName
// public string FullPath
// public bool IsSystem
// public string toolName
string name = (string)toolInfo.GetType().GetProperty("Name").GetValue(toolInfo, null);
string description = (string)toolInfo.GetType().GetProperty("Description").GetValue(toolInfo, null);
string toolType = (string)toolInfo.GetType().GetProperty("ToolType").GetValue(toolInfo, null);
string toolBoxName = (string)toolInfo.GetType().GetProperty("ToolBoxName").GetValue(toolInfo, null);
string fullPath = (string)toolInfo.GetType().GetProperty("FullPath").GetValue(toolInfo, null);
string toolName = (string)toolInfo.GetType().GetProperty("toolName").GetValue(toolInfo, null);
bool isValid = (bool)toolInfo.GetType().GetProperty("IsValid").GetValue(toolInfo, null);
bool isSystem = (bool)toolInfo.GetType().GetProperty("IsSystem").GetValue(toolInfo, null);
string nl = Environment.NewLine;
MessageBox.Show($@"Type of toolInfo: {toolInfo.GetType().ToString()}{nl}"
+ $@"name: {name}{nl}"
+ $@"description: {description}{nl}"
+ $@"toolType: {toolType}{nl}"
+ $@"toolBoxName: {toolBoxName}{nl}"
+ $@"fullPath: {fullPath}{nl}"
+ $@"toolName: {toolName}{nl}"
+ $@"isValid: {isValid}{nl}"
+ $@"isSystem: {isSystem}{nl}");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} Sample output:
... View more
01-06-2025
02:15 PM
|
0
|
1
|
121
|
POST
|
Are you deleting the field using the UI or are you deleting the field programmatically or are you using a Geoprocessing tool? Can you provide a sample snippet?
... View more
01-03-2025
12:12 PM
|
1
|
1
|
295
|
POST
|
When you use ExecuteToolAsync in a loop, I would recommend setting the GPExecuteToolFlags to GPExecuteToolFlags.None (GPExecuteToolFlags Enumeration—ArcGIS Pro) except for your last loop. For your last ExecuteToolAsync call use GPExecuteToolFlags.Default
... View more
11-07-2024
07:56 AM
|
1
|
0
|
177
|
POST
|
If you drag an 'Item' from the Catalog pane (specifically a Geodatabase item) you will have a Feature Class or a Table. Feature Layers are part of the map, so you can't have a feature layer without adding a feature class to the map first. However, you can perform operations on Feature Classes as well as Tables. I attached a drag/drop sample the takes a dropped feature class (point) or table and displays it's content. The sample requires 3.3 Dragging a Point feature class Showing the dropped content
... View more
07-22-2024
03:36 PM
|
1
|
0
|
490
|
POST
|
I tried the drag and drop as well and found no additional issues. Regarding the 'esri_mapping_snapChipToggleButton' error you saw in your log file: It is possible that the initial exception thrown by the 'wrong thread' exception caused this issue. It is also possible that other add-ins were affected by this exception as well. When testing add-ins for exceptions is best to remove other add-ins during the test session. I checked the WorkingWithQueryDefinitionFilters code sample and it didn't make use of the 'esri_mapping_snapChipToggleButton' daml id.
... View more
06-03-2024
04:16 PM
|
0
|
3
|
1438
|
POST
|
I tried the sample snippet you referred to above and did notice an issue with the sample. If you look at the "private void GetMapMembers(MapView mapView)" method, you can see that this method is always running on the thread it is called from. Unfortunately, when the 'query definition' custom dockpane is open and a new featureclass or table is added to the current map, this method is called from a background thread which in turn is throwing an exception. So to correct this i made the following changes to the sample: private void GetMapMembers(MapView mapView)
{
RunOnUiThread(() =>
{
MapMembers.Clear();
if (mapView != null)
{
var tocLayers = mapView.Map.GetLayersAsFlattenedList().OfType<BasicFeatureLayer>().ToList();
var tocTables = mapView.Map.StandaloneTables.ToList();
if (tocLayers.Count > 0 || tocTables.Count > 0)
{
tocLayers.ForEach(x => _mapMembers.Add(x));
tocTables.ForEach(t => _mapMembers.Add(t));
var selectedMapMember = GetSelectedMapMemberInTOC();
if (selectedMapMember != null) //mapmember has been selected
SelectedMapMember = selectedMapMember; //Show that map member's filters
else
SelectedMapMember = MapMembers[0]; //default. Nothing selected in TOC
}
//If no feature layers, show empty dockpanes(DockpaneVisibility)
DockpaneVisibility = MapMembers.Count == 0 ? Visibility.Hidden : Visibility.Visible;
}
});
} And here are the supporting functions: #region Threading Utilities
/// <summary>
/// utility function to enable an action to run on the UI thread (if not already)
/// </summary>
/// <param name="action">the action to execute</param>
/// <returns></returns>
internal static Task RunOnUiThread(Action action)
{
if (OnUIThread)
{
action();
return Task.FromResult(0);
}
else
return Task.Factory.StartNew(action, System.Threading.CancellationToken.None, TaskCreationOptions.None, QueuedTask.UIScheduler);
}
/// <summary>
/// determines if the application is currently on the UI thread
/// </summary>
private static bool OnUIThread
{
get
{
if (FrameworkApplication.TestMode)
return QueuedTask.OnWorker;
else
return System.Windows.Application.Current.Dispatcher.CheckAccess();
}
}
#endregion I will try drag and drop and some other test cases next, but in general I would recommend embedding all custom code in try {} catch {} to prevent crashes that are caused by uncaught exceptions with no error message.
... View more
06-03-2024
03:50 PM
|
0
|
0
|
1439
|
POST
|
Please check out Uma's reply in this thread: How to drag a feature layer from table of contents... - Esri Community
... View more
05-24-2024
11:37 AM
|
0
|
0
|
480
|
POST
|
I cannot duplicate your issue. When you say you migrated your add-in to 3.3 did you upgrade your project to target .NET 8.0? I have a 3.1 add-in with a MapTool that also is using the HandleMouseDownAsync overrise and it worked fine under 3.3. When i migrated the project to ArcGIS Pro 3.3 i get the following when i hover over the HandleMouseDownAsync override: Also can you check the definition for Task? It should be defined as follows:
... View more
05-24-2024
10:13 AM
|
1
|
0
|
717
|
POST
|
It turns out that the DotNet.exe command line tool has a command line option to override the target .NET version by using the --fx-version command line switch. Here is an example of the command line that overrides the target .NET to "8.0.5": "C:\Program Files\dotnet\dotnet.exe" exec --fx-version "8.0.5" CoreHostTest31Build.dll The problem is that the new target .NET version has to be the exact version designation. So in the example above it is not possible to simply specify "8.*" but instead one has to specify "8.0.5" or whatever the current patch level of .NET which has been installed on the machine. Implementing this command line option alleviates the need for overwriting any .json configuration files. I attached a new version of RunCoreHostApp that is using this DotNet command line option to run any CoreHost app with the correct version of .NET.
... View more
05-24-2024
08:57 AM
|
1
|
0
|
961
|
POST
|
@StephenDavis1 Pro SDK documentation only mentions that ‘Add-ins’ are forward compatible between minor versions. If you write a CoreHost standalone app for ArcGIS Pro 3.1 you can achieve forward compatibility as well, but there are a few caveats: Your CoreHost app is in essence a .NET console app with references to the following ArcGIS Pro assemblies: ArcGIS.Core and ArcGIS.CoreHost. You have to make sure that the “Copy Local” attribute for these references is set to “NO”. You also have to add code in your CoreHost app to resolve the path to these assemblies (they are located in the ArcGIS Pro installation bin folder). This ensures that your CoreHost application is actually running the assemblies that are installed with ArcGIS Pro and not a potentially outdated (or mismatched versions) assembly copy included with your CoreHost app. Also, your CoreHost app cannot be a ‘self-contained’ .NET application, instead it has to have a ‘Target Framework’. In order to implement this, you have to edit your .CSPROJ file and add the following setting under the property group: <SelfContained>false</SelfContained> When a console app is ‘self-contained’, the runtime for the target .NET version is included with the binary output when the console application is built. However, this feature is not desirable because this would mean that your .NET runtime version is static. If you follow the steps above your CoreHost standalone app can be forward compatible, but the problem is that the app will only allow the target .NET version to be loaded. So, in our case since you built the app using the Pro SDK 3.1 this means that the CoreHost app is permanently linked to .NET 6.0 (or any minor release of .NET 6.0). I added a small sample project called ‘CoreHostTest31Build’ to this post so you can see an implementation of a ‘forward compatible’ capable CoreHost app. If you look at the .json files included with the corehost app you will notice that they are ‘bound’ to a specific .NET target of .NET 6.0, which means that the CoreHost app will not work under ArcGIS Pro 3.3 since Pro 3.3 requires .NET 8.0. You will get this error: > CoreHostTest31Build C:\Data\FeatureTest\FeatureTest.gdb Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. You can see that the CoreHost app is trying to load .NET 8.0 because ArcGIS Pro 3.3 requires .NET 8.0. However, the CoreHost app is bound to .NET 6.0 and hence the loading of .NET 8.0 fails. This problem can be fixed by updating the .NET target framework version is the CoreHost’s CoreHost.deps.json file and CoreHost.runtimeconfig.json to .NET 8.0. You can do this manually before you call your CoreHost app from the command line, or you can use the RunCoreHostApp command line utility to run your CoreHost app under ArcGIS Pro 3.1, 3.2, or 3.3. This app will make the .json file changes for you: RunCoreHostApp CoreHostTest31Build C:\Data\FeatureTest\FeatureTest.gdb I included the RunCoreHostApp solution. After you build the solution simply copy the executable into your CoreHost executable folder, now you have ‘forward compatibility’.
... View more
05-22-2024
01:56 PM
|
0
|
0
|
1005
|
POST
|
The desktopVersion attribute in the AddInInfo tag in your config.daml determines whether an add-in is included by the current version of ArcGIS Pro. In essence 'desktopVersion' has to be less than the current version of ArcGIS Pro. However, the version in desktopVersion doesn't include the patch version number i.e. ArcGIS Pro version 3.2.1 will work with desktopVersion 3.2 <AddInInfo id="{e1515785-a28f-44f5-9c13-9f6eaab0434f}" version="1.0" desktopVersion="3.2.49743"> I would suggest changing the desktop version number. Make sure that the esriaddinx file in your Add-in folder is replaced after you rebuilt your add-in.
... View more
05-14-2024
01:36 PM
|
0
|
0
|
787
|
POST
|
The reason why GetCurrentSketchAsync returns null is because you call the method after the sketching is already finished. GetCurrentSketchAsync is meant to support modifying the sketch while sketching is in progress. You can check-out the use in the Editing\RestartSketch community sample to see a use of changing a sketch while sketching is in progress. If you want to use a sketched polygon after the sketching is finished, you have to create your own construction tool and save the sketched geometry in a graphics layer (or any other layer). The following sample contains the code to create a polygon (you have to change the SketchType to rectangle) and this MapTool will allow you to complete a sketch which is then stored in the graphics layer: arcgis-pro-sdk-community-samples/Framework/CopyPaste/CreatePolygon.cs at master · Esri/arcgis-pro-sdk-community-samples (github.com) Please note that the latest community samples are release 3.3 samples that require .NET 8. If you want to build the latest community samples on releases 3.0 - 3.2 you have to change the project's target framework to .NET 6.
... View more
05-10-2024
11:45 AM
|
0
|
2
|
718
|
POST
|
I tested the "DisplayName", "IsVisible", and the "FieldOrder" properties of CIMReportField and i was not able to get any of these properties to work as expected. Also, the ‘ReportDataSource’ method doesn’t use the ‘useSelectionSet’ parameter as documented. When i set the parameter to false the report still only shows the selected features. I asked the Report API dev team to take a look at this, however, in the meantime i would recommend using the Alias in the Fields definition: To hide a column just don't add the column to the CIMReportField array. To change the order you have to re-arrange the order in your CIMReportField array. And in order to add all records to your report you need to clear all selected features before you run (export/preview) the report. If the selected features are not cleared only the selected features will appear in your report. I reply on this thread after i hear back from the Report API dev team.
... View more
03-26-2024
02:27 PM
|
1
|
0
|
571
|
Title | Kudos | Posted |
---|---|---|
1 | 01-26-2023 01:46 PM | |
1 | 01-03-2025 12:12 PM | |
1 | 11-07-2024 07:56 AM | |
1 | 06-03-2020 09:11 AM | |
1 | 11-27-2023 10:24 AM |
Online Status |
Offline
|
Date Last Visited |
yesterday
|