eplisp

AutoCAD Center Text in Rectangle LISP for Room Names

Writes a centered text in the middle of an area defined by two corner points.

Commands: TXTCENTER

Load the downloaded .lsp file with the APPLOAD command in AutoCAD or GstarCAD, then type the command name. How to load a LISP file

Download all tools in one file (138 KB)

TXTCENTER is an AutoCAD center text in rectangle LISP. Pick two opposite corners of an area and type the text; it is placed exactly at the midpoint between the two corners, middle-center justified. Use it for room names on floor plans, labels in title block boxes or text in table cells.

The command runs in a loop, so after one text you can go straight to the next area. The text height is asked once, for the first text, and reused for the rest of that run.

How to use it

  1. Load the file with APPLOAD and type TXTCENTER.
  2. Click one corner of the area, then the opposite corner.
  3. Type the text; spaces are allowed.
  4. For the first text, enter the height or press Enter to accept the current TEXTSIZE.
  5. Keep picking corners for the next areas; press Enter at the corner prompt to finish.

Notes and tips

  • The midpoint is calculated from the two corners you pick; the tool does not detect boundaries or closed polylines.
  • For L-shaped or irregular rooms the result is the center of the rectangle spanned by the two corners, not the centroid.
  • Text goes on the current layer in the current text style; restart the command to use a different height.
  • Pressing Enter at the text prompt skips that area and moves on to the next one.

Frequently asked questions

How do I center a room name inside a room in AutoCAD?

Run TXTCENTER, pick two opposite corners of the room and type the name. The text is placed, centered, at the midpoint of the two corners.

Can I place several labels in one go?

Yes. The command keeps asking for the next area until you press Enter at the corner prompt.