Jump to content

Block Description to Multileader


AlexP

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)
 )

Link to comment
Share on other sites

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)
 )

Link to comment
Share on other sites

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.

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...