Jump to content

How to get block name By Autolisp?


fathihvac

Recommended Posts

  • 2 weeks later...
  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • fathihvac

    9

  • pBe

    6

  • dbroada

    2

  • troggarf

    2

Top Posters In This Topic

Posted Images

  • 1 year later...

Here is what i came up with about a year ago.  Change the TXTHT to what you need

;;;-----------------------------------------------------
;;; LABLE BLOCKS BY NAME MIDPOINT OF BOUNDINB BOX
(defun C:NBLK (/ SS i nn obj LL UR MPT TXTHT)
  (vl-load-com)
  (setq SS (ssget '((0 . "INSERT"))))
  (setq i 0)
  (command "_.Undo" "Be")
  (repeat (sslength ss)
    (setq nn (cdr (assoc 2 (entget (ssname ss i)))))
    (setq obj (vlax-ename->vla-object (ssname ss i)))
    (vla-getboundingbox obj 'minpt 'maxpt)
    (setq
      LL (vlax-safearray->list minpt)
      UR (vlax-safearray->list maxpt)
    )
    (setq MPT (polar LL (angle LL UR) (/ (distance LL UR) 2)))
    (setq TXTHT 0.250)            ;;set text height
    (command ".TEXT" "J" "MC" MPT TXTHT "0" NN)
    (setq i (1+ i))
  )
  (command "_.Undo" "E")
)

 

 

Edited by mhupp
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...