Kelly-cruise Posted April 26, 2012 Posted April 26, 2012 Hi I am just starting with programming, and am having difficulty creating a program that can be used with a button to toggle multiple layers on or off. Any suggestions as to how to start? Michael. Quote
pBe Posted April 26, 2012 Posted April 26, 2012 Why not Layer States Manager? LAYERSTATE---> Restore Quote
MSasu Posted April 26, 2012 Posted April 26, 2012 You can achieve the same result by using layer states. But if want to write an AutoLISP routine for this, then may find solutions in one of those previous discussions: http://www.cadtutor.net/forum/showthread.php?8718 http://www.cadtutor.net/forum/showthread.php?23568 Quote
Kelly-cruise Posted April 26, 2012 Author Posted April 26, 2012 Thanks for your responses, I will look at the layer state manager. I was hoping for a button so it could be user friendly to those people use to using buttons and not so comfortable with change, and visibility states. Cheers Michael. Quote
MSasu Posted April 26, 2012 Posted April 26, 2012 You can create a button with this macro: (command "_LAYER" "_A" "_R" [color=blue][i]LayerStateName[/i][/color] "" "") Quote
VVA Posted April 26, 2012 Posted April 26, 2012 Try to use (defun layer-filters-status-change (lstnames / vla:lrs vla:xdic vla:dic vla:spsc name datatype datavalue onoff sps) (setq lstnames (list lstnames)) ;|======================================================================================= * layer-filters-status-change * http://www.caduser.ru/forum/index.php?PAGE_NAME=message&FID=34&TID=20414&MID=114022#message114022 * Arguments [Type]: lstnames = String - the name of the group filter * Return [Type]: nil * * If at least one layer group filter is turned off, all the layers of the filter are also included * Use: ^C^C(if (not layer-filters-status-change)(load "layer-filters-status-change"))(layer-filters-status-change "AT") * Create command (on\off group filters AT): (defun C:AT ()(layer-filters-status-change "AT")) * Macros: * 'AT; =======================================================================================|; (defun massoc (key alist / x nlist) (foreach x alist (if (eq key (car x))(setq nlist (cons (cdr x) nlist)))) (reverse nlist)) (vl-load-com) (setq vla:lrs (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))) (if (= (vla-get-hasextensiondictionary vla:lrs) :vlax-true) (progn (setq lstnames (mapcar 'strcase lstnames)) (setq vla:xdic (vla-getextensiondictionary vla:lrs)) (setq vla:dic nil) (if (progn (vlax-for item vla:xdic (if (= (vla-get-name item) "ACLYDICTIONARY") (setq vla:dic item) ) ;_ if ) ;_ vlax-for vla:dic ) ;_ progn (progn (vlax-for vla:spsc vla:dic (if (progn (setq name (vla-get-name vla:spsc)) (vla-getxrecorddata vla:spsc 'datatype 'datavalue) (member (strcase (vlax-variant-value (vlax-safearray-get-element datavalue (vl-position 300 (vlax-safearray->list datatype)) ) ;_ vlax-safearray-get-element ) ;_ vlax-variant-value ) ;_ strcase lstnames ) ;_ member ) ;_ progn (progn (setq sps (entget(vlax-vla-object->ename vla:spsc)) sps (massoc 330 (member (assoc 300 sps) sps)) sps (vl-remove-if 'null (mapcar 'entget sps)) sps (mapcar '(lambda (x)(cons (cdr(assoc 2 x))(cdr(assoc 62 x)))) sps)) (if (vl-member-if '(lambda (x)(minusp (cdr x))) sps) (setq onoff :vlax-true) (setq onoff :vlax-false) ) (setq sps (mapcar '(lambda (x)(vla-Item vla:lrs x)) (mapcar 'car sps))) (mapcar '(lambda (x)(vla-put-layeron x onoff)) sps) ) ;_ progn ) ;_ if ) ;_ vlax-for (vlax-release-object vla:dic) ) ) ;_ if (vlax-release-object vla:xdic) ) ;_ progn ) ;_ if (vlax-release-object vla:lrs) (princ) ) How to work 1. Create Layer Group filter (for example with name AT) 2. Create command AT (defun C:AT ()(layer-filters-status-change "AT")) 3. Type in command line AT or 'AT Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.