Efficient Drafting: Automatically Drawing Tangent Lines in AutoCAD with TangentDraw.lsp
Program Description
TangentDraw.lsp is a lightweight, high-performance AutoLISP utility built to simplify a very common drafting task: creating tangent lines between curved objects. Instead of relying on repeated object snap overrides and manual precision clicks, this tool lets you select two objects and handles the tangency automatically.
The program works with CIRCLE, ARC, and ELLIPSE entities. It uses the exact point you click on each object to determine the intended tangency side. That means it can generate both:
- External tangents
- Internal (crossed) tangents
There is no manual calculation, no geometry setup, and no need to fight with snaps. The result is a clean, precise tangent line created instantly.
Step-by-Step Guide
Using the TANDRAW command is simple and integrates directly into any existing drafting workflow.
Load the Script
- Drag and drop the
.lspfile into the drawing area - Or use the APPLOAD command
For reference, see Autodesk documentation on loading LISP files: https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-APPLOAD
Initialize the Tool
- Type TANDRAW in the command line
- Press Enter
Select First Object
- Click on the first circle, arc, or ellipse
- The click location matters
Pro tip: Click near the area where you expect the tangent point.
Select Second Object
- Click on the second object
- Again, your click position drives the result
This is how the program determines which of the four possible tangents to create.
Completion
- The tangent line is created immediately
- Your original OSNAP and system settings are restored automatically
No cleanup required.
Download the script here.
Program Code (AutoLISP)
Below is the full source code of TangentDraw.lsp as used in production:
;;; TangentDraw.lsp
;;; Command: TANDRAW
;;; Description: Draws a line tangent to two selected circles, arcs, or ellipses.
(defun c:TANDRAW (/ old_osmode old_cmdecho ent1 ent2 pt1 pt2 isValid type1 type2)
;; Save current system variables
(setq old_osmode (getvar "OSMODE"))
(setq old_cmdecho (getvar "CMDECHO"))
;; Set system variables for clean execution
(setvar "CMDECHO" 0)
(setvar "OSMODE" 0) ; Temporarily disable running osnaps to prevent conflicts
(setq isValid T)
;; --- Get the first object ---
(while (and isValid (not ent1))
(setq ent1 (entsel "\nSelect first Circle or Arc near the desired tangency point: "))
(if ent1
(progn
(setq type1 (cdr (assoc 0 (entget (car ent1)))))
;; Validate that the object is a curve
(if (not (member type1 '("CIRCLE" "ARC" "ELLIPSE")))
(progn
(princ "\nInvalid selection. Object must be a Circle, Arc, or Ellipse.")
(setq ent1 nil)
)
)
)
;; Handle user pressing Enter or Esc
(setq isValid nil)
)
)
;; --- Get the second object ---
(if isValid
(while (and isValid (not ent2))
(setq ent2 (entsel "\nSelect second Circle or Arc near the desired tangency point: "))
(if ent2
(progn
(setq type2 (cdr (assoc 0 (entget (car ent2)))))
;; Validate that the object is a curve
(if (not (member type2 '("CIRCLE" "ARC" "ELLIPSE")))
(progn
(princ "\nInvalid selection. Object must be a Circle, Arc, or Ellipse.")
(setq ent2 nil)
)
)
)
(setq isValid nil)
)
)
)
;; --- Draw the tangent line ---
(if (and ent1 ent2)
(progn
;; Extract the specific points the user clicked
(setq pt1 (cadr ent1))
(setq pt2 (cadr ent2))
;; Pass the points to the LINE command with a forced TAN object snap
(command "_.LINE" "_TAN" pt1 "_TAN" pt2 "")
(princ "\nTangent line drawn successfully.")
)
(princ "\nCommand cancelled.")
)
;; Restore original system variables
(setvar "OSMODE" old_osmode)
(setvar "CMDECHO" old_cmdecho)
;; Exit quietly
(princ)
)
;; Print loading message to the command line
(princ "\n==> TangentDraw.lsp loaded. Type TANDRAW to start.")
(princ)
Note: Ensure you save the file with a .lsp extension using a plain text editor such as Notepad or VS Code. Avoid smart quotes or formatted text editors, as they can break AutoLISP syntax.
How It Works (Practical Insight)
This routine does not calculate tangency using trigonometry. Instead, it leverages AutoCAD’s built-in _TAN object snap through AutoLISP.
Key behavior:
- It captures the user-picked points
- It forces the Tangent snap override (_TAN)
- It feeds both into the LINE command
This approach avoids common issues:
- No dependency on center-to-center math
- No failures with ellipses
- No UCS-related errors
If you’ve ever written tangent routines using geometry formulas, you already know where those break. This method doesn’t.
Advanced Geometric Intelligence
For CAD managers and advanced users, this tool solves several real production problems.
Most LISP routines that attempt tangent construction rely on:
- Distance calculations
- Angle derivations
- Circle-only assumptions
Those methods fail when:
- Working in a rotated UCS
- Handling ellipses
- Dealing with user intent (which tangent?)
TangentDraw.lsp avoids all of that by using AutoCAD’s native geometric engine.
What that gives you:
- Full compatibility with all UCS configurations
- Native support for ellipses and arcs
- Reliable tangency without custom math
- Reduced input steps (less clicking, fewer commands)
If you manage CAD standards or toolsets, this is the type of utility that belongs in a shared LISP library.
Why This Approach Is More Reliable
Using _TAN snap via AutoLISP is not just simpler—it’s more robust.
Advantages over traditional methods:
- Uses AutoCAD’s internal solver (same engine as manual drafting)
- Eliminates rounding errors from custom calculations
- Works consistently across drawings and coordinate systems
- Handles edge cases without additional code
- Direct visual control: since the line is generated based on your click position, there is no trial-and-error to figure out which tangent is created. The result matches user intent immediately.
This is the same logic experienced drafters use manually—just automated.
Integration into Your Workflow
You can integrate TangentDraw.lsp into:
- Your startup suite
- A custom tool palette button
- A shared network LISP folder
For enterprise setups, load it via ACADDOC.lsp so it’s always available.
Autodesk reference on startup files: https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-ACADDOC
Common Use Cases
This tool is useful anywhere tangency is required without overthinking the geometry:
- Road and alignment design
- Mechanical layouts involving rollers or cams
- Pulley and belt systems
- Piping and routing
- Architectural detailing
- Quick construction geometry during design iterations
FAQ
What objects are supported?
The routine works with:
- Circles
- Arcs
- Ellipses
Ellipses are the key advantage here. Very few free LISP routines handle ellipse tangency reliably. This one does, because it relies on AutoCAD’s native snap engine rather than custom math.
Does it work in a rotated UCS?
Yes. It relies on AutoCAD’s native geometry engine, so it works in any UCS without adjustment.
Can it create all possible tangents?
Yes, indirectly. There are up to four possible tangents between two curves. The one created depends on where you click on each object.
Why not calculate tangents mathematically?
Because it’s less reliable in production:
- Breaks with ellipses
- Sensitive to UCS changes
- Requires more code and error handling
Using _TAN snap is faster and matches AutoCAD’s internal logic.
Does it affect my object snap settings?
No. The routine temporarily disables running snaps and restores them after execution.
Can I modify it to draw multiple tangents?
Yes. You can extend the routine to:
- Repeat the command automatically
- Add selection loops
- Store and reuse click points
Is this better than manual TAN snapping?
Yes, especially when working fast. It reduces:
- Missed snaps
- Extra clicks
- Repeated command input
Final Notes
This is the kind of small utility that removes friction from daily drafting. It doesn’t replace core AutoCAD tools—it uses them properly and saves time where it matters.
If you maintain a custom LISP toolkit, this one earns its place quickly.

