List all visible Toolbars

List all visible Toolbars

scot-65
Advisor Advisor
915 Views
6 Replies
Message 1 of 7

List all visible Toolbars

scot-65
Advisor
Advisor

I'm trying to build a list of all visible toolbars on the UI.

What I have so far does not seem to do it.

I have tried vla-get-tagstring and vla-getname, and a few others without success.

 

 (setq b nil)
 (vl-catch-all-apply (function (lambda ()
  (vlax-for tbar (vla-get-toolbars (vlax-get-acad-object))
   (setq b (cons (vla-getname tbar) b))
 ))))
(princ "\n b= ")(princ b)(princ)

The list can either be the toolbar name or it's Element ID.

Any help is appreciated.

 

Scot-65

 


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

0 Likes
916 Views
6 Replies
Replies (6)
Message 2 of 7

hmsilva
Mentor
Mentor

HI scot-65,

perhaps something like this (untested)

 

(vlax-for mnu (vla-get-menugroups (vlax-get-acad-object))
   (vlax-for tlb (vla-get-toolbars mnu)
      (setq tlb_lst (cons (vla-get-name tlb) tlb_lst))
   )
)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 7

scot-65
Advisor
Advisor
What you show are ALL the available toolbars, and yes, it works.
However, what I am looking for is the current visible ones.

The snippet I am adapting came from showing the
menu bar POPs via vla-get-menubar / vla-get-tagstring.
I'm looking for the equivalent for toolbars.

Scot-65

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 7

hmsilva
Mentor
Mentor

@scot-65 wrote:
What you show are ALL the available toolbars, and yes, it works.
However, what I am looking for is the current visible ones.
...

Visible ones... my bad...

 

(vlax-for mnu (vla-get-menugroups (vlax-get-acad-object))
   (vlax-for tlb (vla-get-toolbars mnu)
      (if (= (vla-get-visible tlb) :vlax-true)
         (setq tlb_lst (cons (vla-get-name tlb) tlb_lst))
      )
   )
)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 5 of 7

scot-65
Advisor
Advisor

Oh, how sweet!

I do thank you for your help, hmsilva.

 

For future reference, the synopsis is as follows:

Our menu system swaps POPs and Toolbars in lieu of Workspaces

(if we used workspaces, there would be at least 20 of them and this menu was developed way back in R12 to R2004).

 

When opening a drawing, the Drawing environment is set and the

UI's POP and Toolbars are also aligned (for now).

For this to happen, a Dictionary "Gremlin" is introduced into the file.

 

To set the toolbars, the following code is used:

 

 
 (vlax-for mnu (vla-get-menugroups (vlax-get-acad-object))
  (vlax-for tlb (vla-get-toolbars mnu)
   (if (= (vla-get-visible tlb) :vlax-true)
    (if (member (vla-get-name tlb) %TBNAMES%);is showing and a member of the list
     (vla-put-visible tlb :vlax-false)))
   (if (= (vla-get-name tlb) a)
    (vla-put-visible tlb :vlax-true))
 ))
 

Where %TBNAMES% is a LIST of all the "Custom" toolbar names to hide

and [a] is the toolbar that will display.

 

Scot-65

 


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

0 Likes
Message 6 of 7

hmsilva
Mentor
Mentor

You're welcome, Scot-65
Glad I could help

Henrique

EESignature

0 Likes
Message 7 of 7

scot-65
Advisor
Advisor
I have this section of code as part of the S::STARTUP section and when
testing this code, the code is read but does not execute when SDI=1.
I had to wrap this code with a temporary SDI toggle in order for this to
execute.
How strange.

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

0 Likes