AutoCAD – Drawings

Align dimensions in AutoCAD: one pick for horizontal and vertical dimensions alike

How to align dimensions in AutoCAD with DIMSPACE, the DIM aliGn option, or the Institute's free LISP that moves horizontal and vertical dimensions to one pick.

  • TS. Đỗ Quốc Hoàng
  • 11 min read
On the same dimensions, DIMSPACE and DIM aliGn only line up the horizontal ones, while the DHD LISP moves the vertical one to the picked point too Photo: Diagram by the Institute of Information Technology in Civil Engineering

You finish dimensioning a floor plan and the dimension lines sit at random heights: one 300 from the wall, one 450, one 380. Dragging each by its grip takes an afternoon. This article shows how to align dimensions in AutoCAD with the two tools already built in, and with a free LISP from the Institute that does it in one command: select the lot, pick one point, done.

Download DHD-IIC-EN.lsp5 KB, one command, DHD. The full code is printed below so you can read it before running it. For the whole discipline of dimensioning, the Institute runs an AutoCAD course for construction.

Three ways to align dimensions

Before reaching for a LISP, it is worth knowing what AutoCAD already offers, because in many cases the built-in tools are enough.

MethodHow to start itNeeds a base dimensionHorizontal and vertical together
DIMSPACE with a value of 0Type DIMSPACEYesNo
The aliGn option of DIMType DIM, then GYesNo
The Institute's DHD LISPType DHDNo, you pick a pointYes, in one pass

To compare fairly, all three ran on the same set of dimensions: three horizontal ones measuring 1000, 1500 and 800, with dimension lines 300, 450 and 380 above the base, plus a vertical one measuring 1200 with its dimension line at X = 4300.

The DIMSPACE command: 0 aligns, a positive value spaces

Autodesk sums the command up as "Adjusts the spacing between linear dimensions or angular dimensions." It also spells out how to line them up: "You can also make the dimension lines of a series of linear or angular dimensions line up by using a spacing value of 0."

The 2027 prompts, quoted exactly.

StepThe promptWhat you do
1Select base dimension:Pick the reference dimension
2Select dimensions to space:Pick the others, Enter
3Enter value or [Auto] <Auto>:Type 0 to align

With the 1000 dimension as the base, picking the other three and typing 0 brings all three horizontal dimensions to the base's height of 300. The vertical one is accepted into the selection but not moved, and AutoCAD says nothing about it.

The reason is on the DIMSPACE page: "Spacing is applied only to parallel linear dimensions or to angular dimensions that share a common vertex." Only parallel linear dimensions are touched.

Space dimensions evenly with the same command

Type a positive value instead of 0 and the command spaces them out. Take three stacked dimensions measuring 1000, 2000 and 3000, with dimension lines at 300, 350 and 900. With the 1000 one as the base and a value of 250, the base stays at 300 and the other two land at 550 and 800, exactly 250 apart.

The DIMSPACE Auto trap

At step 3 AutoCAD offers <Auto> as the default, and many people simply press Enter.

Autodesk describes dimspace auto as "The resulting spacing distance is twice the height of the dimension text." But that height is the value stored in the dimension style, before DIMSCALE is applied. In a test drawing with DIMTXT at 0.18 and DIMSCALE at 40, Auto spaced the tiers only 0.36 units apart. The three dimensions ended up almost on top of one another.

So on a scaled drawing, do not accept Auto. Type the spacing you want in drawing units, just as in the 250 example above.

The DIM align option

The DIM command rolls several kinds of dimensioning into one, with an alignment option built in. Its first prompt lists everything: Select objects or specify first extension line origin or [Angular/Baseline/Continue/Ordinate/aliGn/Distribute/Layer/Undo]:

Type G for aliGn. AutoCAD asks Select base dimension:, then Select dimensions to align:. Choose as before: the 1000 dimension as the base, then the other three.

The three horizontal dimensions move to 300. This time the vertical one is rejected outright with the message Parallel, concentric, or same datum dimensions required. followed by 1 was filtered out.

When you have finished selecting, press Enter once more to leave. DIM does not end by itself; it returns to its first prompt, ready to dimension something else.

A LISP to align dimensions: the DHD command

Both built-in tools share two limits. They need a base dimension already sitting at the height you want. And they only handle dimensions parallel to that base, so horizontal and vertical ones take two separate passes.

The DHD LISP removes both. Instead of choosing a base, you pick a point. Each dimension line is pushed perpendicular to itself until it passes through that point, whatever its direction.

Load the file with APPLOAD, as described in our article on loading LISP files, then type DHD.

StepThe promptWhat you do
1Select the dimensions to align:Window the whole area, other objects included; only dimensions are taken
2Pick the point the dimension lines must pass through:Pick one point

On the same set, with an aligned dimension on a sloping edge and a radius dimension added, windowing everything and picking (4600, 700) gives this.

DimensionBeforeAfter
Three horizontal dimensions300 · 450 · 380700 · 700 · 700
Vertical dimensionX = 4300X = 4600
Aligned dimension on the slopeoff to one sideits dimension line passes through the picked point
Radius dimension—skipped

One thing to watch on a real plan. Every horizontal dimension you select goes to the same height, and every vertical one to the same X position. Window the chain above the building together with the chain below it, and the lower chain is pulled up into line with the upper one. So select the dimensions on one side at a time: one pass for the top, one for the bottom, then one for each flank.

AutoCAD reports Aligned 5 dimension(s). Skipped 1 that are not linear dimensions. Radius, diameter, angular and ordinate dimensions have no dimension line to align, so the LISP counts them and leaves them alone.

The measured value of every dimension stays the same: 1000, 1500, 800, 1200 and 1,414.21. Only the position of the dimension line, and the text that travels with it, changes; the definition points are untouched.

The whole command is one undo step. On the stacked set at 300, 350 and 900, running DHD brings all three into line, and a single U returns them to exactly 300, 350 and 900.

The code

The name DHD was checked against every built-in AutoCAD 2027 command, every alias in acad.pgp and every command in the Institute's LISP set; it clashes with none. Every helper function carries the prefix iic-dhd-, so it can be loaded alongside other LISP files without overwriting them.

;;; ==================================================================
;;;  DHD-IIC-EN.LSP  -  align dimension lines in one pass
;;;  Vien Tin hoc Xay dung (IIC) - Truong Dai hoc Xay dung Ha Noi
;;;  https://iic.huce.edu.vn  -  Tel: 0989 427 809
;;; ------------------------------------------------------------------
;;;  Lenh:
;;;    DHD    chon mot loat kich thuoc, bam MOT diem. Moi duong kich
;;;           thuoc duoc day theo phuong vuong goc voi chinh no cho toi
;;;           khi di qua diem ay. Kich thuoc ngang ve cung mot cao do,
;;;           kich thuoc dung ve cung mot hoanh do, trong CUNG MOT lan.
;;;
;;;  Khac voi DIMSPACE va lua chon aliGn cua lenh DIM co san:
;;;    - khong can mot kich thuoc goc, ban bam thang vi tri muon dong;
;;;    - chon lan ca kich thuoc ngang, dung va xien cung mot luc.
;;;
;;;  Chi dong kich thuoc thang (ngang, dung, xoay goc, theo canh xien).
;;;  Kich thuoc ban kinh, duong kinh, goc, toa do bi bo qua va dem lai.
;;;  Con so do (khoang cach hai diem goc) KHONG doi, chi doi vi tri
;;;  duong kich thuoc va chu.
;;;
;;;  Nap tep: go APPLOAD, chon tep nay, bam Load.
;;;  Tep luu bang ma UTF-8. Sua bang Notepad thi nho luu lai dung UTF-8.
;;; ==================================================================

(vl-load-com)

;;; ------------------------------------------------------------------
;;;  Phan chung - moi ham phu deu mang tien to iic-dhd- de khong de
;;;  len ham cung ten cua tep lisp khac dang nap trong cung ban ve.
;;; ------------------------------------------------------------------

(defun iic-dhd-bang-ten ()
  (princ "\nLISP written by RDSIC - Institute of Information Technology in Civil Engineering")
  (princ "\nwebsite: https://iic.huce.edu.vn")
  (princ "\nTel: 0989 427 809")
  (princ)
)

(defun iic-dhd-tai-lieu () (vla-get-ActiveDocument (vlax-get-acad-object)))

(defun iic-dhd-cong (a b) (mapcar '+ a b))
(defun iic-dhd-tru (a b) (mapcar '- a b))
(defun iic-dhd-nhan (v k) (mapcar '(lambda (x) (* x k)) v))
(defun iic-dhd-cham (a b) (apply '+ (mapcar '* a b)))

;; Goc cua duong kich thuoc. Tra ve nil neu khong phai kich thuoc thang.
;;   kieu 0: kich thuoc ngang / dung / xoay goc -> goc nam o ma 50
;;   kieu 1: kich thuoc theo canh xien          -> goc tu diem 13 toi 14
(defun iic-dhd-goc (d / kieu)
  (setq kieu (logand (cdr (assoc 70 d)) 7))
  (cond
    ((= kieu 0) (cdr (assoc 50 d)))
    ((= kieu 1) (angle (cdr (assoc 13 d)) (cdr (assoc 14 d))))
    (t nil)
  )
)

;; Day duong kich thuoc theo phap tuyen cua no cho toi khi di qua p.
;; Dich ca diem dinh duong kich thuoc (ma 10) lan diem giua chu (ma 11)
;; cung mot vec to, nen chu di theo duong kich thuoc.
(defun iic-dhd-doi (en p / d g n p10 p11 dl)
  (setq d (entget en)
        g (iic-dhd-goc d))
  (if g
    (progn
      (setq n   (list (- (sin g)) (cos g) 0.0)
            p10 (cdr (assoc 10 d))
            p11 (cdr (assoc 11 d))
            dl  (iic-dhd-nhan n (iic-dhd-cham (iic-dhd-tru (list (car p) (cadr p) (caddr p10)) p10) n)))
      (setq d (subst (cons 10 (iic-dhd-cong p10 dl)) (assoc 10 d) d))
      (if p11 (setq d (subst (cons 11 (iic-dhd-cong p11 dl)) (assoc 11 d) d)))
      (entmod d)
      (entupd en)
      T
    )
    nil
  )
)

;;; ------------------------------------------------------------------
;;;  Lenh DHD
;;; ------------------------------------------------------------------

(defun c:DHD (/ *error* ss p i n bo)
  (defun *error* (m)
    (vla-EndUndoMark (iic-dhd-tai-lieu))
    (if (not (wcmatch (strcase m) "*CANCEL*,*QUIT*,*BREAK*"))
      (princ (strcat "\nError: " m))
    )
    (princ)
  )
  (iic-dhd-bang-ten)
  (princ "\nSelect the dimensions to align:")
  (setq ss (ssget '((0 . "DIMENSION"))))
  (if ss
    (progn
      (setq p (getpoint "\nPick the point the dimension lines must pass through: "))
      (if p
        (progn
          (setq p (trans p 1 0))
          (vla-StartUndoMark (iic-dhd-tai-lieu))
          (setq i 0 n 0 bo 0)
          (while (< i (sslength ss))
            (if (iic-dhd-doi (ssname ss i) p)
              (setq n (1+ n))
              (setq bo (1+ bo))
            )
            (setq i (1+ i))
          )
          (vla-EndUndoMark (iic-dhd-tai-lieu))
          (princ (strcat "\nAligned " (itoa n) " dimension(s)."))
          (if (> bo 0)
            (princ (strcat " Skipped " (itoa bo) " that are not linear dimensions."))
          )
        )
      )
    )
    (princ "\nNo dimensions selected.")
  )
  (princ)
)

(princ "\nDHD-IIC-EN loaded: type DHD to align dimensions.")
(iic-dhd-bang-ten)

A version with Vietnamese prompts: dhd-iic.lsp.

Which one to use

SituationUse
One dimension is already right and a few parallel ones should follow itDIMSPACE with 0, or DIM → G
Tiers of dimensions should be evenly spacedDIMSPACE with an explicit value, not Auto
Horizontal and vertical dimensions should all go to a freely picked positionThe DHD LISP
Extension lines should be trimmed to a neat lengthour dimension trimming LISP

To place a whole chain of dimensions in one go so there is less to align afterwards, see our quick dimension LISP.

Three things often repeated that are not true

Often heardWhat the 2027 release actually does
DIMSPACE aligns every dimension you selectOnly those parallel to the base; a vertical one is ignored without a word
Accepting Auto gives neat spacingAuto uses the text height before DIMSCALE; at a scale of 40 it spaces by 0.36
Moving a dimension line changes the valueThe value stays; only the position of the line changes

Frequently asked questions

How do I use the LISP to align dimensions?

Load dhd-iic-en.lsp, type DHD, select the dimensions, then pick the point the dimension lines must pass through.

How do I align dimensions in AutoCAD without a LISP?

Type DIMSPACE, pick a base dimension, pick the others, and type 0. Only dimensions parallel to the base are aligned.

Why will the vertical dimension not line up with the horizontal ones?

DIMSPACE and DIM → aliGn handle only dimensions parallel to the base. The DHD LISP handles both kinds in one pass.

Does aligning change the measured value?

No. The value stays; only the position of the dimension line and text changes.

How do I space tiers of dimensions evenly?

Use DIMSPACE, pick the base, pick the other tiers and type a spacing such as 250. Do not accept Auto on a scaled drawing.

What if I align the wrong ones?

Type U once. The whole DHD command is a single undo step.

About the author

TS. Đỗ Quốc Hoàng — Vice Director of the Institute of Information Technology in Civil Engineering, Hanoi University of Civil Engineering, and a specialist in software development for construction