Mirkin Posted February 26, 2015 Share Posted February 26, 2015 Hi all. I've written my first two macros. This one ^C^Cgrid on;;^C^Csnap on;;^C^Ccursorsize 100 turns the grid and snap on and expands the cursor. This one ^C^Cgrid off;;^C^Csnap off;;^C^Ccursorsize 5 does the opposite. I'm wondering if there is a way to turn object snap on and off within these macros as well. This would be a great help but I can't seem to find a command to do it. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 26, 2015 Share Posted February 26, 2015 You are running full AutoCAD so why not use lisp? Re: OSnaps. Are you turning ALL osnaps on or just a select few? If it is a select few which ones would they be? Quote Link to comment Share on other sites More sharing options...
Mirkin Posted February 26, 2015 Author Share Posted February 26, 2015 Hi there. Lisp is a completely foreign thing to me right now and I don't really have bundles of time to learn about it. As for the snaps, yes I want to turn them all on and off. Thanks Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 26, 2015 Share Posted February 26, 2015 (edited) A single lisp routine that would give the user the ability to enable, disable or change all/some of those settings using just two commands would be very simple and straight forward. Are you sure you want all the osnaps enabled if you are using grid? Where/how will you be controlling your settings for grid and snap spacing? Edited February 26, 2015 by ReMark Quote Link to comment Share on other sites More sharing options...
Mirkin Posted February 26, 2015 Author Share Posted February 26, 2015 If you say its easy maybe I'll have a try. What would the Lisp look like and how would I make it into a command that I could assign to a short cut key? You have to explain like I know nothing about it, because I don't lol. Remember I just wrote two macros and it took me a while. Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 26, 2015 Share Posted February 26, 2015 OK...think I got it now. Here is a rather crude lisp routine that will enable or disable the settings as you choose. Use the APPLOAD command to load the program. The two commands for enabling or disabling the settings are DSE and DSD (Drawing Settings Enabled / Drawing Settings Disabled). I'm sure it could be more streamlined but I did this for demonstration purposes only. Test5.lsp Quote Link to comment Share on other sites More sharing options...
zaphod Posted February 26, 2015 Share Posted February 26, 2015 NON a space is needed in front of NON, which will turn Osnap off temporairly Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 26, 2015 Share Posted February 26, 2015 Are you talking to me? The OP said he wanted ALL osnaps on. So I assume the opposite of that is ALL osnaps off. He did not use or mention the word "temporarily". Quote Link to comment Share on other sites More sharing options...
rkent Posted February 26, 2015 Share Posted February 26, 2015 First with your osnaps set the way you usually like them type osmode. Lets say it is 32. Your macro would be ^C^C_osmode;32; turns osnap on ^C^C_osmode;0; turns osnap off I didn't test it but that is close anyway. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 27, 2015 Share Posted February 27, 2015 Like Rkent just play with your osnap settings then type osmode the number that appears is important and you can use it either macro toolbar or lisp (defun C:15 ()(setvar "osmode" 15359)) ; sets all snaps on (defun C:00 ()(setvar "osmode" 0)) ; sets all snaps off (defun C:39 ()(setvar "osmode" 47)) (defun C:99 ()(setvar "osmode" 99)) (defun C:8 ()(setvar "osmode" ) (defun C:59 ()(setvar "osmode" 15359)) (defun C:9 ()(setvar "osmode" 9)) Quote Link to comment Share on other sites More sharing options...
Mirkin Posted February 27, 2015 Author Share Posted February 27, 2015 (edited) Cheers for all the advice. I think I'll use osmode in my macro for now. I have a few more questions. 1. Is there a way to switch between osnap and gridsnap while a command is active (move for example) 2. If I load the lisp routine into autocad using appload is it there forever or do I have to load it on each start? Thanks again for the help. Edited February 27, 2015 by Mirkin Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 27, 2015 Share Posted February 27, 2015 Re: APPLOAD. The code is loaded into the current drawing session. A second method would be to load the code every time a new drawing is opened via acaddoc.lsp. A third method involves the use of the Startup Suite to load your custom programs. Quote Link to comment Share on other sites More sharing options...
lrm Posted February 27, 2015 Share Posted February 27, 2015 As BIGAL said, the command: (setvar "osmode" 0) will turn off osnap To turn osnap on just replace the 0 with a number that is the sum of the osnap modes you want to set where End = 1, Midpoint = 2, Center = 4, Node = 8, etc. (check the order in the osnap setting dialog box and double the number for the next mode). So, if you want to turn on osnap End, Midpoint, and Center it would be 1+2+4 = 7 (setvar "osmode" 7) However, if you just want End and Center the command would be 1+4 = 5 (setvar "osmode" 5) Quote Link to comment Share on other sites More sharing options...
Mirkin Posted February 27, 2015 Author Share Posted February 27, 2015 I'm totally understanding how this works now. Can anybody advise if its possible to turn the osnap on and off from a macro while while a command is active. Cheers Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 27, 2015 Share Posted February 27, 2015 Can anybody advise if its possible to turn the osnap on and off from a macro while while a command is active. Cheers That's why God invented the F3 key. Enable/Disable OSnaps. Quote Link to comment Share on other sites More sharing options...
Mirkin Posted February 27, 2015 Author Share Posted February 27, 2015 Haha Yes I know but I'm being super lazy here. I wanted to write a macro that turned os off and gs on, in one key press, and vice-versa. Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 27, 2015 Share Posted February 27, 2015 Oh, you want to press only ONE key to enable or disable OSnaps. OK....I got it. F3 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 27, 2015 Share Posted February 27, 2015 Check out F8 also and F6 & F? Etc If you want transparent changes and do not want to press F3 then you will have to write a lisp that changes the snaps grid in between doing something. Quote Link to comment Share on other sites More sharing options...
YZ Posted March 3, 2015 Share Posted March 3, 2015 Yes, you can have a macro that will alter the osnap and gridsnap settings while you have another command active. If you start the command with an apostrophe it will run the command transparently, without cancelling the current active command, so you can continue, but with the settings now changed to how you want them. It would look something like: 'OSmode;0;Snap;On; You can also, if this is of interest, have your macro store your current settings and then restore them at the end of the macro. So while you are in that macro command the settings will be exactly as you want them for that task. Then once the macro has finished it can restore the setting so you can continue with your previous settings. Or you can return them to a standard normal which will be as you would want them say 80% of the time anyway. Quote Link to comment Share on other sites More sharing options...
YZ Posted March 9, 2015 Share Posted March 9, 2015 I forgot to mention that in order to achieve the above you need to ignore the usual convention of opening a macro with ^C^C. It literally starts with the apostrophe only. 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.