Community
Greetings!
I am quite new to coding, treat it as such.
I would like to delete all the solid hatch from an arhitect drawing, except the elevation symbol's. I made a solution, but its quite convoluted. It works for my tailored problem, but with real drawings, not so much.
Common errors are:
- doesnt always puts in layers, or finds them when it is needed
- stops after the bursts
- runs in a loop have to cancel it
Can it work, or is there an easy solution? Any suggestion will do fine.
Thank you in advance!
AutoCAD 2016, Windows 10 pro
(defun c:kota ( / a b1 b2 sset i ent obj obj2 b c) (command "_.-layer" "_Thaw" "*" "_ON" "*" "_UNLOCK" "*" "") ;unlocks all layers (setq a 0) ;eliminates all blocks (while (and (setq b1 (ssget "_X" '((0 . "Insert")))) (<= a 6) ) (sssetfirst nil b1) (c:burst) (if (setq b2 (ssget "_X" '((0 . "Insert")))) (if (= (sslength b1) (sslength b2)) (setq a (+ a 1)); then (setq a 0); else ) ) ) (layerstate-import "P:\\Adatok2\\ANG\\Tudástár\\base.las") ;brings in desired layers (layerstate-restore "base" viewport 1) (layerstate-delete "base") (setq sset (ssget "_X" '((0 . "HATCH") (2 . "SOLID"))) i 0) ;filters elevation symbol hatches (repeat (sslength sset) (setq ent (ssname sset i)) (setq obj (entget ent)) (if (/= 42 (car (cadr (member (assoc 10 (member (assoc 2 obj) obj)) obj))) ) (if (= 75 ;arbitrary length (abs (- (cadr (car (member (assoc 10 (member (assoc 2 obj) obj)) obj))) (cadr (cadr (member (assoc 10 (member (assoc 2 obj) obj)) obj))) ) ) ) (progn (command "setbylayer" "al" "" "n" "y") (setq obj2 (reverse obj)) (setq a (cdr (car (member (assoc 10 obj2) obj2)))) ;selects and moves hatch to desired layer (setq b (cdr (caddr (member (assoc 10 obj2) obj2)))) (setq c (ssget "F" (list a b) '((0 . "HATCH")))) (command "change" c "" "p" "la" "_E0_epitesz" "") ) ) ) (setq i (1+ i)) ) (setq i nil) (if (setq a (ssget "_X" '((0 . "HATCH")(2 . "SOLID") (-4 . "<NOT") (8 . "_E0_epitesz") (-4 . "NOT>")))) ;deletes every other solid hatch (repeat (setq i (sslength a)) (entdel (ssname a (setq i (1- i))))) ) (alert "Kész") ;ready )
A couple of points: