Kevin. Perez
Kevin. Perez

Reputation: 1

How to select closed 2d polylines that don't have an specific block inside Autocad

I need a lisp routine to check the polygons (closed polylines) and verify if there's a block (selected by user) inside. After that, highlight the empty polygons, something like this picture.

Autocad

The only thing that i found is to highlight objects outside.

Upvotes: -1

Views: 113

Answers (1)

CAD Developer
CAD Developer

Reputation: 1697

So if I understand correctly, the user is selecting blocks, and Your task is to create a script where selected are closed polylines which are not around selected blocks?

So first You need to find polylines, and You can do it in two ways in both You need to use function ssget with fence mode. (ssget "_F" (list p1 p2) '((0 . "LWPOLYLINE"))). A lot informations about that You may find in LeeMac aricle here: ssget by LeeMac.

The first way if You know more or less how big are polylines, You can imagine line crossing blocks insertion point and as big as max polyline size and calculate

(setq maxsize 100)
(setq p0 (vlax-safearray->list(vlax-variant-value ( vlax-get-property block'InsertionPoint ))) 
 p1 (list (- (car p0) maxsize) (cadr p0)(caddr p0))
 p2 (list (+ (car p0) maxsize) (cadr p0)(caddr p0))
)
(ssget "_F" (list p1 p2) '((0 . "LWPOLYLINE")))

The second way is iterating by polylines, and selecting blocks inside. also using ssget but this time You have to read all coordinates of polyline, and select blocks (ssget "_F" coordinates '((0 . "INSERT")))

Each way You will get entities, but then You need to mark it selected. In subject of Your post You ask how to select, so select and highlight is not the same. to really select entities You need to use sssetfirst function

Upvotes: 0

Related Questions