AutoLISP: Dim Text OverRide

Although you do not really need a LISP routine to accomplish this task (as seen in THIS post). This particular routine is great because it also has an extra option to clear existing text overrides.

I use this routine to easily add text to show underneath dimensions and also to remove text overrides from dimensions.

Here’s how:

  • DTOR <enter> to start
  • Select Dimensions to have the text overrides applied to (can be multiple)
  • Enter the text that you’d like to show: in this example, I used <>\XTYP. to show “TYP.” underneath the dimension.
  • <> lets you keep the actual measured dimension
  • \X starts a new line of text underneath the actual dimension
  • TYP. that is right next to the “\X” is the text to be displayed in the new line

The below animation shows how to add text:

The below animation shows how to remove text overrides:

I do not remember where this routine came from or who wrote it. I think that Alan Thompson wrote it but I am not certain.

(defun c:DTOR () (c:DimTextOverride))

(defun c:DimTextOverride ( / ss textString)

(princ "\rDIMENSION TEXT OVERRIDE ")

(vl-load-com)

(if (and (setq ss (ssget '((0 . "DIMENSION"))))

(setq textString

(getstring

T

"\nEnter override text, <Enter> to remove override: ")))

(progn

(vla-startundomark

(cond (*activeDoc*)

((setq *activeDoc*

(vla-get-activedocument

(vlax-get-acad-object))))))

(vlax-for oDim

(setq ss (vla-get-activeselectionset *activeDoc*))

(vla-put-textoverride oDim textString))

(vla-delete ss)

(vla-endundomark *activeDoc*))

(prompt "\n** Nothing selected ** "))

(princ))
Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, Dimensions, Modifying, Text, TIPS. Bookmark the permalink.

7 Responses to AutoLISP: Dim Text OverRide

  1. Andres says:

    Thank you!
    It works

  2. Matt says:

    How would you use this if the override text is always the same (ex: TYP) and simply wanted to insert it directly without receiving a prompt?

    • AutoCAD Tips says:

      Try the code below:

      ;;; Use CDA in the command line after loadingC
      ;;; Change Dimension Values to “TYP”
      ;;; (c) 2001 Andy Leisk
      ;;; Modified by Greg Battin to insert TYP in to dimension
      (defun C:CDA (/ ss)
      (princ “Select Dimensions to say TYP…\n”)
      (setq ss (ssget))
      (command “.DIM1” “NEW” “TYP” ss “”)
      (princ)
      )
      (princ)

      • Matt says:

        Perfect! Thanks.

        I like that it has the drag select option, instead of the single select, like this one:

        (defun c:T1 ( / edim)
        (vl-load-com)
        (setq edim (vlax-ename->vla-object (car (entsel “\Select dimension to replace value”))) )
        (vla-put-TextOverride edim ” (TOL.)”)
        (princ)
        )
        Original found here: http://forums.augi.com/showthread.php?129908-Text-Override-in-Dimension

      • Matt says:

        Slight mod to yours:
        (command “.DIM1” “NEW” ” TYP” ss “”)

        How would you change the format of the dim to decimal in the same command?

      • Matt says:

        Got it. Thanks for the help.

        (defun C:T1 (/ ss)
        (princ “Select Dimensions to say TOL …\n”)
        (setq ss (ssget))
        (command “.DIM1” “NEW” ” (TOL.)” ss “”)
        (command “DIMOVERRIDE” “DIMUNIT” “2” “” ss “”)
        (princ)
        )

      • AutoCAD Tips says:

        Cool – glad you got it to work for you
        ~Greg

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s