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
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by Moshe-A. Go to Solution.
@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
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))
@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.
Can't find what you're looking for? Ask the community or share your knowledge.