Free LISP scripts for AutoCAD and GstarCAD

11 free .lsp scripts for AutoCAD and GstarCAD: total lengths and areas, labels with export to Excel, splitting lines into segments, numbering, counting symbols, exporting texts.

Free · AutoCAD and GstarCAD · Windows

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

  1. Save the .lsp file in a permanent folder, e.g. C:\CAD\Scripts.
  2. Type the APPLOAD command (or simply drag the .lsp file onto the open drawing).
  3. Select the file and click Load.
  4. Type the script's command name (e.g. SUMLINES) and press Enter.

Permanently in GstarCAD:

  1. Type APPLOAD.
  2. Click the briefcase icon (Startup Suite).
  3. Click Add and select the .lsp file.
  4. Close the dialogs and restart GstarCAD — the script will be loaded on every start.

Permanently in AutoCAD:

  1. Type APPLOAD.
  2. In the Startup Suite section click Contents….
  3. Click Add…, select the .lsp file and close the dialogs.
  4. 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 (L or C) 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 .lsp file in Notepad and editing the values in the ;; ---- SETTINGS ---- block (T = yes, nil = no). After changing the file, load it again with APPLOAD.
  • Results and CSV files use a decimal comma and a semicolon as the CSV separator (the convention of many European versions of Excel). The .xlsx files store real numbers, so they display correctly in any language version of Excel.

SUMLINES — total length of lines

⬇ SumLines.lsp

Adds up the length of the selected lines and polylines. Handy for quickly measuring cable, pipe, kerb or flashing lengths.

  1. Type SUMLINES.
  2. Select lines and polylines (with a window or by clicking).
  3. 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 — T shows a message box with the result; nil prints the result on the command line only (no clicking "OK" after each measurement).
  • copyToClip — T copies the result to the clipboard; nil leaves the clipboard unchanged.
  • decimals — number of decimal places in the result (default 2).

SUMAREA — total area

⬇ SumArea.lsp

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.

  1. Type SUMAREA.
  2. Select the objects.
  3. 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 — T shows a message box with the result; nil prints the result on the command line only.
  • copyToClip — T copies the result to the clipboard; nil leaves the clipboard unchanged.
  • decimals — number of decimal places in the result (default 2).

AREALABELS — area labels with export to Excel

⬇ AreaLabels.lsp

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.

  1. Type AREALABELS.
  2. Select closed polylines and press Enter — a "layer / area m2" label appears in the middle of each one, on the AREA_LABELS layer.
  3. 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_LABELS layer in the whole drawing and creates the labels again — do not put other texts on this layer.
  • The .xlsx/.xls format 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 — T saves the totals to a file; nil only places the labels, without the save dialog.
  • fileSuffix — ending of the suggested file name (default _areas). The file has the columns symbol (layer) and area (area in m²).

LINELABELS — length labels with export to Excel

⬇ LineLabels.lsp

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.

  1. Type LINELABELS.
  2. Choose which objects to label (see Options).
  3. Select the objects and press Enter — the labels appear at the middle of each object, on the LENGTH_LABELS layer.
  4. In the save dialog choose the folder, name and format of the file. The file has the columns symbol (layer), length (length in m) and count (number of objects).

Notes:

  • Every run deletes all texts on the LENGTH_LABELS layer.
  • The .xlsx/.xls format 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 — T saves the totals to a file; nil only places the labels.
  • fileSuffix — ending of the suggested file name (default _lengths).

SPLITINTOLINES — split lines into segments

⬇ SplitIntoLines.lsp

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.

  1. Type SPLITINTOLINES.
  2. Select lines and polylines, press Enter.
  3. Choose the split mode and enter the segment length or the number of parts (see Options).
  4. 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 CONVERTPOLY command.
  • 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 (Length only) — in drawing units; type a number or pick two points in the drawing.
  • Split direction [Start/End/Pick] (Length only) — 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 — T deletes the object after splitting (default); nil keeps 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

⬇ CountSymbols.lsp

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.

  1. Type COUNTSYMBOLS.
  2. 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.
  3. 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 headed QTY, COUNT or QUANTITY (if there is none, the script adds a QTY column 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 — T adds a TOTAL row with the sum at the bottom; nil no total.
  • sortSymbols — T sorts the symbols alphabetically; nil keeps the counting order.

AUTONUMBER — number objects in sequence

⬇ AutoNumber.lsp

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

  1. Type AUTONUMBER or AUTONUMBERPREFIX.
  2. Select the objects and press Enter.
  3. 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 (AUTONUMBERPREFIX only) — 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

⬇ AppendText.lsp

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.

  1. Type APPENDTEXT.
  2. Enter the text to append and press Enter.
  3. 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

⬇ DecreaseTextValue.lsp

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.

  1. Type DECREASETEXTVALUE.
  2. Enter the value (see Options).
  3. Select the texts and press Enter.

Notes:

  • The text should contain the number alone, e.g. 12,50, +3,20 or -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

⬇ ExportText.lsp

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.

  1. Type EXPORTTEXT.
  2. Select the texts and press Enter.
  3. 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

⬇ ExportTextToCSV.lsp

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.

  1. Type EXPORTTEXTTOCSV.
  2. Click any object on the layer you want the texts from.
  3. Select the area (with a window) and press Enter.
  4. 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/2 or +12.30 do 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.

FixControl

Handling inspections and snag lists?

FixControl lets you log defects directly on building floor plans — with contractor assignment, photos and PDF reports.

🍪 We use cookies
We use cookies essential for the service (login, language, consent memory) and — with your consent — Google Analytics 4 analytics and Google Ads marketing cookies (measuring the effectiveness of our advertising campaigns). Payment operator cookies may be used during payments. Your choice is remembered for one year.   Cookie details  ·  Privacy Policy