Jump to content
AlexP

Block Description to Multileader

Recommended Posts

AlexP

Hi Designers,

 

I would like to have a lisp that reads the Description of a Block and shows it on a Multileader so then you don't have to type in the Text once a Block is registered.

 

I know this topic was covered in an much older post before - almost 10 years ago - but I put hours experimenting with the Lisp in different ways and still couldn't get it to work 100%.

 

http://www.cadtutor.net/forum/showthread.php?39301-Block-into-multileader-text

 

Does anyone have the solution to this?

Share this post


Link to post
Share on other sites
Emmanuel Delay

Here is what I wrote:

- the client selects a block (I assume it has a description, I assume the client clicks on a block ... no anti dummy protection)

- the client must now draw the MLeader: two points: arrow head + leader landing

- The routine will fill in the caption, being the description of the block.

 

Command: SAD (pun maybe intended, although it's just an abbreviation)

 

(defun getBlockProperties ( #Entsel / )
     (setq #Entsel   (vlax-ename->vla-object (car #Entsel))
           ;; insertion point
           #InsPoint (vlax-safearray->list
                       (vlax-variant-value
                         (vla-get-InsertionPoint #Entsel)
                       ) ;_ vlax-variant-value
                     ) ;_ vlax-safearray->list
           ;; block name
           #Name     (vla-get-name #Entsel)
           ;; block description
           #Desc     (vla-get-comments
                       (vla-item
                         (vla-get-blocks
                           (vla-get-activedocument (vlax-get-acad-object))
                         ) ;_ vla-get-blocks
                         #Name
                       ) ;_ vla-item
                     ) ;_ vla-get-comments
     ) ;_ setq
 (list #Name #InsPoint #Desc)
)


;; create Mleader with caption.
(defun wmt (caption / )
 ;;(vl-cmdf "_.MLEADER" PAUSE PAUSE "" "_.TEXTEDIT" "_L")
 (vl-cmdf "_.MLEADER" PAUSE PAUSE  caption)
)

;; Select And get Description
(defun c:sad ( / desc)  
 (setq desc (nth 2 (getBlockProperties (entsel "\nSelect a block: "))))
 (princ "\nNow draw the MLeader:\n")
 (wmt desc)
 (princ)
)

 

Happy with this?

Share this post


Link to post
Share on other sites
AlexP

Almost !

 

It identifies the Description, but won't fill in the caption. :(

Share this post


Link to post
Share on other sites
Tharwat

The simplest I guess.

 

(defun c:d2ml ( / s d)
 (and (princ "\nPick a block :")
      (setq s (ssget "_+.:S:E" '((0 . "INSERT"))))
      (or (setq d (cdr (assoc 4 (entget (tblobjname "BLOCK" (cdr (assoc 2 (entget (ssname s 0)))))))))
          (alert "Block does not have a description <!>")
          )
      (vl-cmdf "_.Mleader" "\\" "\\" d)
      )
 (princ)
 )

Share this post


Link to post
Share on other sites
AlexP

Same result.

 

I don't know why it won't put in the Description..

Share this post


Link to post
Share on other sites
Tharwat
Same result.

 

I don't know why it won't put in the Description..

 

Can you post a drawing including the block?

Share this post


Link to post
Share on other sites
AlexP

See attached.

Test.dwg

Share this post


Link to post
Share on other sites
Tharwat

Just this a go and let me know.

(defun c:d2ml ( / s d l n e)
 (and (princ "\nPick a block :")
      (setq s (ssget "_+.:S:E" '((0 . "INSERT"))))
      (or (setq d (cdr (assoc 4 (entget (tblobjname "BLOCK" (cdr (assoc 2 (entget (ssname s 0)))))))))
          (alert "Block does not have a description <!>")
          )
      (setq l (entlast))
      (vl-cmdf "_.Mleader" "\\" "\\" "")
      (and (not (= l (setq n (entlast))))
           (entmod (subst (cons 304 d) (assoc 304 (setq e (entget n))) e))
           )
      )
 (princ)
 )

Share this post


Link to post
Share on other sites
AlexP

You are a Legend Tharwat !!

 

It's works perfectly, many thanks for that ! :D

 

And you Emanuel for giving it a go, I appreciate it.

Share this post


Link to post
Share on other sites
Tharwat
You are a Legend Tharwat !!

 

It's works perfectly, many thanks for that ! :D

Thanks for the nice words AlexP.

 

You are welcome anytime. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×