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
3 weeks ago
|
1
|
0
|
117
|
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
|
172
|
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
|
210
|
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
|
473
|
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
|
487
|
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
|
498
|
POST
|
This worked for me: 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}");
}
}
... View more
12-19-2023
09:25 AM
|
0
|
0
|
547
|
POST
|
I think you should be able to use Geodatabase DDL to modify that table using schemaBuilder.Modify(modifiedTableDescription); ProConcepts DDL · Esri/arcgis-pro-sdk Wiki (github.com) To create an object ID field use this code snippet: ProSnippets Geodatabase · Esri/arcgis-pro-sdk Wiki (github.com)
... View more
12-11-2023
02:05 PM
|
0
|
2
|
299
|
POST
|
This must be a Mac specific issue because the search on my Window 11 OS with Visual Studio 2022 17.8 works as expected:
... View more
12-05-2023
06:25 AM
|
0
|
0
|
365
|
POST
|
In order to place your callouts differently for each point (manually or programmatically) you have to use either an annotation class or a graphics layer. If you create a callout annotation feature programmatically you can take a look at this 'AnnoTools' example: arcgis-pro-sdk-community-samples/Editing/AnnoTools/Modify/SimpleLineCallout.cs at master · Esri/arcgis-pro-sdk-community-samples (github.com) The sample modifies the selected annotation feature and uses SetAnnotationProperties to store the changes to the annotation properties (including the text symbol). This means that each annotation feature can have a different offset and/or position of the callout. Once callouts have been added to the annotation feature class they can be 'edited' (for repositioning) using Pro's out-of-box tools (Edit | Modify | Annotation): This tool allows you to click on the callout and reposition it. To add your own button to invoke this tool you can simply call on the existing tool: protected override void OnClick()
{
var command = FrameworkApplication.GetPlugInWrapper("esri_editing_EditVerticesText") as ICommand;
if (command.CanExecute(null))
command.Execute(null);
}
... View more
11-30-2023
05:07 PM
|
0
|
0
|
153
|
POST
|
If you use EditOperation your changes and additions end up in undo/redo stacks and the data is not saved until Project.SaveEditsAsync is called. The ArcGIS Pro API doesn't support selective saving of changes in the undo/redo stacks. You can't select the changes in one feature class and leave other changes on the redo/undo stack. If you have edits to a particular featureclass you could try Geodatabase.ApplyEdits as documented here: ProConcepts Geodatabase · Esri/arcgis-pro-sdk Wiki (github.com) ApplyEdits is only recommended for "Editing in stand-alone mode" but last time i tried it works on Add-ins as well. I think this is the only option for your particular use case.
... View more
11-27-2023
10:24 AM
|
0
|
1
|
292
|
POST
|
In order to consider left-handedness, you can use this code snippet (i didn't test this one): [DllImport("user32.dll")]
public static extern short GetAsyncKeyState(UInt16 virtualKeyCode);
public const int VK_LBUTTON = 0x01;
public const int VK_RBUTTON = 0x02;
private short _lastMouseButtonState = -1;
[DllImport("user32.dll")]
public static extern Int32 GetSystemMetrics(Int32 bSwap);
public const int SM_SWAPBUTTON = 23;
...
var logicalLeftButton = Convert.ToUInt16(GetSystemMetrics(SM_SWAPBUTTON) != 0 ? VK_RBUTTON : VK_LBUTTON);
var mouseButtonState = GetAsyncKeyState(logicalLeftButton);
... View more
11-15-2023
07:12 AM
|
0
|
0
|
261
|
POST
|
This custom tool did the pan of the map for me: internal class MousePanTool : MapTool
{
[DllImport("user32.dll")]
public static extern short GetAsyncKeyState(UInt16 virtualKeyCode);
public const int VK_LBUTTON = 0x01;
private short _lastMouseButtonState = -1;
private System.Windows.Point _fromMousePoint = new() { X = double.NaN, Y = double.NaN };
private System.Windows.Point _toMousePoint = new() { X = double.NaN, Y = double.NaN };
public MousePanTool()
{
SketchOutputMode = SketchOutputMode.Map;
}
/// <summary>
/// Called when the mouse button is clicked in the view.
/// </summary>
protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e)
{
if (e.ChangedButton == System.Windows.Input.MouseButton.Left)
{
_fromMousePoint = e.ClientPoint;
e.Handled = true;
System.Diagnostics.Trace.WriteLine("!!! OnToolMouseDown");
}
base.OnToolMouseDown(e);
}
/// <summary>
/// Called when the mouse button is released in the view.
/// </summary>
protected override void OnToolMouseUp(MapViewMouseButtonEventArgs e)
{
if (e.ChangedButton == System.Windows.Input.MouseButton.Left)
{
e.Handled = true;
_fromMousePoint = new() { X = double.NaN, Y = double.NaN };
System.Diagnostics.Trace.WriteLine("!!! OnToolMouseUp");
}
base.OnToolMouseUp(e);
}
private bool _isPanning = false;
protected override async void OnToolMouseMove(MapViewMouseEventArgs e)
{
var mapView = MapView.Active;
if (mapView == null || _isPanning)
return;
var mouseButtonState = GetAsyncKeyState(VK_LBUTTON);
if ((mouseButtonState & 0x8000) == 0x0)
{
// the physical left button is not down anymore - stop panning
_fromMousePoint = new() { X = double.NaN, Y = double.NaN };
if (_lastMouseButtonState != mouseButtonState)
{
System.Diagnostics.Trace.WriteLine("!!! MouseUp during mouse move");
_lastMouseButtonState = mouseButtonState;
}
return;
}
_lastMouseButtonState = mouseButtonState;
if (_fromMousePoint.X != double.NaN)
{
_toMousePoint = e.ClientPoint;
_isPanning = true;
try
{
await QueuedTask.Run(() =>
{
var fromPoint = mapView.ClientToMap(_fromMousePoint);
var toPoint = mapView.ClientToMap(_toMousePoint);
var deltaX = toPoint.X - fromPoint.X;
var deltaY = toPoint.Y - fromPoint.Y;
var camera = mapView.Camera;
camera.X -= deltaX;
camera.Y -= deltaY;
mapView.PanTo(camera);
_fromMousePoint = _toMousePoint;
});
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex);
}
finally
{
_isPanning = false;
}
_isPanning = false;
e.Handled = true;
}
}
protected override Task OnToolActivateAsync(bool active)
{
_fromMousePoint = new() { X = double.NaN, Y = double.NaN };
return base.OnToolActivateAsync(active);
}
protected override Task OnToolDeactivateAsync(bool active)
{
_fromMousePoint = new() { X = double.NaN, Y = double.NaN };
return base.OnToolActivateAsync(active);
}
} This sample only works for 'right-handed' mouse configurations, meaning the left mouse button is the 'physical' left mouse button. To consider a 'left-handed' mouse configuration you can determine the system's current mapping of physical mouse buttons to logical mouse buttons by calling GetSystemMetrics(SM_SWAPBUTTON) which returns TRUE if the mouse buttons were swapped. Instead of writing your own custom navigation you can also reuse the map navigation functionality that's built into ArcGIS Pro: var command = FrameworkApplication.GetPlugInWrapper("esri_mapping_exploreTool") as ICommand;
if (command.CanExecute(null))
command.Execute(null);
... View more
11-15-2023
06:55 AM
|
0
|
1
|
261
|
POST
|
There is a community sample that shows different variations of reusing ProCommands: arcgis-pro-sdk-community-samples/Framework/ReusingProCommands at master · ArcGIS/arcgis-pro-sdk-community-samples (github.com)
... View more
11-13-2023
01:54 PM
|
0
|
0
|
324
|
POST
|
Sorry i got a bit derailed with 3.2 release issues (upcoming in the next couple of weeks). Anyways, i am back on it now. I will take a look at your test as well. Thanks much.
... View more
10-23-2023
01:20 PM
|
0
|
0
|
331
|
Title | Kudos | Posted |
---|---|---|
1 | 3 weeks ago | |
1 | 02-21-2024 10:14 AM | |
1 | 01-05-2024 05:27 AM | |
1 | 01-02-2024 12:02 PM | |
1 | 07-30-2021 12:30 PM |
Online Status |
Offline
|
Date Last Visited |
a week ago
|