Hi,
Be sure to have the external rectangles visible in the screen and just select the external rectangles as the message of the program indicates to:
Code:(defun c:Test (/ int sel ent rct pts vol nos are obj big lst dis lng pnt) ;; Tharwat - Date: 09.Nov.2017 ;; (princ "\nSelect external Rectangles only with four corners :") (if (setq int -1 sel (ssget '((0 . "LWPOLYLINE") (90 . 4)))) (while (setq ent (ssname sel (setq int (1+ int)))) (and (setq rct (ssget "_WP" (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (p) (eq (car p) 10)) (entget ent) ) ) ) '((0 . "LWPOLYLINE") (90 . 4)) ) ) (progn (setq vol 0.0) (repeat (setq nos (sslength rct)) (if (> (setq are (vlax-curve-getarea (setq obj (ssname rct (setq nos (1- nos)))) ) ) vol ) (setq vol are big obj ) ) ) big ) (= (length (setq lst (mapcar 'cdr (vl-remove-if-not '(lambda (p) (eq (car p) 10)) (entget big) ) ) ) ) 4 ) (mapcar '(lambda (vrx) (setq pnt (car lst) dis (distance vrx pnt) ) (mapcar '(lambda (cor) (if (< (setq lng (distance vrx cor)) dis) (setq pnt cor dis lng ) ) ) lst ) (entmake (list '(0 . "LINE") (cons 10 vrx) (cons 11 pnt))) ) pts ) ) ) ) (princ) ) (vl-load-com)
Bookmarks