Jump to content

Name of existing blocks


Nkey

Recommended Posts

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 ?

Link to comment
Share on other sites

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 by mhupp
  • Like 1
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...