Want to Create a Select by Rectangle in ArcObjects using C#

2175
2
07-24-2014 04:27 PM
ThomasHasselbeck
New Contributor III

I'm creating an Add-in using ArcObjects and C#, technology I haven't used in 10 plus years.

I'm creating 3 tools that work on a specific polygon layer.

Tool 1 - Select by Line; summarize selected polygon areas

Tool 2 - Select by Polygon; summarize selected polygon areas

Tool 3 - Select by Rectangle; summarize selected polygon areas 

I found this sample;

ArcObjects Help for .NET developers

...and it works great for selecting my polygons using a line.

I was able to convert it pretty easily to selecting my polygons by using a polygon.

I changed theses lines;

private INewLineFeedback m_lineFeedback;

IPolyline polyline;

to

private INewPolygonFeedback m_lineFeedback;

IPolygon polygon; 

(and fixed all the errors that were generated.)

Now I want to do something like this;

private INewRectangleFeedback m_lineFeedback;

IRectangle rectangle;

It doesn't appear to be the same animal.

Can anyone give me a nudge as to the interfaces I need to implement?

I know I have to change some of the logic as well, since I'm not expecting a double click event (as shown in the sample).

Thanks

Tom

Tags (3)
0 Kudos
2 Replies
JeffMatson
Occasional Contributor III

INewRectangleFeedback.Stop returns an IGeometry object...you can test to see what type of IGeometry was returned, cast it to the correct type of object, and proceed from there.

0 Kudos
ThomasHasselbeck
New Contributor III

Hi Jeff -

Thanks for the reply.  I actually punted on this approach and took advantage of the selection set create by the all the native selection tools.  My Add-in simply does a summarize on the current selection set.  Dropped from 3 tools to one.

All the best

Tom

0 Kudos