AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Would you like to switch ON or OFF a list of Layers?
Then look no further :

;CODING STARTS HERE
;Switch OFF a list of Layers
(defun mlayoff ( LLST / BOB RT)

(foreach L LLST
(setq BOB (entget(tblobjname "layer" L)))
(setq rt (- (cdr(assoc 62 BOB))))
(setq BOB
(subst (cons 62 rt)
(assoc 62 BOB)
BOB)
)
(entmod BOB)
)
(princ)
)

;--------------------------------------

;Switch ON a list of Layers
(defun mlayon ( LLST / BOB RT)
(foreach L LLST
(setq BOB (entget(tblobjname "layer" L)))

;reset next line
(setq rt (abs (cdr(assoc 62 BOB))))

(setq BOB
(subst (cons 62 rt)
(assoc 62 BOB)
BOB)
)
(entmod BOB)
)
(princ)
)
(princ)

;---------------------

Usage :

(setq a '("2" "3"))

(mlayoff a)

Switches OFF Layers "2" and "3"

(mlayon a)

Switches ON Layers "2" and "3"
;CODING ENDS HERE

The AutoLisp/Visual Lisp/VBA Resource Website

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website