worked on layerFromColor
This commit is contained in:
@@ -1,20 +1,31 @@
|
|||||||
|
;; layerFromColor.lsp
|
||||||
|
;;
|
||||||
|
;; Create separate layers for each selected objects different colors.
|
||||||
|
;;
|
||||||
|
;; Created by Peter Gyetvai
|
||||||
|
;; gyetpet@mailbox.org
|
||||||
|
|
||||||
(defun C:LFC (/ i imax il ss currElem color colorNum allColors newLayer currLayer newElem)
|
(defun C:LFC (/ i imax il ss currElem color colorNum allColors newLayer currLayer newElem)
|
||||||
(graphscr)
|
(graphscr)
|
||||||
|
|
||||||
;variables:
|
; ---------------------------------- prompt ---------------------------------- ;
|
||||||
(setq i 0);counter to zero
|
|
||||||
(setq imax 1);while variable
|
|
||||||
|
|
||||||
(prompt "\nselect entities to change layer (all): ")
|
(prompt "\nselect entities to change layer (all): ")
|
||||||
(setq ss (ssget));asks for selection
|
(setq ss (ssget));asks for selection
|
||||||
(setq il (sslength ss));length of selection
|
(setq il (sslength ss));length of selection
|
||||||
(setq allColors nil)
|
(setq allColors nil)
|
||||||
|
|
||||||
|
; -------------------------- get colors from objects ------------------------- ;
|
||||||
|
|
||||||
|
(setq i 0);counter to zero
|
||||||
|
(setq imax 1);while variable
|
||||||
|
|
||||||
(while imax
|
(while imax
|
||||||
(print i)
|
;(print i)
|
||||||
(setq currElem (entget (ssname ss i) ))
|
(setq currElem (entget (ssname ss i) ))
|
||||||
(setq color (assoc 62 currElem))
|
(setq color (assoc 62 currElem))
|
||||||
(setq colorNum (cdr color))
|
(setq colorNum (cdr color))
|
||||||
(print colorNum)
|
;(print colorNum)
|
||||||
|
|
||||||
(if (and (not (= colorNum 0)) colorNum)
|
(if (and (not (= colorNum 0)) colorNum)
|
||||||
(progn
|
(progn
|
||||||
@@ -28,24 +39,36 @@
|
|||||||
(if (= i il) (setq imax nil));finish function if i equals il
|
(if (= i il) (setq imax nil));finish function if i equals il
|
||||||
)
|
)
|
||||||
|
|
||||||
|
; ----------------------------- create new layers ---------------------------- ;
|
||||||
|
|
||||||
(setq i 0);counter to zero
|
(setq i 0);counter to zero
|
||||||
(setq imax 1);while variable
|
(setq imax 1);while variable
|
||||||
|
|
||||||
(while imax
|
(while imax
|
||||||
(print i)
|
;(print i)
|
||||||
(setq color (nth i allColors))
|
(setq color (nth i allColors))
|
||||||
|
|
||||||
|
; --- create new layers --- ;
|
||||||
(command "._layer" "_M" color "")
|
(command "._layer" "_M" color "")
|
||||||
|
(command "._layer" "_C" color color "")
|
||||||
|
|
||||||
|
(print )
|
||||||
|
(princ "Created layer ")
|
||||||
|
(princ color)
|
||||||
|
(print )
|
||||||
|
|
||||||
;while specific:
|
;while specific:
|
||||||
(setq i (1+ i));increments i
|
(setq i (1+ i));increments i
|
||||||
(if (= i (length allColors)) (setq imax nil));finish function if i equals il
|
(if (= i (length allColors)) (setq imax nil));finish function if i equals il
|
||||||
)
|
)
|
||||||
|
|
||||||
|
; -------------------------------- set layers -------------------------------- ;
|
||||||
|
|
||||||
(setq i 0);counter to zero
|
(setq i 0);counter to zero
|
||||||
(setq imax 1);while variable
|
(setq imax 1);while variable
|
||||||
|
|
||||||
(while imax
|
(while imax
|
||||||
(print i)
|
;(print i)
|
||||||
(setq currElem (entget (ssname ss i) ))
|
(setq currElem (entget (ssname ss i) ))
|
||||||
(setq color (assoc 62 currElem))
|
(setq color (assoc 62 currElem))
|
||||||
(setq colorNum (cdr color))
|
(setq colorNum (cdr color))
|
||||||
@@ -56,7 +79,6 @@
|
|||||||
|
|
||||||
(setq currLayer (assoc 8 currElem))
|
(setq currLayer (assoc 8 currElem))
|
||||||
(setq newLayer (cons 8 (itoa colorNum)))
|
(setq newLayer (cons 8 (itoa colorNum)))
|
||||||
(print newLayer)
|
|
||||||
(setq newElem(subst newLayer currLayer currElem))
|
(setq newElem(subst newLayer currLayer currElem))
|
||||||
(entmod newElem)
|
(entmod newElem)
|
||||||
)
|
)
|
||||||
@@ -66,6 +88,13 @@
|
|||||||
(if (= i il) (setq imax nil));finish function if i equals il
|
(if (= i il) (setq imax nil));finish function if i equals il
|
||||||
)
|
)
|
||||||
|
|
||||||
|
; --------------------------- set color to bylayer --------------------------- ;
|
||||||
|
|
||||||
|
(print )
|
||||||
|
(command "_.change" ss "" "_P" "_C" "bylayer" "")
|
||||||
|
|
||||||
|
; ---------------------------------- finish ---------------------------------- ;
|
||||||
|
|
||||||
(terpri)
|
(terpri)
|
||||||
(setq ss nil)
|
(setq ss nil)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user