Toggle Toolbar Button

Toggle Toolbar Button

BigBeam
Enthusiast Enthusiast
525 Views
5 Replies
Message 1 of 6

Toggle Toolbar Button

BigBeam
Enthusiast
Enthusiast

Is there a simple way to create a toolbar button that toggles (i.e. on or off). I have some routines that toggle layer states and I want to be able to see those states visually on a toolbar.

0 Likes
526 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

They can be made to toggle [for example] on/off-type System Variable values, or cycle through those with more than two values [e.g. the ISOPLANE setting].  One could easily be made to go to [Restore] a given Layer State if that's what "on" means, but what would "off" mean in relation to a Layer State?  Go [back?] to all Layers on, or something?  What if you didn't come to the current State from that condition, but from some other defined State?  I'm not aware that when you have restored a Layer State, it knows which one you're in, and you could change any Layer conditions independently of State status subsequent to that, so I don't know of a way to trigger something based on what State you're in, if any.

 

EDIT:

Maybe a tool palette item could contain a variable setting -- Restore a given Layer State and set a variable to T[rue].  Next time you pick it, it could check that variable, and if True, go to whatever "off" means [see above] and set that variable to nil, but if not, Restore that Layer State and set it to True.  But suppose you have one like that for LayerStateA and another for LayerStateB, and along the way you have used both, and both have their variables set to True.  If A was the first one picked, then later B, and you're "in" B but maybe have changed some things since [turned on an individual Layer, made a new one, etc.], then what should it do if you pick on the Tool Palette item for A?  Its variable would be True, so if your intent would be that it Restore A [since that's not what you're in], the variable-based approach would then not get you what you want.

 

Making Tool Palette buttons to go to particular defined Layer States is easy.  It's the "toggling" part that I'm having a hard time imagining.

Kent Cooper, AIA
0 Likes
Message 3 of 6

scot-65
Advisor
Advisor

>>be able to see those states visually

 

I do not think that is possible. Given the complexity of switching out the "visual" buttons on the fly

or graying out buttons that have unique layer state names.

 

One could write a diesel expression to display the current state in the menubar or on MODEMACRO.

 

scot65_0-1693319294894.png

 

scot65_1-1693320352858.png

My understanding of layer states is minimal. We developed and use a "Layer Control" to handle all of this.


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 4 of 6

BigBeam
Enthusiast
Enthusiast

I'm not using later states, just freezing unthawing a standard set of layers. At drawing startup, I will likely need to scan the layers and establish the layer states or put a refresh button on the toolbar. There are 40 layers that I am tracking. 

I found a function called Setbitmaps in the ToolbarItem that can probably toggle an icon but this is pulling me into a custom toolbar addin that I would have to develop. I was hoping to try and achieve this just with the CUI editor...

0 Likes
Message 5 of 6

Jonathan3891
Advisor
Advisor

You can have your routine toggle a toolbar.

 

Here is a simply way to toggle a toolbar on/off

(defun c:ttt (/)
  (if (null tbtoggle)(setq tbtoggle 0))
  (setq tbtoggle (abs (- 1 tbtoggle ))
	);setq
  (if (= tbtoggle 0)
    (COMMAND "-TOOLBAR" "modify" "hide")
    (COMMAND "-TOOLBAR" "modify" "show")
    );if
  (princ)
  )

Jonathan Norton
Blog | Linkedin
0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

"At drawing startup" why not just run a lisp on start up that has the 40 layer names and an on/off setting. need a check does layer exists as well so no error on not found. Has the advantage of a external file rather than the complicated toolbar approach. Did something similar but much more as well like change layer colors.

 

The other comment if still go down toolbar method it is easy to make a custom one with Notepad. Just need an example, can not see that using the CUI as it will save a CUIX.

0 Likes