LISPs for AutoCAD routines

LISP (LISt Processing) is one of the oldest high-level programming languages, developed in the late 1950s

Files with the .lsp extension are typically AutoLISP scripts—a dialect of LISP used for customizing AutoCAD (a computer-aided design program). These scripts automate tasks, create new commands, or manipulate objects in AutoCAD.

3D offset: LISP for AutoCAD

Many people know that it is impossible to perform 3D-offset function using standard Autocad tools. In 3D modeling this function is very useful. In order to simplify modeling by point clouds it is possible to create a LISP code to get such functionality.

I have created a 3DOFF function that works as follows:
  • function remembers the coordinates of the selected 3D polyline
  • The next step is to zero out all Z coordinates for each point on the selected polyline in order to “put” the polyline on the plane
  • Then the standard AutoCAD offset function is applied to the line that lies on the plane
  • Then each point on the polyline is returned to the Z coordinate it had in the original polyline with an offset added.

What options can be applied in this function:
  • User can select the offset in the plane from the baseline polyline
  • User can select the vertical offset in the Z axis
  • User can set a single Z coordinate for the entire offset polyline
  • You can connect the vertexes of the baseline polyline and the offset polyline.

The user is prompted to select a 3D polyline. The script verifies the selection is valid (POLYLINE type). The script loops through the vertices of the selected polyline and collects their coordinates.

Depending on the Z mode:
  • Add: adds the Z value to each vertex's Z.
  • Replace: sets Z to the given value.
  • None: leaves Z unchanged.

LISP AutoCAD: Z-elevation approximator

In 3d modeling by point clouds it is often necessary to change the Z-coordinate of the selected object: whether it is a polygon or a polyline.

I have created a function in LISP language in autocad to change the elevation of the selected object:
  • by first or last point
  • by lowest or highest point
  • by average value of the elevation
  • change the elevation of all vertexes by changing the elevation of the first and last point of the object.

The ZAPPROX command replaces the Z-values of the vertices of a selected 3D polyline based on interpolation or user-defined methods. It’s typically used to smooth, approximate, or normalize elevations (Z-values) across a polyline. It’s useful for terrain modeling, elevation smoothing, or contour editing in AutoCAD.

3DCORNER - LISP in AutoCAD

In 3D modeling of interiors based on laser scanning results, a common problem is that some corners of the room are not visible to the scanner because they are blocked by furniture or building materials. To solve this problem, it is necessary to take the corner point of the room in the place where it is visible and “lower” it at floor level. In order to automate this process, a LISP function was created in AutoCAD that allows you to automatically lower the corner points of the room to the height mark of the floor level.

How it works:
- I create a 3D-polyline of the corners of the room in the visible part of the room
- I create a 3D polyline of floor elevations near each pivot point of the polyline created in the first step.
- LISP script creates a new 3D polyline, where X and Y are taken from the corners polyline and Z is taken from the elevation polyline.


I help companies
do their job better
If you have a proposal for cooperation, please contact me
Made on
Tilda