Small Lisp Collection for AutoCAD

Advertisements

In this article, I will summarize some small AutoCAD Lisp routines that I have shared on my personal Facebook page and design groups. These Lisp routines are very small tools that are useful for solving a specific purpose, for a specific situation.

All of the tools below are provided completely free of charge. You can use, share, and modify them as you see fit to suit your work. The Lisps support most versions of AutoCAD. If you have any problems using them, please contact me.

Small Lisp Collection for AutoCAD

Last update: 28/08/2024. Still ongoing updates...

General Instructions

The downloaded Lisp files usually come in a ZIP compressed file. You need to extract the ZIP file to get the LSP file. These can all be loaded into AutoCAD using the Appload command. To ensure they load into AutoCAD every time you start the program, follow these steps:

  1. Open AutoCAD and type the APPLOAD command on the command line, then press Enter.
  2. The Load/Unload Applications window will appear. Click on the Contents… button at the bottom of the Startup Suite section.
  3. In the Startup Suite window, click on Add… and select the Lisp files you need.
  4. Click OK to save and close the windows. From now on, the Lisp files will automatically load every time you start AutoCAD.

The command for each LSP is written after the hyphen. For example, SumAreaPolyline-SAP.lsp will have the shortcut command SAP. If you want to change this command, open the LSP file with Notepad. Then, edit the shortcut command after the defun statement. The shortcut command is not limited in length, but keep it concise for quick access. Also, ensure it does not duplicate existing AutoCAD commands.

SumAreaPolyline (SAP)

Calculate the total area of selected Polylines and create a text object with a user-defined height. Select the Polylines to be calculated, type SAP, enter the text height, and then pick the text insertion point. The area is converted from mm² to m² by default. If you want to keep the original unit as mm², change the value 1000000 to 1 on line 24.

Download SumAreaPolyline-SAP.lsp >

SumAreaPolyline (SAP)
SumAreaPolyline (SAP)

SumLengthPolyline (SLP)

Calculate the total length of selected Polylines and create a text object with a user-defined height. Select the Polylines to be calculated, type SLP, enter the text height, and then pick the text insertion point. The length is converted from mm to m by default. If you want to keep the original unit as mm, change the value 1000 to 1 on line 25.

Download SumLengthPolyline-SLP.lsp >

SumLengthPolyline (SLP)
SumLengthPolyline (SLP)

QuickBlock (QB)

Create a block quickly from the selected objects with an automatic name. This replaces the combination of Ctrl + Shift + C or Ctrl + Shift + X and Ctrl + Shift + V.

Download QuickBlock-QB.lsp >

QuickBlock (QB)
QuickBlock (QB)

QuickRotate (QR)

Rotate quickly by 45 degrees without selecting a base point and without losing the selection. Applies to a single block only. To change it to 90 degrees, modify line 5 to (setq ang 90.0).

Download QuickRotate-QR.lsp >

QuickRotate (QR)
QuickRotate (QR)

SetDim (SD)

Lisp for quick DIM style change. Designed for drawings with numerous dimension styles received from collaborators. Similar to the “Make Current” command for layers. To use, select any dimension, type SD. The Lisp will change the DIM style and set the active layer to match the selected dimension style.

Download SetDim-SD.lsp >

SetDim (SD)
SetDim (SD)

RandomRotate (RRT)

Lisp to randomly rotate selected objects. Note to execute the RRT command first, then select objects.

Download RandomRotate-RRT.lsp >

RandomRotate (RRT)
RandomRotate (RRT)

RandomScale (RSC)

Lisp for randomly scaling selected objects. Note to execute the RSC command first, then select objects.

Download RandomRotate-RRT.lsp >

RandomScale (RSC)
RandomScale (RSC)

BlockToDefaultLayer (BDL)

Bring all objects within a block to layer 0. Typically used to quickly adjust the linetype and color of furniture library item

Download BlockToDefaultLayer-BDL.lsp >

BlockToDefaultLayer (BDL)
BlockToDefaultLayer (BDL)

CenterBasepoint (CB)

Move the basepoint of selected blocks to the center of the block. The Lisp script will calculate the offset to ensure it does not alter its position or display on the drawing.

Download CenterBasepoint-CB.lsp >

CenterBasepoint (CB)
CenterBasepoint (CB)

CenterText (LCT-MCT-RCT)

Adjust the justification of selected text to Left Center (LCT), Middle Center (MCT), or Right Center (RCT). This replaces the need to manually adjust in the Properties panel.

Download CenterText-MLT-MCT-MRT.lsp >

CenterText (LCT-MCT-RCT)
CenterText (LCT-MCT-RCT)

RotateViewport (R1-R2-RR)

Rotate AutoCAD viewport 90 degrees clockwise (R1) or counterclockwise (R2). Use RR to reset to default orientation.

Download RotateViewport-R1-R2-RR.lsp >

RotateViewport (R1-R2-RR)
RotateViewport (R1-R2-RR)

LoBan (LB1-LB2-LB3)

Check whether the dimensions are “good” or “bad” according to the Lỗ Ban ruler measurements of 52.2 cm (LB1), 42.9 cm (LB2), and 38.8 cm (LB3).

How to Use: Type the command corresponding to the measurement system you want to use, then select the dimension values you want to check. The results will appear after the dimension values. The tool also supports undo functionality.

Download >

LoBan (LB1-LB2-LB3)
LoBan (LB1-LB2-LB3)

LockUnlockViewport (LV-UV)

Lock Viewport (LV) or Unlock Viewport (UV) all viewports in every layout of the current drawing.

Download >

LockUnlockViewport (LV-UV)
LockUnlockViewport (LV-UV)

AutoBlock (B)

AutoBlock (B) combines QuickBlock (QB) and CenterBasepoint (CB). This Lisp will create a block from the selected objects, automatically setting the base point at the center. You do not need to enter a block name or pick a point.

Important Note: Currently, the shortcut assigned to this Lisp is B, which means it will replace the default Block command in AutoCAD. If you want to use the default Block command to enter a name and coordinates, type BL instead. If you wish to change the shortcut, open the Lisp file and modify the first line defun c:B to defun c:AB or to whatever shortcut you prefer.

Update: Fixed the issue of duplicate block names when copying to another drawing.

Download >

AutoBlock (B)
AutoBlock (B)

SetLayerHatch (SLH)

Move all hatch objects in the drawing (including those inside blocks) to the currently active layer.

Download >

SetLayerHatch (SLH)
SetLayerHatch (SLH)

SetLayerText (SLT)

Move all text objects in the drawing (including those inside blocks) to the currently active layer.

Download >

SetLayerText (SLT)
SetLayerText (SLT)

SetLayerDim (SLD)

Move all dimension objects in the drawing (including those inside blocks) to the currently active layer. Note: For dimension objects inside blocks, you’ll need to redefine the block for them to display correctly. A tip is to click on the block, make random edits, then use Ctrl + Z to undo the changes, followed by pressing Save Changes. This is a known “feature” in AutoCAD.

Download >

SetLayerDim (SLD)
SetLayerDim (SLD)

QuickRotate (QR1-QR2-QR3-QR4)

Rotate the selected objects by +90 degrees (QR1), -90 degrees (QR2), +45 degrees (QR3), or -45 degrees (QR4) around their centers. You can modify or add new rotation angles or change the shortcut commands by opening the .lsp file and adjusting the last four defun lines.

Download >

QuickRotate (QR1-QR2-QR3-QR4)
QuickRotate (QR1-QR2-QR3-QR4)

ResetRotate (RR)

Reset the rotation angle of the selected blocks and text to 0 degrees.

Download >

ResetRotate (RR)
ResetRotate (RR)

Thanks for reading!!!

Written by Dang Tien Dung

To know more tips, more errors and the other ways to correct error, you can continue to access CAD tips and refer more interesting things at our web
You can see more commands in AutoCAD… here

Advertisements

You might also like

Advertisements

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More