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