Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Call save and restore layer states with Macro or lisp??

12 REPLIES 12
Reply
Message 1 of 13
Anonymous
513 Views, 12 Replies

Call save and restore layer states with Macro or lisp??

I would like to setup two new toolbar buttons to call both the save and restore layer states dialogs without having to first go into the layer properties manager. Is it possible to do this with a macro or lisp?
12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: Anonymous

-LAYER command (note the dash), look at the command line prompts, follow the one(s) you need through the entire process, record what you did, write a simple toolbar button macro (explained in HELP). Post back if you need help finishing or writing a LISP version. -- Dean Saadallah Add-on products for LT http://www.pendean.com/lt --
Message 3 of 13
Anonymous
in reply to: Anonymous

Dean, thanks very much for the reply, it's nearly what i was looking for. I was hoping to call the dialog box so that I can click on the layer state to be restored rather than typing in the name. Do you know if this is possible?
Message 4 of 13
Anonymous
in reply to: Anonymous

(initdia)(command "layer") Don "buttonmonkey" wrote in message news:3529930.1079122129476.JavaMail.jive@jiveforum1.autodesk.com... > I would like to setup two new toolbar buttons to call both the save and restore layer states dialogs without having to first go into the layer properties manager. Is it possible to do this with a macro or lisp? --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.591 / Virus Database: 374 - Release Date: 2/17/2004
Message 5 of 13
Anonymous
in reply to: Anonymous

That's half way there, as it opens the layer properties manager dialog but it's still a second click to open either the save or restore states dialogs. I wanted to achieve this with a single click. It is possible?
Message 6 of 13
Anonymous
in reply to: Anonymous

Does anyone have any suggestions??
Message 7 of 13
Anonymous
in reply to: Anonymous

What version of Acad? -- Ken Alexander Acad2004 Windows2000 Prof. "We can't solve problems by using the same kind of thinking we used when we created them." --Albert Einstein "buttonmonkey" wrote in message news:4681914.1079196525473.JavaMail.jive@jiveforum1.autodesk.com... > Does anyone have any suggestions??
Message 8 of 13
Anonymous
in reply to: Anonymous

AutoCAD LT2002 (occasionally full version 2002) - I'd prefer a macro/diesel if it's possible but I can use Autolisp with LT as i'm forced to use a lisp enabler when all the full version licences are taken (which is often).
Message was edited by: buttonmonkey
Message 9 of 13
Anonymous
in reply to: Anonymous

I don't know anything about LT or 2002 but take a look at this and see if it can get you going. ;;;Restore Layer States 2004 ;;;Ken Alexander 3/13/04 ;;;Requires doslib2004 (defun C:re_lay_state (/ dos2004 data inf_obj state_names ans) (vl-load-com) (cond ((and (not (member "doslib2004.arx" (arx))) (setq dos2004 (findfile "doslib2004.arx")) (arxload dos2004) ) T ) ((member "doslib2004.arx" (arx)) T) (T (princ "\nDos_lib is not loaded. ") (exit) ) ) (or *app* (setq *app* (vlax-get-acad-object))) (or *actdoc* (setq *actdoc* (vla-get-activedocument *app*))) (setq lay_col (vla-get-layers *actdoc*) data (vla-get-database *actdoc*) inf_obj (vla-getinterfaceobject *app* "AutoCAD.AcadLayerStateManager.16") state_names (get_lay_states lay_col)) (if state_names (progn (setq ans (dos_listbox "Select Layer State" "Select a state" state_names ) ) (vla-setdatabase inf_obj data) (vla-restore inf_obj ans) (vla-update app) ) (princ "\nNo Layer States!: ") ) (princ) ) (defun get_lay_states (lay_col / ex_dict state_list) (if (= (vla-get-hasextensiondictionary lay_col) :vlax-true) (progn (setq ex_dict (vla-getextensiondictionary lay_col)) (vlax-for each ex_dict (if (= (vla-get-name each) "ACAD_LAYERSTATES") (vlax-for each_st each (setq state_list (cons (vla-get-name each_st) state_list)) ) )) ) ) (reverse state_list) ) -- Ken Alexander Acad2004 Windows2000 Prof. "We can't solve problems by using the same kind of thinking we used when we created them." --Albert Einstein "buttonmonkey" wrote in message news:27288692.1079200240878.JavaMail.jive@jiveforum1.autodesk.com... > AutoCAD LT2002 (occasionally full version 2002)
Message 10 of 13
Anonymous
in reply to: Anonymous

Sorry, use this sub instead of the other. (defun get_lay_states (lay_col / ex_dict states state_list) (if (= (vla-get-hasextensiondictionary lay_col) :vlax-true) (progn (setq ex_dict (vla-getextensiondictionary lay_col)) (vl-catch-all-apply 'vla-item (list ex_dict "ACAD_LAYERSTATES") ) (setq states (vl-catch-all-apply 'vla-item (list ex_dict "ACAD_LAYERSTATES") ) ) (if (not (vl-catch-all-error-p states)) (vlax-for each states (setq state_list (cons (vla-get-name each) state_list)) ) ) ) ) (reverse state_list) ) -- Ken Alexander Acad2004 Windows2000 Prof. "We can't solve problems by using the same kind of thinking we used when we created them." --Albert Einstein "Ken Alexander" wrote in message news:40534fe3_1@newsprd01... > > I don't know anything about LT or 2002 but take a look at this and > see if it can get you going. > > ;;;Restore Layer States 2004 > ;;;Ken Alexander 3/13/04 > ;;;Requires doslib2004 > (defun C:re_lay_state (/ dos2004 data inf_obj state_names ans) > (vl-load-com) > (cond > ((and > (not (member "doslib2004.arx" (arx))) > (setq dos2004 (findfile "doslib2004.arx")) > (arxload dos2004) > ) > T > ) > ((member "doslib2004.arx" (arx)) T) > (T > (princ "\nDos_lib is not loaded. ") > (exit) > ) > ) > (or *app* > (setq *app* (vlax-get-acad-object))) > (or *actdoc* > (setq *actdoc* (vla-get-activedocument *app*))) > (setq lay_col (vla-get-layers *actdoc*) > data (vla-get-database *actdoc*) > inf_obj (vla-getinterfaceobject > *app* > "AutoCAD.AcadLayerStateManager.16") > state_names (get_lay_states lay_col)) > (if state_names > (progn > (setq ans (dos_listbox > "Select Layer State" > "Select a state" > state_names > ) > ) > (vla-setdatabase inf_obj data) > (vla-restore inf_obj ans) > (vla-update app) > ) > (princ "\nNo Layer States!: ") > ) > (princ) > ) > > > > > (defun get_lay_states (lay_col / ex_dict state_list) > (if (= (vla-get-hasextensiondictionary lay_col) :vlax-true) > (progn > (setq ex_dict (vla-getextensiondictionary lay_col)) > (vlax-for each ex_dict > (if (= (vla-get-name each) "ACAD_LAYERSTATES") > (vlax-for each_st each > (setq state_list (cons (vla-get-name each_st) state_list)) > ) > )) > ) > ) > (reverse state_list) > ) > -- > Ken Alexander > Acad2004 > Windows2000 Prof. > > "We can't solve problems by using the same kind > of thinking we used when we created them." > --Albert Einstein > > "buttonmonkey" wrote in message > news:27288692.1079200240878.JavaMail.jive@jiveforum1.autodesk.com... > > AutoCAD LT2002 (occasionally full version 2002) > >
Message 11 of 13
Anonymous
in reply to: Anonymous

Dang, I'm really screwing it up. Left some junk in it. How about this one. (defun get_lay_states (lay_col / ex_dict states state_list) (if (= (vla-get-hasextensiondictionary lay_col) :vlax-true) (progn (setq ex_dict (vla-getextensiondictionary lay_col)) (setq states (vl-catch-all-apply 'vla-item (list ex_dict "ACAD_LAYERSTATES"))) (if (not (vl-catch-all-error-p states)) (vlax-for each states (setq state_list (cons (vla-get-name each) state_list)) ) ) ) ) (reverse state_list) ) -- Ken Alexander Acad2004 Windows2000 Prof. "We can't solve problems by using the same kind of thinking we used when we created them." --Albert Einstein "Ken Alexander" wrote in message news:40535235$1_2@newsprd01... > > Sorry, use this sub instead of the other. > > (defun get_lay_states (lay_col / ex_dict states state_list) > (if (= (vla-get-hasextensiondictionary lay_col) :vlax-true) > (progn > (setq ex_dict (vla-getextensiondictionary lay_col)) > (vl-catch-all-apply > 'vla-item > (list ex_dict "ACAD_LAYERSTATES") > ) > (setq states (vl-catch-all-apply > 'vla-item > (list ex_dict "ACAD_LAYERSTATES") > ) > ) > (if (not (vl-catch-all-error-p states)) > (vlax-for each states > (setq state_list (cons (vla-get-name each) state_list)) > ) > ) > ) > ) > (reverse state_list) > ) > > -- > Ken Alexander > Acad2004 > Windows2000 Prof. > > "We can't solve problems by using the same kind > of thinking we used when we created them." > --Albert Einstein > > "Ken Alexander" wrote in message > news:40534fe3_1@newsprd01... > > > > I don't know anything about LT or 2002 but take a look at this > and > > see if it can get you going. > > > > ;;;Restore Layer States 2004 > > ;;;Ken Alexander 3/13/04 > > ;;;Requires doslib2004 > > (defun C:re_lay_state (/ dos2004 data inf_obj state_names ans) > > (vl-load-com) > > (cond > > ((and > > (not (member "doslib2004.arx" (arx))) > > (setq dos2004 (findfile "doslib2004.arx")) > > (arxload dos2004) > > ) > > T > > ) > > ((member "doslib2004.arx" (arx)) T) > > (T > > (princ "\nDos_lib is not loaded. ") > > (exit) > > ) > > ) > > (or *app* > > (setq *app* (vlax-get-acad-object))) > > (or *actdoc* > > (setq *actdoc* (vla-get-activedocument *app*))) > > (setq lay_col (vla-get-layers *actdoc*) > > data (vla-get-database *actdoc*) > > inf_obj (vla-getinterfaceobject > > *app* > > "AutoCAD.AcadLayerStateManager.16") > > state_names (get_lay_states lay_col)) > > (if state_names > > (progn > > (setq ans (dos_listbox > > "Select Layer State" > > "Select a state" > > state_names > > ) > > ) > > (vla-setdatabase inf_obj data) > > (vla-restore inf_obj ans) > > (vla-update app) > > ) > > (princ "\nNo Layer States!: ") > > ) > > (princ) > > ) > > > > > > > > > > (defun get_lay_states (lay_col / ex_dict state_list) > > (if (= (vla-get-hasextensiondictionary lay_col) :vlax-true) > > (progn > > (setq ex_dict (vla-getextensiondictionary lay_col)) > > (vlax-for each ex_dict > > (if (= (vla-get-name each) "ACAD_LAYERSTATES") > > (vlax-for each_st each > > (setq state_list (cons (vla-get-name each_st) state_list)) > > ) > > )) > > ) > > ) > > (reverse state_list) > > ) > > -- > > Ken Alexander > > Acad2004 > > Windows2000 Prof. > > > > "We can't solve problems by using the same kind > > of thinking we used when we created them." > > --Albert Einstein > > > > "buttonmonkey" wrote in message > > > news:27288692.1079200240878.JavaMail.jive@jiveforum1.autodesk.com... > > > AutoCAD LT2002 (occasionally full version 2002) > > > > > >
Message 12 of 13
Anonymous
in reply to: Anonymous

AutoCAD 2002 LT doesn't support Lisp does it? Don "buttonmonkey" wrote in message news:27288692.1079200240878.JavaMail.jive@jiveforum1.autodesk.com... > AutoCAD LT2002 (occasionally full version 2002) --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.591 / Virus Database: 374 - Release Date: 2/17/2004
Message 13 of 13
Anonymous
in reply to: Anonymous

You can also look at my response to Rakesh Rao under Layer States. Don "Ken Alexander" wrote in message news:405352ee$1_1@newsprd01... > > Dang, I'm really screwing it up. Left some junk in it. How about > this one. > > (defun get_lay_states (lay_col / ex_dict states state_list) > (if (= (vla-get-hasextensiondictionary lay_col) :vlax-true) > (progn > (setq ex_dict (vla-getextensiondictionary lay_col)) > (setq states (vl-catch-all-apply > 'vla-item > (list ex_dict "ACAD_LAYERSTATES"))) > (if (not (vl-catch-all-error-p states)) > (vlax-for each states > (setq state_list (cons (vla-get-name each) state_list)) > ) > ) > ) > ) > (reverse state_list) > ) > > -- > Ken Alexander > Acad2004 > Windows2000 Prof. > > "We can't solve problems by using the same kind > of thinking we used when we created them." > --Albert Einstein > > "Ken Alexander" wrote in message > news:40535235$1_2@newsprd01... > > > > Sorry, use this sub instead of the other. > > > > (defun get_lay_states (lay_col / ex_dict states state_list) > > (if (= (vla-get-hasextensiondictionary lay_col) :vlax-true) > > (progn > > (setq ex_dict (vla-getextensiondictionary lay_col)) > > (vl-catch-all-apply > > 'vla-item > > (list ex_dict "ACAD_LAYERSTATES") > > ) > > (setq states (vl-catch-all-apply > > 'vla-item > > (list ex_dict "ACAD_LAYERSTATES") > > ) > > ) > > (if (not (vl-catch-all-error-p states)) > > (vlax-for each states > > (setq state_list (cons (vla-get-name each) state_list)) > > ) > > ) > > ) > > ) > > (reverse state_list) > > ) > > > > -- > > Ken Alexander > > Acad2004 > > Windows2000 Prof. > > > > "We can't solve problems by using the same kind > > of thinking we used when we created them." > > --Albert Einstein > > > > "Ken Alexander" wrote in message > > news:40534fe3_1@newsprd01... > > > > > > I don't know anything about LT or 2002 but take a look at > this > > and > > > see if it can get you going. > > > > > > ;;;Restore Layer States 2004 > > > ;;;Ken Alexander 3/13/04 > > > ;;;Requires doslib2004 > > > (defun C:re_lay_state (/ dos2004 data inf_obj state_names > ans) > > > (vl-load-com) > > > (cond > > > ((and > > > (not (member "doslib2004.arx" (arx))) > > > (setq dos2004 (findfile "doslib2004.arx")) > > > (arxload dos2004) > > > ) > > > T > > > ) > > > ((member "doslib2004.arx" (arx)) T) > > > (T > > > (princ "\nDos_lib is not loaded. ") > > > (exit) > > > ) > > > ) > > > (or *app* > > > (setq *app* (vlax-get-acad-object))) > > > (or *actdoc* > > > (setq *actdoc* (vla-get-activedocument *app*))) > > > (setq lay_col (vla-get-layers *actdoc*) > > > data (vla-get-database *actdoc*) > > > inf_obj (vla-getinterfaceobject > > > *app* > > > "AutoCAD.AcadLayerStateManager.16") > > > state_names (get_lay_states lay_col)) > > > (if state_names > > > (progn > > > (setq ans (dos_listbox > > > "Select Layer State" > > > "Select a state" > > > state_names > > > ) > > > ) > > > (vla-setdatabase inf_obj data) > > > (vla-restore inf_obj ans) > > > (vla-update app) > > > ) > > > (princ "\nNo Layer States!: ") > > > ) > > > (princ) > > > ) > > > > > > > > > > > > > > > (defun get_lay_states (lay_col / ex_dict state_list) > > > (if (= (vla-get-hasextensiondictionary lay_col) > :vlax-true) > > > (progn > > > (setq ex_dict (vla-getextensiondictionary lay_col)) > > > (vlax-for each ex_dict > > > (if (= (vla-get-name each) "ACAD_LAYERSTATES") > > > (vlax-for each_st each > > > (setq state_list (cons (vla-get-name each_st) > state_list)) > > > ) > > > )) > > > ) > > > ) > > > (reverse state_list) > > > ) > > > -- > > > Ken Alexander > > > Acad2004 > > > Windows2000 Prof. > > > > > > "We can't solve problems by using the same kind > > > of thinking we used when we created them." > > > --Albert Einstein > > > > > > "buttonmonkey" wrote in message > > > > > > news:27288692.1079200240878.JavaMail.jive@jiveforum1.autodesk.com... > > > > AutoCAD LT2002 (occasionally full version 2002) > > > > > > > > > > > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.591 / Virus Database: 374 - Release Date: 2/17/2004

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta