AlexP Posted July 9, 2018 Posted July 9, 2018 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? Quote
Emmanuel Delay Posted July 10, 2018 Posted July 10, 2018 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? Quote
AlexP Posted July 10, 2018 Author Posted July 10, 2018 Almost ! It identifies the Description, but won't fill in the caption. Quote
Tharwat Posted July 10, 2018 Posted July 10, 2018 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) ) Quote
AlexP Posted July 10, 2018 Author Posted July 10, 2018 Same result. I don't know why it won't put in the Description.. Quote
Tharwat Posted July 10, 2018 Posted July 10, 2018 Same result. I don't know why it won't put in the Description.. Can you post a drawing including the block? Quote
Tharwat Posted July 10, 2018 Posted July 10, 2018 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) ) Quote
AlexP Posted July 10, 2018 Author Posted July 10, 2018 You are a Legend Tharwat !! It's works perfectly, many thanks for that ! And you Emanuel for giving it a go, I appreciate it. Quote
Tharwat Posted July 10, 2018 Posted July 10, 2018 You are a Legend Tharwat !! It's works perfectly, many thanks for that ! Thanks for the nice words AlexP. You are welcome anytime. Quote
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.