Wednesday, March 11, 2026

FREE LISP : Improving Drawing Quality by using Ortho-Check LISP

 

Improving Drawing Quality with an Ortho-Check LISP Tool

In many CAD workflows, especially in architectural, engineering, and construction drawings, maintaining orthogonal geometry (lines that are perfectly horizontal or vertical) is essential. However, during the drafting process, it is very common for small inaccuracies to occur. These errors may be almost invisible on screen but can create serious issues later in design coordination, quantity calculations, and model conversions.

An AutoLISP Ortho-Check tool helps solve this problem by automatically detecting and highlighting lines or polyline segments that are not aligned with the X or Y axis.



Common Problems in CAD Drawings

Even experienced CAD users frequently encounter situations where geometry is slightly misaligned. Some typical causes include:

1. Accidental Ortho Off
When the Ortho mode is turned off during drafting, lines may be drawn at a small angle unintentionally.

2. Snap or Input Precision Issues
Manual coordinate input or object snaps may produce tiny deviations, resulting in lines that appear straight but are actually rotated by a small angle.

3. Imported or Converted Drawings
Drawings imported from other software or converted from formats such as PDF, BIM models, or GIS data often contain geometry that is not perfectly orthogonal.

4. Editing Existing Geometry
Stretching, trimming, or modifying existing elements may introduce small angle deviations.

5. Polyline Segment Errors
Polylines can contain segments that are slightly rotated even when most of the shape is orthogonal.

These issues are often difficult to detect manually, especially in large drawings containing hundreds or thousands of objects.


Risks of Non-Orthogonal Geometry

Small angular errors can cause several downstream problems, including:

  • Dimension inaccuracies

  • Incorrect area or quantity calculations

  • Problems when generating BIM models

  • Difficulty when aligning walls, grids, or structural elements

  • Errors during CNC or fabrication workflows

  • Poor drawing standards and quality control issues

Because of these risks, many organizations implement drawing quality control (QC) procedures before issuing drawings.


How the AutoLISP Ortho-Check Tool Helps

The Ortho-Check AutoLISP tool automates the detection process by performing the following steps:

  1. The user selects lines and polylines in the drawing.

  2. The program analyzes each segment of the geometry.

  3. It compares the X and Y coordinates of endpoints using a tolerance value.

  4. Any segment that is not horizontal or vertical is identified.

  5. The object is automatically highlighted for easy review.

  6. A summary dialog reports the number of checked objects and detected errors.

This process allows users to quickly locate problematic geometry that would otherwise be very difficult to find manually.


Key Benefits

1. Faster Quality Control
Instead of visually inspecting drawings, the tool checks hundreds or thousands of objects in seconds.

2. Improved Drawing Accuracy
It ensures that geometry strictly follows orthogonal design standards.

3. Reduced Risk of Downstream Errors
By identifying geometry issues early, the tool prevents problems in modeling, documentation, and construction.

4. Works with Large Drawings
The AutoLISP solution is lightweight and performs efficiently even with very large datasets.

5. Supports Lines and Polylines
The tool checks both simple lines and complex polyline segments, which are common in architectural and engineering drawings.

6. Easy Integration into QC Workflow
Because the tool runs directly inside AutoCAD, it can easily become part of a standard drawing review procedure.


Practical Use Cases

This tool is particularly useful for:

  • Architectural floor plans

  • Structural grid layouts

  • Infrastructure drawings

  • Shop drawings

  • CAD files converted from BIM models

  • Drawings received from external consultants

In these scenarios, ensuring that geometry is truly orthogonal can significantly improve drawing quality and coordination.


Conclusion

Small geometric inaccuracies are common in CAD drawings, but they can lead to significant problems if left unchecked. An AutoLISP-based Ortho-Check tool provides a simple yet powerful way to automatically detect and highlight non-orthogonal lines and polyline segments.

By incorporating this tool into the drawing review process, CAD teams can improve quality control, reduce errors, and ensure cleaner, more reliable drawings before they are issued for construction or further design development.


Source code

(defun c:QCORTHO (/ ss tol i ent ed typ p1 p2 dx dy pts pt prev flag errss tot err msg)

  (setq tol (getreal "\nSpecify Ortho tolerance <0.0001>: "))
  (if (null tol) (setq tol 0.0001))

  (prompt "\nSelect LINE / POLYLINE to check: ")
  (setq ss (ssget '((0 . "LINE,LWPOLYLINE"))))

  (if ss
    (progn
      (setq i 0)
      (setq tot 0)
      (setq err 0)
      (setq errss (ssadd))

      (while (< i (sslength ss))

        (setq ent (ssname ss i))
        (setq ed (entget ent))
        (setq typ (cdr (assoc 0 ed)))
        (setq flag nil)

        ;; LINE
        (if (= typ "LINE")
          (progn
            (setq p1 (cdr (assoc 10 ed)))
            (setq p2 (cdr (assoc 11 ed)))

            (setq dx (abs (- (car p1) (car p2))))
            (setq dy (abs (- (cadr p1) (cadr p2))))

            (if (and (> dx tol) (> dy tol))
              (setq flag T)
            )
          )
        )

        ;; LWPOLYLINE
        (if (= typ "LWPOLYLINE")
          (progn
            (setq pts '())

            (foreach d ed
              (if (= (car d) 10)
                (setq pts (append pts (list (cdr d))))
              )
            )

            (setq prev nil)

            (foreach pt pts
              (if prev
                (progn
                  (setq dx (abs (- (car prev) (car pt))))
                  (setq dy (abs (- (cadr prev) (cadr pt))))

                  (if (and (> dx tol) (> dy tol))
                    (setq flag T)
                  )
                )
              )
              (setq prev pt)
            )
          )
        )

        ;; mark error
        (if flag
          (progn
            (redraw ent 3)
            (ssadd ent errss)
            (setq err (+ err 1))
          )
        )

        (setq tot (+ tot 1))
        (setq i (+ i 1))
      )

      ;; -------- dialog summary --------
      (setq msg
        (strcat
          "QC ORTHO CHECK RESULT\n\n"
          "Total objects checked : " (itoa tot) "\n"
          "Non-Ortho objects : " (itoa err) "\n\n"
          "Highlighted objects need correction."
        )
      )

      (alert msg)

    )
  )

  (princ)
)


FREE LISP : Improving Drawing Quality by using Ortho-Check LISP

  Improving Drawing Quality with an Ortho-Check LISP Tool In many CAD workflows, especially in architectural, engineering, and construction...