fixed sephatch if no hatch in the file

This commit is contained in:
2019-12-09 02:00:33 +01:00
parent 7371c969cf
commit 5643168f2a

View File

@@ -75,23 +75,27 @@
(defun sephatch (/ ss i il imax currElem layerName newLayerName layerSettings newLayerSettings newLayer newElem) (defun sephatch (/ ss i il imax currElem layerName newLayerName layerSettings newLayerSettings newLayer newElem)
(graphscr) (graphscr)
(setq ss (ssget "_A" '((0 . "HATCH")))) (setq ss (ssget "_A" '((0 . "HATCH"))))
(setq il (sslength ss));length of selection (if ss
(setq i 0);counter to zero (progn
(setq imax 1);while variable (setq il (sslength ss));length of selection
(while imax (setq i 0);counter to zero
(setq currElem (entget (ssname ss i) )) (setq imax 1);while variable
(setq layerName (cdr (assoc 8 currElem))) (while imax
(setq newLayerName (strcat layerName "-hatch")) (setq currElem (entget (ssname ss i) ))
(command "._-layer" "_M" newLayerName "") (setq layerName (cdr (assoc 8 currElem)))
(setq layerSettings (entget (tblobjname "LAYER" layerName))) (setq newLayerName (strcat layerName "-hatch"))
(setq newLayerSettings (entget (tblobjname "LAYER" newLayerName))) (command "._-layer" "_M" newLayerName "")
(setq newLayer (subst (cons 62 (cdr (assoc 62 layerSettings))) (assoc 62 newLayerSettings) newLayerSettings)) (setq layerSettings (entget (tblobjname "LAYER" layerName)))
(setq newLayer (subst (cons 70 (cdr (assoc 70 layerSettings))) (assoc 70 newLayer) newLayer)) (setq newLayerSettings (entget (tblobjname "LAYER" newLayerName)))
(entmod newLayer) (setq newLayer (subst (cons 62 (cdr (assoc 62 layerSettings))) (assoc 62 newLayerSettings) newLayerSettings))
(setq newElem(subst (cons 8 newLayerName) (assoc 8 currElem) currElem)) (setq newLayer (subst (cons 70 (cdr (assoc 70 layerSettings))) (assoc 70 newLayer) newLayer))
(entmod newElem) (entmod newLayer)
(setq i (1+ i));increments i (setq newElem(subst (cons 8 newLayerName) (assoc 8 currElem) currElem))
(if (= i il) (setq imax nil));finish function if i equals il (entmod newElem)
(setq i (1+ i));increments i
(if (= i il) (setq imax nil));finish function if i equals il
)
)
) )
(princ) (princ)
) )