(defun C:HHB (/ hatch pieces); = Hatch with Hatch Boundaries
(setq hatch (car (entsel "\nSelect Hatch to use as Hatch bounaries: ")))
(command
"_.copy" hatch "" "0,0" "@"
"_.explode" "_last"
)
(setq pieces (ssget "_P"))
(initdia)
(command-s "_.hatch"); allow completion of command, then:
(command "_.erase" pieces "")
)
How can I modify the code so that I can select multiple hatches, apply the EXPLODE command to them to add a new hatch so that its islands are elements of those multiple hatches?
Sample of looping through a selection set. Untested., but may get you a little further.
(setq hatches (ssget "X" (list (cons 2 "HATCH"))))
; Returns something like: <Selection set: 3ad>
;
(sslength hatches)
; returns 3 for 3 hatches on this drawing
; and to loop through those hatches..
(if hatches
(progn
(setq c 0); first one in selection set
(repeat (sslength hatches)
(setq hatch (ssname hatches C)); single hatch from selection set
(command "_.copy" hatch "" "0,0" "@")
(command "_.explode" hatch)
(setq pieces (ssget "_P"))
(initdia)
(command-s "_.hatch"); allow completion of command, then:
(command "_.erase" pieces "")
(setq C (+ C 1)); increment index to selection set
); repeat
); progn
); if
ECCAD