Select everything within a closed polyline?

3269 views
Skip to first unread message

Kirsten

unread,
Mar 8, 2002, 10:25:44 AM3/8/02
to
Is there a way to select everything within a closed polyline by simply
selecting the polyline?

(Please note: This is not the same as the cpolygon or wpolygon. You have
to pick each individual point for that command. I just want to select the
line.)

Jason gave me the following lisp file (see below), but I don't know Lisp, so
I'm trying to translate it to VBA. I can select the polyline with the
SelectOnScreen command, and can select every entity within the drawing, but
am unsure how to test if the entity is within the boundary.

Has this already been done or am I reinventing the wheel?
TIA, -Kirsten

Lisp file:
(defun C:Test ()
(ssget "wp" (massoc 10 (entget (car (entsel "\nselect polyline:")))))
)


(defun massoc (key alist / x nlist)
(foreach x alist
(if (eq key (car x))
(setq nlist (cons (cdr x) nlist))
)
)
(reverse nlist)
)


TomD

unread,
Mar 8, 2002, 11:24:43 AM3/8/02
to
Kirsten <kirste...@co.anoka.mn.us> wrote in message
news:F6409595ABA5F486...@in.WebX.maYIadrTaRb...

> Is there a way to select everything within a closed polyline by simply
> selecting the polyline?
<SNIPPED>

> Has this already been done or am I reinventing the wheel?
> TIA, -Kirsten

Have you looked into the SelectionSet.SelectByPolygon method? It sounds
like exactly what you need. If you need help with the point retrieval,
there are a couple of web sites with good descriptions on getting LWPoly and
Polyline point lists.

A word of caution: I did something similar to that with lips a few years
back, but using the SSGET function of lisp, with the WP option (I think)
only picked up objects currently visible on-screen. If the user selected a
polyline that went beyond the current zoom scale, objects would be
potentially missed. I don't know if this is still true, or what would
eliminate the problem, but something to consider and test for. I just gave
up on it, because I didn't need it very often.

THT

Minkwitz Design

unread,
Mar 8, 2002, 11:45:17 AM3/8/02
to
Hi Kirsten,
Try grabbing the polyline with getentity or selectonscreen like you are
doing, then test the entity to verify it is a closed polyline. Once you
have that, you should be able to just pass the coordinates property of
the polyline to the "points list" argument of the selectbypolygon
method, giving you a new selectionset of the entities within the
original polyline.
-Josh

Laurie Comerford

unread,
Mar 8, 2002, 1:49:31 PM3/8/02
to
Hi,

To over come the object not on screen issue:
After selecting the polyline get its boundingbox and do a zoom centre on the
middle of the bounding box with a scale matching twice the diagonal length.

--


Laurie Comerford
CADApps
www.cadapps.com.au

"TomD" <nospam.dc...@stargate.net> wrote in message
news:A3ECAD2A97ADB524...@in.WebX.maYIadrTaRb...


> Kirsten <kirste...@co.anoka.mn.us> wrote in message
> news:F6409595ABA5F486...@in.WebX.maYIadrTaRb...

<snipped>

Alan McCormack

unread,
Mar 8, 2002, 4:24:54 PM3/8/02
to
"Kirsten" <kirste...@co.anoka.mn.us> wrote in message news:<F6409595ABA5F486...@in.WebX.maYIadrTaRb>...

Here's a snippet of code that I wrote for an appication that does what
you want (I think). You might be able to use a similar technique:

varVertices = objPolyline.Coordinates

intFilterType(0) = 0
varFilter(0) = "TEXT"
varFilterType = intFilterType
varFilterData = varFilter
lngSelectMode = acSelectionSetCrossingPolygon

Set ssetBFText = ThisDrawing.SelectionSets.Add("BondFingerText")ssetBFText.SelectByPolygon
lngSelectMode, varVertices, _
varFilterType, varFilterData

Rob Starz

unread,
Mar 10, 2002, 11:58:49 PM3/10/02
to
I have not tried this but I am curious as to the result if the selected
Polyline has an arc. I could be wrong but from what see it would miss items
if the fall outside the straight line of the start and end point. Am I
wrong in saying this.

What I have been doing is converting the Polyline into a Region then testing
all objects that fall within the BoundBox to see if they intersect. This
guaranties they are inside even arcs.

--
|
-+-------------------------------------------------
| Rob Starz
| Stardsign cad solutions
| AEC Designer / Consultant / Developer
| Arch Desktop tools www.stardsign.com/adtcadpacx.htm
| ******coming soon e-Training for ******
| programming Arch Desktop
| learn what you can do...with little input.

Minkwitz Design

unread,
Mar 11, 2002, 10:56:05 AM3/11/02
to
Hi Rob,
That's a good point, something I didn't even take into consideration.And
the bounding box idea isn't a bad work arouund, except it could have the
opposite effect. You could wind up selecting entities outside of the
polyline if they fall within the bounding box. I suppose the only way to
handle it accurately would be to select the set assuming that none of
the polyline segments are arcs, then go back and test each segment. If
it's an arc, you would have to calculate the area it encompasses and
then test for entities that fall within that area but are not part of
the set, then add them to the set. That could become pretty involved.
Out of curiousity, under what circumstances would you want to select
enities that are contained in an existing polyline?
-Josh

p.s.- sorry Tom, I didn't catch your response to the original post
before posting my own redundant version.

Rob Starz

unread,
Mar 11, 2002, 11:15:51 AM3/11/02
to
Maybe I didn't state myself properly.
Select the Pline
Get BoundBox
Create Region from Polyline
create a selection set of object using BoundBox of Polyline
check to see if each object intersects with Region.

This will easily grab all objects even if there is an arc with a large
bulge.

Rob Starz

unread,
Mar 11, 2002, 11:17:43 AM3/11/02
to
Also

<<Out of curiosity, under what circumstances would you want to select


enities that are contained in an existing polyline?

I use this for scheduling of items that are in a room area. Facility
Management software would use this also.

Rob Starz

unread,
Mar 11, 2002, 3:03:31 PM3/11/02
to
Yes if you just did the BoundBox it would grab all ....But I if you check
and see if each object Interfers with the created Region and remove the ones
that don't you will get all objects that fall within the Polyline.

Works great on my end.

TomD

unread,
Mar 11, 2002, 2:57:39 PM3/11/02
to

Minkwitz Design <josh...@ameritech.net> wrote in message
news:3C8CD395...@ameritech.net...

> Out of curiousity, under what circumstances would you want to select
> enities that are contained in an existing polyline?
> -Josh

For civil/surveying, that type of thing can be handy quite often. One
example would be to select objects within boundary polyline to create
surface models from.

> p.s.- sorry Tom, I didn't catch your response to the original post
> before posting my own redundant version.

No problem. I'm not the best at conveying the thoughts in my scrambled
head, so most of my posts can't hurt a second perspective, even if it's
saying basically the same thing. ;)

Interesting topic (at least to me.)


TomD

unread,
Mar 11, 2002, 2:55:31 PM3/11/02
to
I think Josh was eluding to the fact that using boundbox would give you the
outermost rectangle, thereby potentially picking objects that are not
actually within the polyline.

I haven't used the BoundBox property at all, so if I'm mistaken about it
returning a rectangular area, by all means correct me.

Rob Starz <r...@stardsignNOSPAM.com> wrote in message
news:DFC4DA2D3FF2D003...@in.WebX.maYIadrTaRb...

TomD

unread,
Mar 11, 2002, 2:52:25 PM3/11/02
to
Thanx for the tip, Laurie. Maybe it's time to revisit that utility, this
time in VBA. ;)

Laurie Comerford <lau...@cadapps.com.au> wrote in message
news:EE342C30653D6669...@in.WebX.maYIadrTaRb...

Minkwitz Design

unread,
Mar 11, 2002, 5:11:56 PM3/11/02
to

> Interesting topic (at least to me.)


I find it interesting as well ,,, makes me think :)
-Josh

Minkwitz Design

unread,
Mar 11, 2002, 5:08:12 PM3/11/02
to
Hi Rob,
Sorry if I'm grasping this a little slowly :) I see where you're coming
from, but I don't understand how your checking for the interference
between the entity in the set and the region. Are you using the
intersectwith method? Basically creating a "crossing window" version. Or
do you have a method (that I'm not seeing) of determining if the entire
entity falls "within the polyline" or region.
-Josh

Rob Starz

unread,
Mar 11, 2002, 6:28:41 PM3/11/02
to
I am checking the IntersectsWith and the Insertion point of the object. I
guess you can take if further and check each subentity if the objects is a
block or custom object. I am happy with the insertion point for the
IntersectsWith.

TomD

unread,
Mar 12, 2002, 8:27:08 AM3/12/02
to
Great idea, Rob! Thanks for the clarification. I'm saving this one. ;)

Rob Starz <r...@stardsignNOSPAM.com> wrote in message

news:88128F407EF9BB58...@in.WebX.maYIadrTaRb...

kanna...@gmail.com

unread,
Oct 26, 2015, 2:01:10 AM10/26/15
to
tHANK U kIRSTEN. WORKS PERFECT. YOU SAVED ME
Reply all
Reply to author
Forward
0 new messages