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

Toggle by macro

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Shay.Gaghe
978 Views, 3 Replies

Toggle by macro

Hi

Can I set a toggle in a macro? For example, in the Toggle Coords command i see in the macro

'_.coords $M=$(if,$(and,$(getvar,coords),2),0,$(+,$(getvar,coords),1))

 

i belive its a toggle condition.

 

can someone translate it so i can understand the logic?

 

Thanks

Shay

Using Autocad 2018, Autocad Architecture.
Please accept as solution if i solved your problem
3 REPLIES 3
Message 2 of 4
Moshe-A
in reply to: Shay.Gaghe

@Shay.Gaghe  hi,

 

it's a diesel macro that toggle from 0 to 2. the diesel AND function is a bitwise logical AND of the integers. only when all supply arguments are 2, the function return 2. so when COORDS is 2 the macro set COORDS to 0 otherwise it add 1 to current COORDS value 😀

 

Moshe

 

 

 

Message 3 of 4
Kent1Cooper
in reply to: Shay.Gaghe

That one is actually a cycling  routine, not strictly a toggle [which, in my mind anyway, switches between two  values, such as 0 and 1 for System Variables that have only those two -- on/off situations].  If the value is 2 it sets it to 0; if it's 0, it sets it to 1, if it's 1, it sets it to 2.  Operationally, if it's 2, it sets it to 0, otherwise it sets it to one more than its current value.

 

Another way to do that is to use a (rem) [remainder] function -- here in AutoLisp format [the Diesel functions reference doesn't list an equivalent]:

(setvar 'coords (rem (1+ (getvar 'coords)) 3))

Kent Cooper, AIA
Message 4 of 4
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

.... here in AutoLisp format [the Diesel functions reference doesn't list an equivalent]....


... but some AutoLisp expressions can  be used in Tool Palette buttons, including this one -- it doesn't need to be Diesel language to work in a macro.

Kent Cooper, AIA

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report