I know that I can access the currently selected entities when the user clicks on custom button via Map.GetSelection.
But let's say that I need the user to select a polyline somewhere along the way. Probably even from a wpf window because I need to get some information like length or num vertices from some polyline. Like this:
When the user clicks on "From Polyline", he can select a polyline and my code can determine the number of segments of that polyline and the result is displayed in the textbox.
Is that actually possible? And if yes, is there a best practice for doing this?
What I'm basically looking for is a "pick mechanic" just like AutoCAD offers. And since I'm coming from an AutoCAD background, I've been doing this a lot and I figured it should be doable in ArcGIS Pro as well 🙂
Thanks in advance and Best Regards
one way to achieve this would be to plug in the existing Pro select tool.
Please do take a look at this example arcgis-pro-sdk-community-samples/Framework/HookProCommands at master · Esri/arcgis-pro-sdk-community...
These are the steps you need to consider for achieving something you requested.
First, you know need to create a map tool. Second, you need to create a dock pane or anything you want for your UI. Third, you need a way of communication between map tool and your dock pane (there are several options but the one I am using is events) In the map tool OnSketchCompleteAsync we publish the event args in Dock pane we subscribe and update the value of our UI textbox with the number of selected features(in this example I am simply publishing the number of selected segments, you can publish total length or object from map tool). Please make sure you change the layer name inside SelectMapTool.cs file to your desired layer name. I have copied the codes in this repo.
thanks a lot for the detailed description. It looks like something I can use! I'll check it out in more detail after I return from the holidays next January.