Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text Lisp

Status
Not open for further replies.

AlexDring

Mechanical
Dec 31, 2002
117
Does anyone have a lisp that can edit Mtext or regular text to put common things behind or in front of the text?

Example:

I have a leader with text "a"(mtext or regular text) and I want it to read "a typ" or "a SEE DETAIL" or "2X a SEE Detail"

So I am looking for something that I can pick the text and then pick a prefix to apply to that text? Just curios.
 
Replies continue below

Recommended for you


Yes you can do that with a lisp
program, but may not be worth it
(time spent in writing routine)
for single use only. It's good to
do it via lisp when you are adding
additonal text to multiple instances
in mutltiple drawings.

 
Well to get detailed I would like a button to click, a dialog box appears, asking letter to be assigned and any or none prefixes. Like a bom utility without the cumbersome setting up or tracking.

I have noticed some utilities for boms which would be nice, but for me and my use, a perfect thing would be to have buttons for assigning piece marks, a dialog pops up, type in the name and values to be put in the bom, for lengths to click a dimension and the length is put in the bom.

But for now I spend alot of time cleaning up drawings with putting typ, ns+fs, see deails text on existing text. So that is what I was really looking for.
 
Not sure it this is what you want. Save it somewhere as "CT.lsp". In Autocad at the command line type (load"ct") and press enter. Still at the command line, type CT and press enter. Have some text in the drawing. At the CT prompt, select the text you want to change, then type the text you want to replace then type the new text. For instance, replace "a" with "a typ".

;
"CT" Change text
;
(DEFUN chgterr (s)
(if (/= s "Function cancelled") ; If an error (such as CTRL-C) occurs
(princ (strcat "\nError: " s)) ; while this command is active...
)
(setq p nil) ; Free selection set
(setq *error* olderr) ; Restore old *error* handler
(princ)
)

;
(DEFUN C:CT (/ p l n e os as ns st s nsl osl sl si chf chm olderr) ; Correct spelling errors
(setq olderr *error* ; Initialize variables
*error* chgterr
chm 0)
(setq p (ssget)) ; Select objects
(if p (progn ; If any objects selected
(while (= 0 (setq osl (strlen (setq os (getstring t "\nOld string: ")))))
(princ "Null input invalid")
)
(setq nsl (strlen (setq ns (getstring t "\nNew string: "))))
(setq l 0 n (sslength p))
(while (< l n) ; For each selected object...
(if (= "TEXT" ; Look for TEXT entity type (group 0)
(cdr (assoc 0 (setq e (entget (ssname p l))))))
(progn
(setq chf nil si 1)
(setq s (cdr (setq as (assoc 1 e))))
(while (= osl (setq sl (strlen
(setq st (substr s si osl)))))
(if (= st os)
(progn
(setq s (strcat (substr s 1 (1- si)) ns
(substr s (+ si osl))))
(setq chf t) ; Found old string
(setq si (+ si nsl))
)
(setq si (1+ si))
)
)
(if chf (progn ; Substitute new string for old
(setq e (subst (cons 1 s) as e))
(entmod e) ; Modify the TEXT entity
(setq chm (1+ chm))
))
)
)
(setq l (1+ l))
)
))
(princ "Changed ") ; Print total lines changed
(princ chm)
(princ " text lines.")
(terpri)
(setq *error* olderr) ; Restore old *error* handler
(princ)
)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor