Wednesday, 23 November 2016

arcgis 10.0 - Get the geometry from the lasso selection tool


I'm building an Add-in solution in ArcGIS 10 that contains a custom tool. I'd like to borrow the functionality of the lasso selection tool without reinventing the wheel. Is there a way to intercept the geometry of the lasso selection area from the mouse up event? I want to pass the geometry of the lasso area to a spatial filter.



I know how to get control of the lasso tool with the following code in my custom tool class:


private ITool m_SelectTool;
protected override void OnActivate()
{
UID uid = new UID();
uid.Value = "esriArcMapUI.SelectByLassoTool";
ICommandItem commandItem = ArcMap.Application.Document.CommandBars.Find(uid, false, false);
ICommand command = commandItem.Command;
m_SelectTool = (ITool)command;
}


Answer



I don't think this is possible (intercepting another tool's private data/events), but the good news is that reinventing the wheel is pretty easy when the inventor shows you how to do it.


See the Custom selection extension Add-In Sample, particularly the SelectByLineTool class. You could tweak it to use a NewPolygonFeedback instead of a line feedback, and add points to it in OnMouseMove instead of OnMouseDown, and Stop the feedback in OnMouseDown instead of OnDoubleClick.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...