Anushka Posted October 14, 2019 Posted October 14, 2019 Hello everyone, Is there a way to count only objects at a specific distance? Example I have several blocks in my drawing and I want to count only those that are at the maximum distance X, from a RED, CIAN polyline ... and delete all others, How to do this? In the attached dwg example, I want to delete only those with the green circle. Thanks in advance for the help you are giving me !! Drawing1.dwg Quote
Tharwat Posted October 14, 2019 Posted October 14, 2019 Hi, Something like this? (defun c:Test (/ int cnt sel ent get bks lws lst len) ;; Tharwat - Date: 14.Oct.2019 ;; (and (or *gapdis* (setq *gapdis* 1.0)) (or (initget 6) (setq *gapdis* (cond ((getdist (strcat "\nSpecify maximum gap distance between blocks and polylines <" (vl-princ-to-string *gapdis*) "> :" ) ) ) (*gapdis*) ) ) ) (princ "\nSelect Blocks & Polylines : ") (setq int -1 cnt 0 sel (ssget "_:L" '((0 . "LWPOLYLINE,INSERT"))) ) (while (setq int (1+ int) ent (ssname sel int) ) (or (and (= (cdr (assoc 0 (setq get (entget ent)))) "INSERT") (setq bks (cons get bks)) ) (setq lws (cons ent lws)) ) ) (mapcar '(lambda (w) (mapcar '(lambda (b / p) (and (setq lst b) (or (< (setq len (distance (vlax-curve-getclosestpointto w (setq p (cdr (assoc 10 b)))) p) ) *gapdis* ) (equal len *gapdis* 1e-4) ) (setq cnt (1+ cnt)) (setq bks (vl-remove lst bks)) ) ) bks ) ) lws ) (and bks (foreach bk bks (entdel (cdr (assoc -1 bk))))) ) (princ (strcat "\nNumber of blocks retained [ " (if (< 0 cnt) (itoa cnt) "None") " ].")) (princ) ) (vl-load-com) 1 Quote
Anushka Posted October 15, 2019 Author Posted October 15, 2019 @Tharwat Works great, THANK YOU VERY MUCH !! Quote
Tharwat Posted October 15, 2019 Posted October 15, 2019 1 hour ago, Anushka said: @Tharwat Works great, THANK YOU VERY MUCH !! You're welcome anytime. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.