Jump to content

menu: toggling a variable showing current value


harinezumi

Recommended Posts

Hi, I have some variables wich I sometimes need to toggle, so I made my menu commands. I managed to create a command to show the current value and another to actually toggle it. Is there a way to merge the two? like showing the command "turn frameselction ON" (or OFF based on current value)?

Here are my commands:

toggle snap to hatch

command to show current value (Command Name line in the CUI)

~Current snap to hatch: $(index,$(getvar, osnaphatch),"off,on")

command to toggle (Command Macro line in the CUI)

'osnaphatch $M=$(xor,$(getvar, osnaphatch),1)

and similarly for "frameselection"

I hate the need to have two separate lines in the menu.

 

Thank you
 

Annotazione 2019-06-19 121228.jpg

Link to comment
Share on other sites

I think you will have to live with it. Adding the tilde to the command name disables it so it can't contain the toggle macro, and removing the tilde stops the label diesel from working and turns into text.

Link to comment
Share on other sites

Wouldn't you know it, post a negative answer then 2 minutes later you find the solution, try this in the command name section

$(index,$(getvar, osnaphatch),"Current snap to hatch: off,Current snap to hatch: on")

And place your other code in the macro section.

PS nice idea, I'll be adding a few of these myself

Edited by steven-g
  • Like 1
Link to comment
Share on other sites

A Display Name of 

$(if,$(and,1,$(getvar,ossnaphatch)),!.)OsnapHatch

displays highlighted when on.  Simple and easy alternative for displaying whether a system variable is On -vs- Off.

For newer versions the proper macro would be 

^P'setvar;osoptions;$M=$(if,$(and,1,$(getvar,osoptions)),$(-,$(getvar,osoptions),1),$(+,$(getvar,osoptions),1)) ^P 

with a Display Name of 

$(if,$(and,1,$(getvar,osoptions)),!.)OsnapHatch

While OsnapHatch still works in 2019 it's hasn't been listed in help since before the 2015 versions. 

  • Like 1
Link to comment
Share on other sites

On 6/19/2019 at 6:43 PM, steven-g said:

 


$(index,$(getvar, osnaphatch),"Current snap to hatch: off,Current snap to hatch: on")

I only prefer to changeit to  "Toggle snap to hatch ON,Toggle snap to hatch OFF" wich I find more meaningfull

 

Edited by harinezumi
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...