Jump to content
lamensterms

Routine to add modified text below existing text (copy/replace?)...

Recommended Posts

lamensterms

Hi guys,

 

Im not sure the best way to explain what I am looking for – but I would like to have a LISP routine that would copy and replace text.

 

I am a steel detailer and we recently switched from one AutoCAD add-on package to another. The original software package had the ability to copy text below itself, then replace the copied text with new text (same size, style… and copied it a standard distance below the existing text). This feature is very handy when labeling dimensions.

 

Please see attached image for examples…

 

The distance that the new text is copied below the existing text would be proportional to the text height (style).

 

Thanks so much for any help.

 

Ps... i thought it would also be worth noting that it would be pre-defined text getting added below the existing text. So there could be a range of commands... ie. command 'TYP' would add the text "TYP", 'EQ' would add "= =", etc...

 

Copied Text Example.jpg

Edited by lamensterms

Share this post


Link to post
Share on other sites
Lee Mac

How about using DDEdit on the Dimension and then \XTYP or \XREF

Share this post


Link to post
Share on other sites
lamensterms

Hi Lee, thanks for the reply..

 

can you please elaborate on that response? what is the function of \X? and how can i use it?

Share this post


Link to post
Share on other sites
Lee Mac

When you DDEdit a Dimension you are modifying the Text Override Content of the Dimension.

 

The represents the dimension measurement in this override string, and \X will place any text following it underneath the dimension line.

Share this post


Link to post
Share on other sites
lamensterms

Oh wow, that’s great. Thanks so much Lee, for your help and your quick response.

 

I understand that the ‘\X’ input needs to be written into a routine – rather than simply adding it in autoCAD? (otherwise the ‘’ appears as part of the dimension text?)

 

I have actually just found a routine that will accomplish exactly what I need – using the same method you describe.

 

(Defun c:fieldverify ()
(setq newdim (entsel "\n Select Dimension to Add FIELD VERIFY to:"))
(setq newdimvalue "<>\\X FIELD VERIFY")
(command "dimedit" "n" newdimvalue newdim "")
(princ)
)

 

http://www.archidigm.com/lounge/autocad%20tips/adding_text_to_dimensions.htm

 

Thanks again for you help.

 

Cheers.

Share this post


Link to post
Share on other sites
Lee Mac

The text override could be typed manually or used in a program.

 

A few examples:

 

(defun c:test1 ( / e )
 (if 
   (and
     (setq e (car (entsel "\nSelect Dimension: ")))
     (wcmatch (cdr (assoc 0 (setq e (entget e)))) "*DIMENSION")
   )
   (entmod (subst (cons 1 "<>\\XTYP") (assoc 1 e) e))
 )
 (princ)
)

(defun c:test2 ( / ss i e )
 (if (setq ss (ssget "_:L" '((0 . "*DIMENSION"))))
   (repeat (setq i (sslength ss))
     (setq e (entget (ssname ss (setq i (1- i)))))
     (entmod (subst (cons 1 "<>\\XTYP") (assoc 1 e) e))
   )
 )
 (princ)
)

There may be typo's as I've just typed that code from my mobile.

Edited by Lee Mac

Share this post


Link to post
Share on other sites
lamensterms

Thats great, thanks again for all this help Lee.

 

will any of these routines work on dtext or mtext? i would mainly use these routines to run on dimensions, but would also like to use them on normal text.

 

thanks again for taking the time mate.

Share this post


Link to post
Share on other sites
lamensterms

Also... is it possible to have multiple lines of notes added below a dimension?

 

like this...

 

Copied Text Example 2.jpg

 

thanks again.

Share this post


Link to post
Share on other sites
VVA
(defun c:test2 ( / ss i e )
 (if (setq ss (ssget "_:L" '((0 . "*DIMENSION"))))
   (repeat (setq i (sslength ss))
     (setq e (entget (ssname ss (setq i (1- i)))))
     (entmod (subst (cons 1 "<>\\XREF[color="#ff0000"]\\P[/color]TYP") (assoc 1 e) e))
   )
 )
 (princ)
)

Share this post


Link to post
Share on other sites
Lee Mac
will any of these routines work on dtext or mtext? i would mainly use these routines to run on dimensions, but would also like to use them on normal text.

 

You could use the "\\P" string to insert a new line to the end of an MText string, however, for DText you would need to create a new DText object at a distance below the original calculated from the text height of the selected DText and a Line spacing factor (such as 1.5).

Share this post


Link to post
Share on other sites
lamensterms

alanjt... thank you for your reply - that routine looks like it could be very helpful.

 

Can you please post the routines on this forum though? I have registered to join the swamp but i havent yet received to approval to use their forums.

 

Thanks for your help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×