Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macros & Diesel expressions in AutoCAD 2

Status
Not open for further replies.

cmberry20

Automotive
Dec 13, 2002
8
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).
 
Replies continue below

Recommended for you

Hi cmberry20,
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
 
yes please could you please post the LISP code. We used AutoCAD 2002 at work (as well as LT on other terminals).

thankyou
 
Hi Again,

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
 
Brilliant, worked great. Thankyou for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor