Anushka Posted March 16, 2020 Share Posted March 16, 2020 How I adapt the program to get the name of the nearest block. with text it works. (defun :closestname (pt ss) (cdar (vl-sort (mapcar '(lambda (e) (cons (distance (cdr (assoc 10 (entget e))) pt) (cdr (assoc 1 (entget e))))) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) ) '(lambda (p1 p2) (< (car p1) (car p2))) ) ) ) Quote Link to comment Share on other sites More sharing options...
dlanorh Posted March 16, 2020 Share Posted March 16, 2020 Quote 23 minutes ago, Anushka said: How I adapt the program to get the name of the nearest block. with text it works. (defun :closestname (pt ss) (cdar (vl-sort (mapcar '(lambda (e) (cons (distance (cdr (assoc 10 (entget e))) pt) (cdr (assoc 1 (entget e))))) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) ) '(lambda (p1 p2) (< (car p1) (car p2))) ) ) ) If you are only selecting blocks change (cdr (assoc 1 (entget e))) to (cdr (assoc 2 (entget e))) 1 Quote Link to comment Share on other sites More sharing options...
Anushka Posted March 17, 2020 Author Share Posted March 17, 2020 (edited) @dlanorh It's YES!!! lol lol -1 worked Edited March 17, 2020 by Anushka Quote Link to comment Share on other sites More sharing options...
dlanorh Posted March 17, 2020 Share Posted March 17, 2020 1 hour ago, Anushka said: @dlanorh It's YES!!! lol lol -1 worked Glad I could help. (assoc 2) is the actual name of the block, (assoc -1) is the entity name. Quote Link to comment Share on other sites More sharing options...
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.