Nkey Posted July 13, 2022 Share Posted July 13, 2022 Hello everyone. What is the fastest way to create a text or leader that shows the name of an already existing block? I know I can create a field, select object, name, but i have a lot of different blocks that need naming. I tried to create a macro to automate the process but it didn't work. Is there a lisp that can do this ? Quote Link to comment Share on other sites More sharing options...
mhupp Posted July 13, 2022 Share Posted July 13, 2022 (edited) This is what i use to create a text over blocks ;;----------------------------------------------------------------------------;; ;; LABLE BLOCKS BY NAME MIDPOINT OF BOUNDINB BOX (defun C:BLKNAME (/ SS e Name LL UR MPT) (if (setq SS (ssget '((0 . "INSERT")))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (setq Name (cdr (assoc 2 (entget e)))) (vla-getboundingbox (vlax-ename->vla-object e) 'minpt 'maxpt) (setq LL (vlax-safearray->list minpt) UR (vlax-safearray->list maxpt) MPT (mapcar '/ (mapcar '+ LL UR) '(2 2 2)) ) (entmake (list '(0 . "TEXT") '(8 . "0") (cons 10 MPT) (cons 11 MPT) ;needed for text that isn't left justify (cons 40 (getvar 'Dimtxt)) ;use current dim text size or hard code a height (cons 1 name) '(72 . 4) ;Text justification Middle Center ) ) ) (prompt "\nNo Blocks Selected") ) (princ) ) Edited July 13, 2022 by mhupp 1 Quote Link to comment Share on other sites More sharing options...
Nkey Posted July 14, 2022 Author Share Posted July 14, 2022 Thank you mhupp this works great !!! 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.