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!

Replace Text

Status
Not open for further replies.

rwbaker

Computer
Mar 27, 2004
37
acad2004 - vba

I want to be able to replace text strings in a drawing
I have written a program which calcs perameters for a drawing
the drawing is not to scale so all i am trying to do is replace items with the calced value

Private Sub cmdCreatePart_Click()
xxx = Replace("DimA", DimA, XX)
End Sub

thanks in advance
 
Replies continue below

Recommended for you

Are these text items in associative dimensions, or text or MText?
 
thanks for reply
they are both mtext and text

 
Here is a simple LISP routine, if that helps.

(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)
)
 
Maybe I don't understand what you are doing, but can't you use the "find and replace" that is part of Autocad already?
 
I changed the way I was going to do this

What I did was create a master of the filter assembly
then i used attributes for the fields that i want to fill in

this seems to be working fine

just need to get the rounding of the numbers done

right now they are spending about an hour to create this drawing

thru the program it takes about 2 minutes and you get the
flat pattern also....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor