TheSwamp

Code Red => .NET => Topic started by: waterharbin on April 13, 2015, 02:13:01 AM

Title: How to select Rectangles which are created by the RECTANG command
Post by: waterharbin on April 13, 2015, 02:13:01 AM
Hello,I would like to define a SelectionFilter to select the rectangles, lines, texts. And Here is what I have:
Code: [Select]
SelectionFilter flt = new SelectionFilter(new TypedValue[] { new TypedValue(0, "TEXT,MTEXT,LINE,POLYLINE") });

It works for lines and texts, but can not select rectangles.Those rectangles are all created by the RECTABG command. We click the Rectangle Icon on the toolbar to fire this command.

How can I do it right? I don't want to explode every rectangle.
Title: Re: How to select Rectangles which are created by the RECTANG command
Post by: Kerry on April 13, 2015, 02:26:10 AM
There is no RECTANGLE Type object.


One way to solve the problem is to select Polylines and then Test


Is the PLINE closed,
Does it have 4 sides ( check vertex count),
are the opposite sides the same length, or are the diagonals the same length,
Is one internal angle a right angle.


The process for each step is relatively simple.
Title: Re: How to select Rectangles which are created by the RECTANG command
Post by: waterharbin on April 13, 2015, 08:27:49 AM
Hello,Kerry,Thanks for your answer.
But there is still the problem, Rectangles are PolyLine objects, but my SelectionFilter just can not include PolyLine. I will need to select PolyLine before I make any judgment. So, is there any improvement for my SelectionFilter?
Title: Re: How to select Rectangles which are created by the RECTANG command
Post by: owenwengerd on April 13, 2015, 10:33:44 AM
Your rectangles are likely LWPOLYLINE objects. Try adding LWPOLYLINE to your filter list.
Title: Re: How to select Rectangles which are created by the RECTANG command
Post by: waterharbin on April 13, 2015, 11:25:57 AM
Hi, Owen. Thanks very much. That is what I want. :laugh:
Title: Re: How to select Rectangles which are created by the RECTANG command
Post by: rkmcswain on April 13, 2015, 03:37:43 PM
I have no business in the .NET forum.... but just wanted to say that it is possible for "rectangles" to be either an LWPOLYLINE or a POLYLINE.
According the documentation, the RECTANG command will always create an LWPOLYLINE, but anyone can create a rectangular shaped polygon with the PLINE command while PLINETYPE = 0.
Also, an LWPOLYLINE created with the RECTANG command can easily be converted to a POLYLINE with the CONVERTPOLY command.

So in summary, you can't assume that all "rectangles" will be LWPOLYLINES.

Title: Re: How to select Rectangles which are created by the RECTANG command
Post by: waterharbin on April 13, 2015, 09:42:38 PM
Hi
You are absolutly right. But in most cases, Rectangle is LWPOLYLINE. That is enough for me.