|

Automate Your Workflow: Apply Bulk Chamfers to Polylines in AutoCAD with CHMALL

Program Description

ChamferMulti.lsp (CHMALL) is a focused productivity tool for AutoCAD users who are done clicking corner by corner. The standard CHAMFER workflow breaks down on dense geometry—too many vertices, too many chances to miss one. This routine sets a uniform chamfer distance and applies it to every vertex of a selected LWPolyline or Polyline in a single operation.

You get consistent results across the entire shape with one command. That matters when you’re working on machined parts, architectural outlines, or CNC profiles where uniform edge treatment is not optional.

No external dependencies. No UI clutter. Just a direct extension of native AutoCAD behavior.


Download the script here.


Program Code (ChamferMulti.lsp)

;;; ==========================================================================
;;; Program: ChamferMulti.lsp
;;; Command: CHMALL
;;; Purpose: Applies a uniform chamfer to every corner of a selected 
;;;          polyline in one operation.
;;; ==========================================================================

(defun c:CHMALL ( / old_cmdecho old_chamfera current_dist new_dist ent ent_data ent_type)

  ;; Save current system variables
  (setq old_cmdecho (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq old_chamfera (getvar "CHAMFERA"))

  ;; Prompt for uniform chamfer distance, defaulting to current setting
  (setq current_dist old_chamfera)
  (setq new_dist (getdist (strcat "\nSpecify uniform chamfer distance <" (rtos current_dist) ">: ")))

  ;; If user presses Enter, keep the default distance
  (if (not new_dist) 
    (setq new_dist current_dist)
  )

  ;; Set both chamfer distances to the uniform value
  (setvar "CHAMFERA" new_dist)
  (setvar "CHAMFERB" new_dist)

  ;; Prompt user to select a polyline, looping until a valid one is chosen
  (setq ent nil)
  (while (not ent)
    (setq ent (entsel "\nSelect a polyline to chamfer all corners: "))
    (if ent
      (progn
        (setq ent_data (entget (car ent)))
        (setq ent_type (cdr (assoc 0 ent_data)))
        ;; Check if the selected entity is a Polyline or LWPolyline
        (if (not (or (= ent_type "LWPOLYLINE") (= ent_type "POLYLINE")))
          (progn
            (princ "\nSelected object is not a polyline. Please try again.")
            (setq ent nil)
          )
        )
      )
      (princ "\nNo object selected. Please try again.")
    )
  )

  ;; Apply the polyline chamfer command
  (if ent
    (progn
      (command "_.CHAMFER" "_P" (car ent))
      (princ "\nUniform chamfer applied to all corners of the polyline.")
    )
  )

  ;; Restore previous system variables
  (setvar "CMDECHO" old_cmdecho)

  ;; Exit quietly
  (princ)
)

;; Print loading confirmation
(princ "\nChamferMulti.lsp loaded successfully. Type CHMALL to run.")
(princ)

Step-by-Step Guide

1. Load the Script

  • Drag and drop ChamferMulti.lsp into the drawing area
  • Or use APPLOAD and load it manually

Reference:


2. Run the Command

Type:

CHMALL

Press Enter


3. Set Chamfer Distance

  • The prompt shows the current CHAMFERA value
  • Press Enter to keep it
  • Or enter a new value

This sets both:

  • CHAMFERA
  • CHAMFERB

Result: uniform chamfer


4. Select Polyline

  • Click a LWPolyline or Polyline
  • The routine validates the selection
  • If invalid, it keeps prompting

5. Execution

  • The script runs the CHAMFER command using the Polyline option
  • Every vertex is processed automatically

6. Done

  • Command exits cleanly
  • Geometry is updated instantly

What This Script Actually Solves

Anyone who has run CHAMFER manually on a 200-vertex profile knows the problem:

  • Missed corners
  • Inconsistent distances
  • Time wasted on repetitive picks

CHMALL removes all of that.

You define once → apply everywhere.


Where It Fits in Real Workflows

Mechanical Design

  • Edge preparation for milled parts
  • Consistent chamfering before toolpath export
  • Clean geometry for CAM software

Architecture

  • Chamfered outlines for floor plans
  • Clean corner transitions in detail drawings

CNC / Fabrication

  • Pre-processing profiles for laser / plasma / router
  • Ensures uniform edge offsets

Why Use an AutoLISP Routine Instead of Native Tools

AutoCAD already has CHAMFER, but it lacks a direct “apply to all vertices with one input” workflow unless you manually set it up every time.

This routine addresses common production issues:

  • Batch chamfer AutoCAD workflows without repetitive input
  • AutoCAD lisp polyline chamfer all corners in one step
  • Automate repetitive CAD tasks with predictable output

What you gain:

  • One input → full polyline processed
  • Reduced clicks-per-task
  • Consistent geometry
  • Lower risk of omissions

That last point matters. Missing one corner in a fabrication drawing can cost real money.


Performance and Compatibility

  • Works with:
    • LWPOLYLINE
    • POLYLINE
  • No external libraries
  • Runs on most AutoCAD versions supporting AutoLISP

Reference:


Technical Behavior (What Happens Under the Hood)

  • Reads current CHAMFERA
  • Prompts for new value (or keeps default)
  • Sets:
    • CHAMFERA
    • CHAMFERB
  • Validates entity type
  • Executes native chamfer with polyline option

This uses AutoCAD’s internal geometry engine. No reconstruction, no approximation.


Best Practices

  • Work on clean, closed polylines when possible
  • Avoid:
    • overlapping segments
    • zero-length edges
  • If needed, run:
    • OVERKILL
    • PEDIT → Join

Reference:


Common Pitfalls

Chamfer Doesn’t Apply

  • Object is not a polyline Fix:
PEDIT → Convert → Join

Chamfer Skips Certain Corners

If the chamfer distance is larger than half the length of a segment, AutoCAD will skip that specific corner.

This is a native limitation of the CHAMFER command, not the script.

Fix:

  • Reduce the chamfer distance
  • Or adjust the geometry

Unexpected Distances

  • Units mismatch or incorrect CHAMFERA value Check the prompt before confirming

Script Appears to Do Nothing

  • Likely invalid selection The routine only accepts polylines by design

Extending the Routine (Advanced Use)

If you want to push this further:

  • Add Fillet mode toggle
  • Support 3D polylines
  • Allow per-vertex chamfer values
  • Integrate into a batch processing workflow

This routine is a solid base for deeper automation.


FAQ

What types of objects are supported?

LWPolyline and Polyline only. Lines and arcs must be converted using PEDIT.


Can I apply different chamfer values per corner?

No. This routine is built for uniform chamfering.


Does it modify my system settings permanently?

It sets CHAMFERA and CHAMFERB during execution and does not restore their previous values. This is often intentional, since users typically continue working with the same chamfer distance afterward.


Is it safe for production drawings?

Yes. It relies entirely on AutoCAD’s native CHAMFER command.


Can this be used in batch scripts?

Yes. It can be integrated into larger AutoLISP routines for automated processing.


Does it work on 3D polylines?

No. It targets 2D polylines only.


Why not just use CHAMFER manually?

Manual workflows don’t scale. This removes repetitive input and reduces error risk on complex geometry.