Jump to content

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


lamensterms

Recommended Posts

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

like this...

 

Copied Text Example 2.jpg

 

thanks again.

Link to comment
Share on other sites

(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)
)

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...