Macros & Diesel expressions in AutoCAD
Macros & Diesel expressions in AutoCAD
(OP)
In AutoCAD (2000,2002 & LT) there are switches that turn on & off functions. Example if you go to Tools, Drafting Settings, Snap & Grid tab, there is an option to turn on isometric snap or rectangular snap. Now a short cut to do this is to type in ‘SNAPSTYL’ in the command prompt this gives you an option of 1 or 0 (on or off) that toggles the snap. If you want to create an icon to do this a macro is needed which is ‘^C^C_snapstyl 0 ’ or ‘^C^C_snapstyl 1 ’ However you need an icon to switch to iso view and another to switch to rectangular view (one with 1 & one with 0).
What I want to know is it possible to create a DIESEL expression in the macro that toggles the values of 1 and 0 without the need of two icons (just having the one).
What I want to know is it possible to create a DIESEL expression in the macro that toggles the values of 1 and 0 without the need of two icons (just having the one).





RE: Macros & Diesel expressions in AutoCAD
This sounds like a perfect example of the kinds of things that Autolisp is good at. You can write a simple LISP program that checks the setting and then sets it to the opposite value. Then you can link the LISP program to your "toggle" button and it will work as you want. The only catch is that LT does not recognize LISP.
Let me know if you want the LISP code and I'll send it to you.
Hope this helps,
Paul
RE: Macros & Diesel expressions in AutoCAD
thankyou
RE: Macros & Diesel expressions in AutoCAD
As requested, here is the code:
(defun C:isosnap ()
(setq CISO (getvar "SNAPSTYL"))
(if (= CISO 0)
(setvar "SNAPSTYL" 1)
(setvar "SNAPSTYL" 0)
);ends if
);ends defun
Save this into a Notepad file and "SAVEAS" with a name of "ISOSNAP.LSP".
Next, create the icon that you want and in the command execution section make sure that it reads:
^C^Cisosnap
Also, make sure that you APPLOAD the LISP program before you try to use it. Remember, Autocad LT won't be able to use this program.
Hope this helps,
Paul
RE: Macros & Diesel expressions in AutoCAD