Rooster Posted August 13, 2009 Posted August 13, 2009 Hi folks. I use the following LISP to add a specified prefix to a bit of text & then delete the corresponding note. Could someone help me edit this to make it more versatile? Rather than adding the same prefix every time I would like to select the note, copy the contents to use as the prefix, add it to the selected text, and then delete the note leaving just the text with its now-added prefix.... Hope that all makes sense ;ADDS PREFIX OF 'DK:' TO SELECTED TEXT & THEN DELETES ORIGINAL DK NOTE (defun c:dk (/ tSet dl) (vl-load-com) (if (setq tSet (ssget '((0 . "TEXT,MTEXT")))) (foreach tx (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex tSet)) ) ;_ end vl-remove-if ) ;_ end mapcar (vla-put-TextString tx (strcat "DK:" (vla-get-TextString Tx)) ) ;_ end vla-put-TextString ) ; end foreach ) ; end if (setq dl (ssget)) (command "erase" dl "") (princ) ) ; end of c:dk Quote
Lee Mac Posted August 13, 2009 Posted August 13, 2009 Like this? (defun c:ptxt (/ ent pr ss) (if (and (setq ent (car (entsel "\nSelect Prefix Text: "))) (wcmatch (cdr (assoc 0 (entget ent))) "*TEXT") (setq pr (cdr (assoc 1 (entget ent))))) (if (setq ss (ssget '((0 . "*TEXT")))) (progn (mapcar (function (lambda (x) (vla-put-TextString x (strcat pr (vla-get-TextString x))))) (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))) (entdel ent)))) (princ)) Quote
Rooster Posted August 13, 2009 Author Posted August 13, 2009 Lee, as ever you are the man! Thanks a lot Quote
Lee Mac Posted August 13, 2009 Posted August 13, 2009 Not a problem, I don't mind writing the quick text edit LISPs 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.