Lisp AutoCAD – Associative Hatch

By | May 4, 2023

The topic today: Lisp AutoCAD – Associative Hatch or Merge Hatch

Shortcut command: MH

Step to step as follow:

  1. Load Lisp into AutoCAD
  2. Type MH and press Enter
  3. Select Hatch
  4. Press Enter

Code Lisp:

(defun c:mh (/ ss entht sl i dt dtht)
(princ “\nMerge Hatch”)
ss (ssget ‘((0 . “HATCH”)))
sl (if ss
(sslength ss)
i 0
l 0
(repeat sl
entht (ssname ss i)
dtht (getbdata entht)
dt (append dt dtht)
l (+ l (cdr (assoc 91 (entget entht))))
i (1+ i)
(setq ent (ssname ss 0)
ss (ssdel ent ss)
tt (entget ent)
duoi (member (assoc 75 tt) tt)
dau (reverse (member (assoc 91 tt) (reverse tt)))
tt (append dau dt duoi)
tt (subst (cons 91 l) (assoc 91 tt) tt)
(entmod tt)
(command “.erase” ss “”)
(defun getbdata (ent)
(setq tt (entget ent)
tt (cdr (member (assoc 75 tt) (reverse tt)))
tt (cdr (member (assoc 91 tt) (reverse tt)))
(princ “\nMerge Hatch is loaded, please type MH to start!”)

Download Lisp here: Link 1, Link 2

Thanks for visiting and reading Blog!