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
|
106
|
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
|
571
|
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
|
572
|
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
|
250
|
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
|
344
|
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
|
373
|
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
|
417
|
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
|
413
|
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
|
327
|
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
|
376
|
POST
|
You can look at this example: arcgis-pro-sdk-community-samples/MVVM-XAML/DockpaneWithListCheckbox at master · Esri/arcgis-pro-sdk-community-samples (github.com)
... View more
02-21-2024
10:14 AM
|
1
|
1
|
328
|
POST
|
As far as i can tell from looking at ArcGISLayout.daml the following condition has to be met: id="esri_layouts_selectedElementsNotPartsCondition" The description for the condition says: "Elements are selected in the active layout view and FORMAT selection is set to the whole element not a part." I used your code and it's working fine for me: protected override void OnClick()
{
try
{
LayoutView layoutView = LayoutView.Active;
Layout layout = layoutView.Layout;
var tmpTextElement = layout.FindElement("TestText 1");
var tmpPunktElement = layout.FindElement("Point");
layout.SelectElements(new List<ArcGIS.Desktop.Layouts.Element> { tmpTextElement, tmpPunktElement });
MessageBox.Show($@"Selected: {layout.GetSelectedElements().Count}");
var pluginWrapperDistributeAlignMiddle = FrameworkApplication.GetPlugInWrapper("esri_layouts_alignMiddle", true) as ICommand;
if (pluginWrapperDistributeAlignMiddle != null)
{
if (pluginWrapperDistributeAlignMiddle.CanExecute(null))
{
pluginWrapperDistributeAlignMiddle.Execute(null);
}
else
MessageBox.Show("Can't execute");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} These are my two sample elements to be aligned: After the alignment button completes i see this:
... View more
01-11-2024
07:39 AM
|
0
|
1
|
421
|
POST
|
That is what i suspected. It appears that the KML underlying data model has some limitations that restrict it's usage. ArcGIS Pro documentation shows a bit more detail about this and suggests a workaround to overcome those limitations: What is KML?—ArcGIS Pro | Documentation "KML elements can include information that can be viewed in pop-ups, but there is no provision for attributes for KML features. A KML layer does not have an associated attribute table. You cannot select KML features or use them in analysis. If you want to work with this data in the same way as other GIS data, use the KML To Layer tool to convert a KML (or KMZ) file into feature classes in a file geodatabase. This tool also creates a corresponding layer file that reflects the symbology established in the KML file."
... View more
01-05-2024
05:27 AM
|
1
|
0
|
738
|
POST
|
You can see the DefinitionSetURI as the key to the QueryDefinition that defines your selection set that was used to create your layer (created using "Make Layer From Selected Features"). So in essence if you don't have a selection set then you don't have a layer created using "Make Layer From Selected Features". And the DefinitionSetURI is persisted (so it's not in memory), because you can close and reopen your project and see the same feature selection. I don't have an answer on the KML layer, maybe KML layers can't store a 'selection set'. I noticed that Pro developers added the CIMKMLLayer condition to their code, so I used copy/paste inheritance. If you have some KML data you can try to create a layer from selection.
... View more
01-03-2024
11:27 AM
|
0
|
1
|
752
|
POST
|
Sorry my bad, i didn't copy all code needed: protected override async void OnClick()
{
try
{
//get selected layer in toc
var featLayer = MapView.Active.GetSelectedLayers().First() as FeatureLayer;
if (featLayer == null)
return;
CIMBaseLayer baseLayer = await QueuedTask.Run (() => featLayer.GetDefinition());
var definitionSetURI = GetDefinitionSetURI(baseLayer);
var isSelectionLayer = !string.IsNullOrEmpty(definitionSetURI);
MessageBox.Show($@"Is selection layer: {isSelectionLayer}");
}
catch (Exception ex)
{
MessageBox.Show($@"Error: {ex.Message}\n{ex.StackTrace}");
}
}
internal static string GetDefinitionSetURI(CIMBaseLayer baseLayer)
{
if (baseLayer is CIMGeoFeatureLayerBase geoFeatureLayerBase)
return (geoFeatureLayerBase.FeatureTable?.DefinitionSetURI);
else if (baseLayer is CIMKMLLayer kmlLayer)
return (null);
else if (baseLayer is CIMAnnotationLayer annotationLayer)
return (annotationLayer.FeatureTable?.DefinitionSetURI);
else if (baseLayer is CIMDimensionLayer dimensionLayer)
return (dimensionLayer.FeatureTable?.DefinitionSetURI);
return (null);
}
... View more
01-02-2024
12:02 PM
|
1
|
1
|
763
|
Title | Kudos | Posted |
---|---|---|
1 | 07-22-2024 03:36 PM | |
1 | 05-24-2024 10:13 AM | |
1 | 05-24-2024 08:57 AM | |
1 | 03-26-2024 02:27 PM | |
1 | 02-21-2024 10:14 AM |
Online Status |
Offline
|
Date Last Visited |
Friday
|