What's in the pack
Eleven AutoLISP scripts (.lsp files) that speed up everyday work with floor plans: measuring lengths and areas, labelling areas, splitting lines into segments, numbering objects, counting symbols and exporting texts from a drawing to Excel. They work in AutoCAD and GstarCAD on Windows, are free and need nothing installed apart from the file itself.
⬇ Download all scripts (ZIP) or download a single file from the descriptions below.
| Script | Command | What it does |
|---|---|---|
| SumLines.lsp | SUMLINES |
total length of lines and polylines |
| SumArea.lsp | SUMAREA |
total area of closed objects |
| AreaLabels.lsp | AREALABELS |
area labels + totals by layer to Excel / CSV |
| LineLabels.lsp | LINELABELS |
length labels + totals by layer to Excel / CSV |
| SplitIntoLines.lsp | SPLITINTOLINES |
split lines into segments of a given length or into N parts |
| CountSymbols.lsp | COUNTSYMBOLS |
count symbols into a new or existing table |
| AutoNumber.lsp | AUTONUMBER, AUTONUMBERPREFIX |
number objects in a chosen direction |
| AppendText.lsp | APPENDTEXT |
append text to many text objects |
| DecreaseTextValue.lsp | DECREASETEXTVALUE |
subtract a value from numbers in texts |
| ExportText.lsp | EXPORTTEXT |
export texts to a TXT file |
| ExportTextToCSV.lsp | EXPORTTEXTTOCSV |
export texts from one layer to Excel / CSV |
How to load a script
For the current session (until the program is closed):
- Save the
.lspfile in a permanent folder, e.g.C:\CAD\Scripts. - Type the
APPLOADcommand (or simply drag the.lspfile onto the open drawing). - Select the file and click Load.
- Type the script's command name (e.g.
SUMLINES) and press Enter.
Permanently in GstarCAD:
- Type
APPLOAD. - Click the briefcase icon (Startup Suite).
- Click Add and select the
.lspfile. - Close the dialogs and restart GstarCAD — the script will be loaded on every start.
Permanently in AutoCAD:
- Type
APPLOAD. - In the Startup Suite section click Contents….
- Click Add…, select the
.lspfile and close the dialogs. - If AutoCAD shows a security warning, choose Always Load or add the scripts folder to the trusted locations (Options → Files → Trusted Locations).
Good to know:
- The command is the name given next to the script, not always the file name. Upper or lower case does not matter.
- All script messages on the command line are in English.
- Undo changes in the drawing with the usual Undo (Ctrl+Z). Make a copy of an important drawing before working on it.
- When a script asks you to choose from options in square brackets, e.g.
[Length/Count], just type the first letter (LorC) or click the option on the command line. Enter accepts the value shown in<…>. - There are two kinds of options: prompts at run time (you answer on the command line) and settings in the file — you change them once by opening the
.lspfile in Notepad and editing the values in the;; ---- SETTINGS ----block (T= yes,nil= no). After changing the file, load it again withAPPLOAD. - Results and CSV files use a decimal comma and a semicolon as the CSV separator (the convention of many European versions of Excel). The
.xlsxfiles store real numbers, so they display correctly in any language version of Excel.
SUMLINES — total length of lines
Adds up the length of the selected lines and polylines. Handy for quickly measuring cable, pipe, kerb or flashing lengths.
- Type
SUMLINES. - Select lines and polylines (with a window or by clicking).
- Press Enter — the result appears in a message box and on the command line, and it is also copied to the clipboard, so you can paste it straight into Excel (Ctrl+V).
The result is in drawing units (drawing in mm → result in mm), with a decimal comma. Arcs, splines and other objects are ignored during selection.
Options
Settings in the file:
showAlert—Tshows a message box with the result;nilprints the result on the command line only (no clicking "OK" after each measurement).copyToClip—Tcopies the result to the clipboard;nilleaves the clipboard unchanged.decimals— number of decimal places in the result (default 2).
SUMAREA — total area
Adds up the areas of the selected closed objects: polylines, circles, ellipses, regions and splines. Lets you measure, for example, the floor area of several rooms at once.
- Type
SUMAREA. - Select the objects.
- Press Enter — the result appears in a message box and on the command line, and is copied to the clipboard.
Open polylines are skipped: the script lists how many there are and their handles, so they are easy to find. The result is in square drawing units (drawing in cm → cm²).
Options
Settings in the file:
showAlert—Tshows a message box with the result;nilprints the result on the command line only.copyToClip—Tcopies the result to the clipboard;nilleaves the clipboard unchanged.decimals— number of decimal places in the result (default 2).
AREALABELS — area labels with export to Excel
Labels every selected closed polyline with its layer name and its area in m², and saves the area totals for each layer to an Excel or CSV file. Typical use: outlines of rooms or floor finishes, each type on its own layer — and you get an area schedule straight away.
- Type
AREALABELS. - Select closed polylines and press Enter — a "layer / area m2" label appears in the middle of each one, on the
AREA_LABELSlayer. - In the save dialog choose the folder, name and format of the totals file (by default next to the drawing, drawing name +
_areas). Cancelling the dialog = labels without export.
Notes:
- Every run deletes all texts on the
AREA_LABELSlayer in the whole drawing and creates the labels again — do not put other texts on this layer. - The
.xlsx/.xlsformat requires Excel to be installed; without it the script saves a CSV file with the same name (semicolon, decimal comma). - The label sits in the centre of the polyline's bounding box — for L-shaped outlines it may fall outside the area.
Options
At run time you only choose the location, name and format of the file (.xlsx, .xls or .csv). Settings in the file:
textSize— label text height in drawing units (default 40).areaDivisor— conversion of area to m², depending on drawing units: centimetres →10000.0(default), millimetres →1000000.0, metres →1.0.exportFile—Tsaves the totals to a file;nilonly places the labels, without the save dialog.fileSuffix— ending of the suggested file name (default_areas). The file has the columnssymbol(layer) andarea(area in m²).
LINELABELS — length labels with export to Excel
Labels every selected line or polyline with its layer name and its length in metres, and saves the length totals and object counts for each layer to an Excel or CSV file — e.g. lengths of services runs by type.
- Type
LINELABELS. - Choose which objects to label (see Options).
- Select the objects and press Enter — the labels appear at the middle of each object, on the
LENGTH_LABELSlayer. - In the save dialog choose the folder, name and format of the file. The file has the columns
symbol(layer),length(length in m) andcount(number of objects).
Notes:
- Every run deletes all texts on the
LENGTH_LABELSlayer. - The
.xlsx/.xlsformat requires Excel; without it a CSV with the same name is created.
Options
At run time:
- Objects to label
[Lines/Polylines/All]—Lines: lines only;Polylines: polylines only (the whole polyline length is labelled);All: both. The last choice is remembered until the program is closed. - Totals file — location, name and format (
.xlsx,.xls,.csv); cancel = no export.
Settings in the file:
textSize— label text height (default 40).lengthDivisor— conversion of length to metres: centimetres →100.0(default), millimetres →1000.0, metres →1.0.defaultMode— object choice suggested on the first run:"Lines","Polylines"or"All"(default).exportFile—Tsaves the totals to a file;nilonly places the labels.fileSuffix— ending of the suggested file name (default_lengths).
SPLITINTOLINES — split lines into segments
Splits the selected lines and polylines into segments of a given length or into a given number of equal parts. Useful e.g. for laying out metal sheets or membrane rolls along a length, dividing a route into installation sections or setting out post spacing.
- Type
SPLITINTOLINES. - Select lines and polylines, press Enter.
- Choose the split mode and enter the segment length or the number of parts (see Options).
- Each object is replaced by the segments.
Notes:
- Segments follow the polyline shape — bends and arcs are kept. They inherit the original's layer, colour, linetype and lineweight.
- Objects shorter than the given length are skipped.
- Old-style polylines (POLYLINE type) are not supported — convert them first with the
CONVERTPOLYcommand. - The whole split is undone with a single Undo.
Options
At run time (the last answers are remembered until the program is closed — Enter repeats them):
- Split mode
[Length/Count]—Length: segments of a fixed length, the last one (the remainder) is shorter;Count: the given number of equal segments (at least 2). - Segment length (
Lengthonly) — in drawing units; type a number or pick two points in the drawing. - Split direction
[Start/End/Pick](Lengthonly) — decides on which side the shorter remainder ends up.Start: from the start of the object (remainder at the end);End: from the end (remainder at the start);Pick(default): for each object in turn you click near the end the measuring should start from — the object is highlighted meanwhile.
Settings in the file:
deleteOriginal—Tdeletes the object after splitting (default);nilkeeps the original under the segments.outputType—"AUTO"(default): a straight segment becomes a line, a segment with a bend or arc becomes a polyline;"PLINE": every polyline segment is a polyline. Lines always produce lines.
COUNTSYMBOLS — count symbols into a table
Counts how many times each text symbol appears in the drawing (e.g. luminaire, socket, door or window type tags) and inserts a ready table with the quantities or fills in an existing one. A quantity schedule without counting by hand.
- Type
COUNTSYMBOLS. - Select the texts to count (e.g. the whole plan with a window) and press Enter — the result is also listed on the command line.
- Choose a new or an existing table (see Options).
Notes:
- Texts count as identical only when they match character for character (including case and spaces). Works best with simple single-line texts.
- The whole operation is undone with a single Undo.
Options
At run time:
- Table
[New/Existing]—New(default): the script creates the table itself, with a title, SYMBOL / QTY columns and a TOTAL row; you enter the text height (the last value is remembered) and pick the top-left corner of the table.Existing: you pick an existing table whose first row holds the headers and whose column headed SYMBOL lists the symbols — the quantities go to the column headedQTY,COUNTorQUANTITY(if there is none, the script adds aQTYcolumn at the end). A symbol from the table that is not in the drawing gets 0.
Settings in the file (they apply to a new table):
tableTitle— table title (default "SYMBOL SCHEDULE";""= no title).textHeight— text height suggested on the first run (default 40).addTotalRow—Tadds a TOTAL row with the sum at the bottom;nilno total.sortSymbols—Tsorts the symbols alphabetically;nilkeeps the counting order.
AUTONUMBER — number objects in sequence
Gives consecutive numbers to the selected objects — columns, luminaires, parking spaces, rooms — in a chosen direction. The file contains two commands: AUTONUMBER (numbers only) and AUTONUMBERPREFIX (numbers with a prefix, e.g. "P-1", "P-2").
- Type
AUTONUMBERorAUTONUMBERPREFIX. - Select the objects and press Enter.
- Answer the prompts (see Options) — a number appears at each object.
The number is placed at the centre of the object: at the insertion point of a block or text, the centre of a circle, the midpoint of a line, the average of a polyline's vertices.
Options
At run time (Enter = the value in brackets):
- Prefix (
AUTONUMBERPREFIXonly) — text added before the number, e.g.P-→ P-1, P-2… - Direction —
1: left to right;2: right to left;3: bottom to top;4: top to bottom;5: along a line you pick with two points (e.g. a diagonal row of columns). Any other value = 1. - Text height — default 1; in a drawing in mm or cm enter a larger value, e.g. 250.
- Number layer — default
0; the given layer is created if it does not exist. - Start number — default 1; useful when continuing numbering from another plan.
The script has no settings in the file.
APPENDTEXT — append text to many text objects
Appends the same text to the end of many selected text objects at once — e.g. the unit " m2", a suffix "/A" or a floor tag.
- Type
APPENDTEXT. - Enter the text to append and press Enter.
- Select the texts and press Enter.
Works with single-line and multi-line texts.
Options
At run time:
- Text to append — may contain spaces. It is added without a gap, so if you want a space, start the text with one (e.g.
m2).
The script has no settings in the file.
DECREASETEXTVALUE — decrease numbers in texts
Subtracts the given value from numbers written in the selected texts. Useful when recalculating spot levels after a change of datum or when correcting annotations.
- Type
DECREASETEXTVALUE. - Enter the value (see Options).
- Select the texts and press Enter.
Notes:
- The text should contain the number alone, e.g.
12,50,+3,20or-0.45(comma or dot). The result has a decimal comma and as many decimal places as the original (or more, if the entered value needs them); a leading "+" is kept for results ≥ 0. - Texts that are not a number are skipped — they are listed on the command line.
Options
At run time:
- Value to subtract — how much to decrease the numbers by, with a decimal dot, e.g.
0.25(Enter = 0.1). A negative number, e.g.-0.5, increases the values.
The script has no settings in the file.
EXPORTTEXT — export texts to a TXT file
Saves the content of the selected texts to a .txt file — e.g. to move room names, numbers or notes from a drawing to Word or Excel.
- Type
EXPORTTEXT. - Select the texts and press Enter.
- Choose the name and location of the file.
After each text the file has a line with an @ sign — it makes splitting multi-line texts easy (e.g. with Find and Replace in Word). Formatting of multi-line texts (fonts, colours) is removed, line breaks are kept, empty texts are skipped.
Options
At run time you only choose the file name and location. The script has no settings in the file.
EXPORTTEXTTOCSV — texts from one layer to Excel
Saves texts from the selected area to an Excel or CSV file, but only from the layer you point at — e.g. just the room numbers without the other annotations.
- Type
EXPORTTEXTTOCSV. - Click any object on the layer you want the texts from.
- Select the area (with a window) and press Enter.
- Choose the folder, name and format of the file.
Each text goes to a separate row (column A, no header). Formatting of multi-line texts is removed and line breaks are replaced with spaces.
Options
At run time:
- File format —
.xlsx/.xls(saved via Excel; cells are formatted as "Text", so e.g.1/2or+12.30do not turn into a date or a number) or.csv(plain text). Without Excel installed a CSV with the same name is created.
Settings in the file:
fileSuffix— ending of the suggested file name (drawing name +_texts).
Frequently asked questions
Are the scripts free?
Yes. You can download, use and modify all scripts at no cost and without creating an account.
Do they work in AutoCAD LT?
They may not. The scripts use Visual LISP (ActiveX) functions that AutoCAD LT does not support or supports only partly. They work in full AutoCAD and GstarCAD on Windows, and usually also in other AutoLISP-compatible programs such as BricsCAD or ZWCAD.
How do I load a script permanently, so I don't have to do it on every start?
Add the file to the Startup Suite in the APPLOAD dialog — in GstarCAD it is the briefcase icon, in AutoCAD the "Contents…" button. Details are in the "How to load a script" section.
After typing the command I get "Unknown command". What should I do?
Check that the script is loaded (APPLOAD) and that you are typing the command name, not the file name — e.g. the file DecreaseTextValue.lsp is run with the DECREASETEXTVALUE command.
Can I adapt a script to my needs?
Yes. An .lsp file is plain text — open it in Notepad. The settings of each script (e.g. text height, unit conversion, copying the result to the clipboard) are collected in the ;; ---- SETTINGS ---- block and described in the "Options" section of each script on this page.