TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Dommy2Hotty on September 16, 2009, 12:14:39 PM
-
Been working on this for a minute today, can't figure out how to use assoc code 1 from mtext for assoc code 304 for mleaders. Anyone know?
(defun C:MTxt2Mleader ()
(setq ent (entget (car (entsel "\nSelect SOURCE text: "))))
(setq info (assoc 1 ent))
(setvar "cmdecho" 0)
(while
(setq ent2 (entget (car (entsel "\nSelect MLEADER object: "))))
(SETQ mlinfo (assoc 304 ent2))
(setq ent2 (subst (assoc 304 INFO) (assoc 304 ent2) ent2))
(entmod ent2)
(setvar "cmdecho" 1)
);end while
);end of defun
Returns:
; error: bad association list: (1 . "SAMPLE TEXT")
-
Mleaders are much easier to manipulate via ActiveX...here's a small example:
(defun c:test(/ mleader txt)
(if (and (setq txt (car (entsel "\nSelect text: ")))
(setq mleader (car (entsel "\nSelect mleader: ")))
(setq mleader (vlax-ename->vla-object mleader))
(setq txt (vlax-ename->vla-object txt))
)
(progn (vla-put-textstring mleader (vla-get-textstring txt))
(vla-update mleader)
)
)
)
-
Hi,
replace:
(subst (assoc 304 INFO) (assoc 304 ent2) ent2)
by
(subst (cons 304 INFO) (assoc 304 ent2) ent2)
-
Mleaders are much easier to manipulate via ActiveX...here's a small example:
(defun c:test(/ mleader txt)
(if (and (setq txt (car (entsel "\nSelect text: ")))
(setq mleader (car (entsel "\nSelect mleader: ")))
(setq mleader (vlax-ename->vla-object mleader))
(setq txt (vlax-ename->vla-object txt))
)
(progn (vla-put-textstring mleader (vla-get-textstring txt))
(vla-update mleader)
)
)
)
Worked like a charm! Thank you!
-
Hi,
replace:
(subst (assoc 304 INFO) (assoc 304 ent2) ent2)
by
(subst (cons 304 INFO) (assoc 304 ent2) ent2)
Still got an error, think I tried that one earlier, but brains fried now...need to do this more often...
-
Just for completeness Dommy:
(defun C:MTxt2Mleader (/ ent text ent2)
(if (setq ent (car (entsel "\nSelect SOURCE text: ")))
(progn
(setq text (cdr (assoc 1 (entget ent))))
(while (setq ent2 (car (entsel "\nSelect MLEADER object: ")))
(entmod
(subst
(cons 304 text)
(assoc 304 (entget ent2)) (entget ent2))))))
(princ))
PS: You don't need to set CMDECHO to 0, as you are not calling (command... anywhere :wink:
-
Mleaders are much easier to manipulate via ActiveX...here's a small example:
(defun c:test(/ mleader txt)
(if (and (setq txt (car (entsel "\nSelect text: ")))
(setq mleader (car (entsel "\nSelect mleader: ")))
(setq mleader (vlax-ename->vla-object mleader))
(setq txt (vlax-ename->vla-object txt))
)
(progn (vla-put-textstring mleader (vla-get-textstring txt))
(vla-update mleader)
)
)
)
Worked like a charm! Thank you!
:-)