(vl-load-com)

(defun C:SetByLayer ( / elementy ileelementow elem_def i)

(setq elementy(vl-catch-all-apply 'ssget (list )))
(if (not(vl-catch-all-error-p elementy))
(progn
(if elementy (progn
(setq ileelementow(sslength elementy))
(setq i 0 )
(repeat ileelementow
(setq elem_def(entget(ssname elementy i)) )

(if (cdr (assoc 62 elem_def)) ; przypisanie koloru
(setq elem_def(subst (cons 62 256 ) (assoc 62 elem_def) elem_def)) ; stała 256 jest przypisana kolorowi ByLayer
(setq elem_def (append elem_def (list (cons 62 256 ))))
)
(if (cdr (assoc 6 elem_def)) ; przypisanie typu linii
(setq elem_def(subst (cons 6 "ByLayer" ) (assoc 6 elem_def) elem_def))
(setq elem_def (append elem_def (list (cons 6 "ByLayer" ))))
)
(if (cdr (assoc 370 elem_def)) ; przypisanie szerokości linii
(setq elem_def(subst (cons 370 -1 ) (assoc 370 elem_def) elem_def)) ; stała -1 to ByLayer
(setq elem_def (append elem_def (list (cons 370 -1 ))))
)
(entmod elem_def)
(setq i (1+ i) )
)
))
)
)

(print)
)



(defun C:SetByBlock ( / elementy ileelementow i elem_def )

(setq elementy(vl-catch-all-apply 'ssget (list )))
(if (not(vl-catch-all-error-p elementy))
(progn
(if elementy (progn
(setq ileelementow(sslength elementy))
(setq i 0 )
(repeat ileelementow
(setq elem_def(entget(ssname elementy i)) )
(if (cdr (assoc 62 elem_def)) ;
(setq elem_def(subst (cons 62 0 ) (assoc 62 elem_def) elem_def)) ; 0 to stała dla koloru ByBlock
(setq elem_def (append elem_def (list (cons 62 0 ))))
)
(if (cdr (assoc 6 elem_def))
(setq elem_def(subst (cons 6 "ByBlock" ) (assoc 6 elem_def) elem_def))
(setq elem_def (append elem_def (list (cons 6 "ByBlock" ))))
)
(if (cdr (assoc 370 elem_def))
(setq elem_def(subst (cons 370 -2 ) (assoc 370 elem_def) elem_def)) ; -2 to stała dla szerokości linii ByBlock
(setq elem_def (append elem_def (list (cons 370 -2 ))))
)

(entmod elem_def)
(setq i (1+ i) )
)
))
)
)


)

Wykonanie w ZWCAD 2015+LISP SetBy 2015

Wykonanie w ZWCAD ClassicLISP SetBy Classic