demes Posted March 6, 2013 Share Posted March 6, 2013 I was wondering if someone could help me out with this idea. I have for example 3 layers, layer '0', layer '1' and layer '2' I want to creat a simple command that changes the current layer I'm working in. For instance if I just type '2' that my current layer is automatically set to layer '2'. Since I'm always working on only 3 or 4 layers, this would make changing between them quite easy... I don't want one single command to automatically recognize the name of the layer, I would make 4 commands for the 4 different layers. ANY SUGGESTIONS? thanks! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted March 6, 2013 Share Posted March 6, 2013 (defun _SetCLayer (layerName) (if (tblsearch "layer" layerName) (setvar 'clayer layerName) (prompt (strcat "\n** Layer \"" layerName "\" not found ** ") ) ) (princ) ) (defun c:0 () (_SetCLayer "0")) (defun c:1 () (_SetCLayer "1")) (defun c:2 () (_SetCLayer "2")) (defun c:3 () (_SetCLayer "3")) Quote Link to comment Share on other sites More sharing options...
dbroada Posted March 6, 2013 Share Posted March 6, 2013 however, if you are really using AutoCAD LT 2012, lisp code may not work. Quote Link to comment Share on other sites More sharing options...
demes Posted March 6, 2013 Author Share Posted March 6, 2013 Hi BlackBox! thanks for you quick response... I've the feeling that your code is exactly what I need, but I'm completely new with autocad codes so I was wondering If you could tell me for 1 of the 4 examples how exactly I have to put it into my user interface... I tried some things but none of them seems to be able to recognise the command (I tried it for layer 0) Quote Link to comment Share on other sites More sharing options...
ReMark Posted March 6, 2013 Share Posted March 6, 2013 (edited) As Dave pointed out if you are using LT, lisp code will not run in it. You'll have to resort to using a macro. The command line version of the layer command (-Layer) has an option called Set. That's how you could do it. This macro would set layer 1 current. ^C^C-Layer;Set;1;; Macros can be assigned to buttons. If your profile is incorrect re "LT" could you please change it? Thanks. Edited March 6, 2013 by ReMark Quote Link to comment Share on other sites More sharing options...
demes Posted March 6, 2013 Author Share Posted March 6, 2013 thanks ReMark, is it possible to run the macro once it is installed from the command line, or can I only run it when I assign a button to it? Quote Link to comment Share on other sites More sharing options...
ReMark Posted March 6, 2013 Share Posted March 6, 2013 I'd assign it to a button and place the button on a custom toolbar. Have you thought of just using the Make Object's Layer Current button? Quote Link to comment Share on other sites More sharing options...
SLW210 Posted March 6, 2013 Share Posted March 6, 2013 Sounds like you need a programmable mouse and/or keyboard, if indeed you use LT. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted March 6, 2013 Share Posted March 6, 2013 Sorry demes, I rarely check what someone is using when they specifically ask for help with LISP, and I should have. As DBroada, and ReMark have made clear, you're relegated to using macros/scripts in LT, so for this situation, I'd follow ReMarks advise here: Have you thought of just using the Make Object's Layer Current button? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 7, 2013 Share Posted March 7, 2013 here is a toolbar for you but you need to make your own icons called 0lay etc ***MENUGROUP=layers ***TOOLBARS **Layers ID_ALAN [_Toolbar("Layers", _LEFT, _Show, 0,0, 1)] 0 lay[_Button("0lay","0lay.BMP","0lay.BMP")]^c^c^c(layer s "0") 1 lay[_Button("1lay","1lay.BMP","1lay.BMP")]^c^c^c(layer s "1") Quote Link to comment Share on other sites More sharing options...
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.