# Thread: Autolisp Function to Determine Point Location

1. ## Autolisp Function to Determine Point Location

Summary: An Autolisp function to determine if a point is inside a closed polyline or selection set of objects.

Description: I wish there was an autolisp function to determine if a point is "inside" a closed polyline or selection set of objects.

How Used: Having such a function would fill a gap in the current function list, and would eliminate ~200 lines of code (at least in my case) for lisp programs that require that test, making it more efficient.

Feature Affinity: Lisp

Submitted By: Tim Creary on January 16, 2008

2. ## Re: Autolisp Function to Determine Point Location

I have a lisp to do this.
It's actually simple.
Steps (in lisp or vba)
1) Draw a line from the coordinates of the target point.
2) project the line horizontally further than the X value of the polyline vertices.
3) Do an inters (for lisp) or ent.IntersectWith (for vba)
4) Count the numbers of intersection points.
5) If count is Odd, point is inside poly, otherwise outside if even.

This should only make you 10 to 15 lines of code.

Efren

3. ## Re: Autolisp Function to Determine Point Location

Summary: An Autolisp function to determine if a point is inside a closed polyline or selection set of objects.

Description: I wish there was an autolisp function to determine if a point is "inside" a closed polyline or selection set of objects.

This can be done by using the polylines co-ordinates as a crossing polygon or window polygon to generate the selection set.

I've done exactly this for a routine which populates block attributes with the room number of the room they are located in. Each room has a polyline around it and the routine detects which blocks are inside the polyline.

i.e.

(setq ss1 (ssget "WP" (list pt1 pt2 pt3))) - where pt1 pt2 etc are the verticies taken from the polyline.

Works a treat!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•