Free AutoCAD LISP commands
Small commands that save a few minutes every day: number block attributes, write areas into the drawing, isolate layers, clean up a file, export tables to CSV. Every command is one file that you can read, copy or download. Take only what you need.
Free for personal and commercial use. Please read the terms before you share or republish them. LISP terms
How to load them in AutoCAD · Tested in AutoCAD (full version). Other programs that run AutoLISP may work, but they are not tested.
62 commands
CXATTFILLBlocks and attributesFill an attribute in many blocksSets one attribute to the same value in every selected block, for example STATUS = NEW across a whole sheet, optionally only where it is still empty.CXATTNUMBlocks and attributesNumber a block attribute in sequenceNumbers one attribute across many blocks, such as V-001, V-002, in reading order across or down the drawing.CXATTCOPYBlocks and attributesCopy attribute values from one block to othersTakes the attribute values of one block and writes them into the other blocks you select, either all tags or just the ones you name.CXATTVISBlocks and attributesShow or hide block attributesMakes the attributes of many blocks visible or invisible in one step, for one tag or all tags.CXBLKCOUNTBlocks and attributesCount blocks by nameLists how many times each block appears in the drawing or in a selection, most frequent first, and can place the list as a text block.CXBLKREPLBlocks and attributesReplace blocks with another blockSwaps selected blocks for a different block that is already in the drawing. Each keeps its position, rotation and scale.CXBLKRENBlocks and attributesRename blocks in bulkRenames many block definitions at once: find and replace in the name, add a prefix or suffix, limited to names that match a wildcard.CXBLKXPBlocks and attributesExplode blocks but keep their attribute textExplodes blocks and keeps what their attributes said as ordinary texts instead of losing it, which is what plain EXPLODE does.CXBLKSELBlocks and attributesSelect blocks by name or attribute valueSelects every block with a given name, or only those whose attribute has a given value, so you can then move, copy or edit them together.CXBLKATBlocks and attributesInsert a block at many places at oncePuts a block at the centre of every selected circle, arc or ellipse, at every point, text or block, and at the middle of every line, turned along it. Fast for symbols at hundreds of positions.CXBYLAYERClean-upSet color, linetype and lineweight back to ByLayerRemoves individual color, linetype and lineweight overrides so objects follow their layers again, the first step in making a drawing meet a standard.CXZEROLENClean-upFind and delete zero-length lines and polylinesFinds lines, arcs and polylines that are too short to see and either selects them for you to inspect or deletes them.CXEMPTYTXTClean-upFind and delete empty textFinds texts that show nothing, whether empty, only spaces or only formatting, and selects or deletes them.CXFONTCHKClean-upList text styles whose font file is missingChecks every text style and lists the ones that point to an SHX font file that cannot be found, the usual cause of question marks in text.CXFONTSUBClean-upReplace one font file by another in all text stylesChanges every text style that uses a given font file to use another one, then regenerates the drawing so you see the result.CXPURGEClean-upPurge the drawing until nothing more goesRuns purge repeatedly until nothing more can be removed, since unused items often hide inside other unused items, and reports what was removed.CXDELTYPEClean-upDelete every object of the type you pickClick one object, for example a hatch or a leader, and delete every object of the same type, in the whole tab or only on that layer.CXDIMRESETClean-upReset typed-over dimension text to the measured valueFinds dimensions whose text was typed over by hand and puts the real measured value back, so numbers can be trusted again.CXDUPDELClean-upDelete exact duplicate objectsFinds objects drawn twice on top of each other with identical properties and deletes the extra copies, keeping one of each.CXOBJCOUNTClean-upCount the objects by typeShows how many lines, texts, blocks, hatches and so on the drawing or your selection contains, most frequent first.CXTXT2CSVExport and import (CSV)Export text to a CSV fileWrites the selected texts to a spreadsheet file with layer, position, height and content, in reading order from top to bottom.CXBLK2CSVExport and import (CSV)Export blocks and their attributes to a CSV fileExports every block with its name, layer, position, rotation, scale and one column for each attribute, a ready-made parts list.CXCOORD2CSVExport and import (CSV)Export coordinates to a CSV fileWrites the coordinates of points, line ends, polyline vertices, circle centres, texts and blocks to a spreadsheet file.CXLAYER2CSVExport and import (CSV)Export the layer list to a CSV fileSaves a table of all layers with color, linetype, lineweight, on, frozen, locked and plot state and the number of objects on each.CXAREA2CSVExport and import (CSV)Export areas and perimeters to a CSV fileSaves area, perimeter and centre point of every closed polyline, circle and ellipse in your selection as a table.CXOBJ2CSVExport and import (CSV)Export an object list to a CSV fileLists every object with its type, layer, color, linetype and first point, a quick inventory of a drawing.CXDIM2CSVExport and import (CSV)Export dimension values to a CSV fileSaves each dimension's measured value, the text it shows and its style, so you can check for typed-over numbers.CXCSV2TXTExport and import (CSV)Place text from a CSV fileReads x, y and text from a spreadsheet file and puts a text at every position, with an optional height and rotation per row.CXPTSExport and import (CSV)Plot named points from a CSV filePlots survey-style points from a spreadsheet file: name, X, Y and optional Z become a point with its name written beside it.CXCSV2ATTExport and import (CSV)Fill block attributes from a CSV fileUpdates the attributes of many blocks from a spreadsheet: each row finds its block by a key such as a tag number and sets the other columns.CXLAYISOLayersIsolate the layers of the objects you pickSwitches off every layer except those of the objects you select, so you can concentrate on one discipline. CXLAYRES brings everything back.CXLAYRESLayersBring back the layers CXLAYISO switched offSwitches on exactly the layers CXLAYISO hid. If nothing was isolated it offers to switch on every layer that is off.CXLAYOFFLayersSwitch off the layers of the objects you pickHides the layers of the objects you select with one click, without opening the layer manager.CXLAYCOLORLayersChange the color of the layers you pickSets a new color on the layers of the objects you select. A layer that is switched off stays off.CXLAYRENLayersRename layers by find and replaceRenames many layers at once by replacing part of their names, for example OLD- with NEW-, and tells you what was changed.CXLAYSETLayersMove objects to the layer of another objectMoves the selected objects onto the layer of an object you click, matching layers without typing layer names.CXLAYMRGLayersMerge layers into one and delete the restMoves everything from the layers of the objects you select onto the layer of one more object you click, then deletes the emptied layers.CXLAYCOUNTLayersCount the objects on each layerShows how many objects sit on each layer in the drawing or in your selection, most used first, and can place the list in the drawing.CXLAYSELLayersSelect everything on the layers you pickSelects every object on the layers of the objects you pick, in the current tab, so you can move, copy or change them together.CXLAYSTDLayersCreate a set of layers from a CSV listBuilds your layer standard from a spreadsheet: name, color and linetype per line. Existing layers are updated to match.CXAREAMeasuring and polylinesWrite the area inside closed shapesWrites the area as text in the middle of every closed polyline, circle or ellipse, in the unit you want, with your own prefix and suffix.CXLENMeasuring and polylinesWrite the length along lines, arcs and polylinesWrites each object's length as text alongside it, turned to follow the line and always readable. Circles get their circumference.CXSUMMeasuring and polylinesTotal length and area by layerAdds up the length and the area of the selected objects layer by layer and gives a grand total, ready to copy or to place as a table.CXCENTROIDMeasuring and polylinesFind and mark the centre of closed shapesFinds the true centre of gravity of closed polylines, even with arc segments, and circles and ellipses, and can mark it with a cross.CXDISTMeasuring and polylinesMeasure a path point by pointClick along a route and see every leg's length, angle and offsets plus the running total, with Undo for the last point.CXPLCLOSEMeasuring and polylinesClose polylines whose ends almost meetCloses open polylines whose end lies within a distance you set of their start, and removes a doubled last point when the ends are exactly on top of each other.CXPLREVMeasuring and polylinesReverse the direction of lines and polylinesTurns lines and polylines around so they start where they ended. Arc segments and widths keep their shape.CXPLCLEANMeasuring and polylinesRemove duplicate and straight-line verticesSimplifies polylines by removing points that sit on top of each other and, if you like, points that lie on a straight line between their neighbours.CXPLWIDTHMeasuring and polylinesSet one width for many polylinesGives every selected polyline the same width, or turns them all back to hairlines, clearing any widths set on single segments.CXJOINMeasuring and polylinesJoin lines and arcs into polylines, gaps allowedJoins lines, arcs and polylines that touch into single polylines, and can bridge small gaps up to a distance you give.CXNUMTextNumber texts in sequenceTurns a pile of texts into a numbered series: 1, 2, 3 or P-001, P-002, in the order you pick or in reading order across or down the drawing.CXTXTADDTextAdd a prefix or suffix to many textsPuts the same text in front of or after every selected text, for example DN on every pipe size or mm on every dimension note.CXTXTCUTTextCut characters off the ends of textsRemoves the first or last few characters of every selected text, or everything before or after a marker you name.CXTXTCASETextChange the case of many textsSwitches every selected text to UPPER, lower or Title Case in one go.CXTXTREPLTextFind and replace in many texts at onceReplaces a word or phrase in every selected text, with an optional match-case switch, and tells you how many replacements it made.CXTXTCLEANTextClean up spaces and formatting in textsRemoves leading, trailing and doubled spaces, and strips fonts, colors and size overrides from multiline text while keeping its line breaks.CXT2MTextMerge single-line texts into one multiline textJoins several lines of text into one multiline text, ordered from top to bottom, so a paragraph typed line by line becomes a single object.CXM2TTextBreak multiline text into single linesSplits a multiline text into one single-line text per line, each keeping its place on the page, ready for tools that only handle single-line text.CXTXTALIGNTextLine texts up with a reference textMoves or rotates many texts so they match one reference text: same left edge, same baseline, same rotation or same height.CXTXTSTYLETextChange text style and height for many textsSets one text style, and optionally one height, on every selected text. Handy for fixing drawings that mix fonts.CXTXTCOUNTTextCount identical textsLists every different text in the drawing or selection with how often it occurs, most frequent first. Useful for room names, tags and notes.CXTXTSUMTextAdd up the numbers in textsReads the numbers in selected texts, such as quantities or lengths, and reports their sum, average, smallest and largest value.