PDA

View Full Version : Hatch to back



cadconcepts
2021-05-26, 08:03 PM
Hi
I have a lisp routine that I want to modify so that it only runs only if it finds objects in the current environment - modelspace or paperspace.


(defun c:HAT2BACK(/ sset)
(if (setq sset (ssget "_x" (list (cons 0 "HATCH"))))
(progn
(command ".draworder" sset "" "back")
(prompt "\nAll hatches successfully sent to the back.")
)
)
(princ)
)

Thanks
Manuel

Opie
2021-05-26, 08:18 PM
Does the HATCHTOBACK command not accomplish what you are attempting?

Otherwise, you would need to add to your filter for the selection set to include the current space. This would be a group code of 410, which includes the current value of the CTAB variable.

Tom Beauford
2021-05-27, 12:27 PM
As I recall the earliest version of HATCHTOBACK command only worked for the current session though it's worked permanently for me for many years.
Try this:

(defun c:HAT2BACK(/ cspace sset)
(if (= 1(getvar 'cvport)
(setq cspace (67 . 1)(67 . 0))
)
(if (setq sset (ssget "_x" (list cspace (cons 0 "HATCH"))))
(progn
(command ".draworder" sset "" "back")
(prompt "\nAll hatches successfully sent to the back.")
)
)
(princ)
)

cadconcepts
2021-05-28, 01:49 PM
Tom
Thank you very much for the help. Much appreciated.
Manuel