Author Topic: how to detect menu ?  (Read 5890 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
how to detect menu ?
« on: September 23, 2005, 01:34:11 PM »
a little simple question...

maybe i already know....but I can find a way.....

I would like to detect if a menu is loaded or not...
and display a toolbar..

any idea ?
Keep smile...

M-dub

  • Guest
Re: how to detect menu ?
« Reply #1 on: September 23, 2005, 01:37:56 PM »
menuload?

Simple enough...

Andrea

  • Water Moccasin
  • Posts: 2372
Re: how to detect menu ?
« Reply #2 on: September 23, 2005, 01:45:44 PM »
sorry....i mean...in lisp..

eg:

(setq menulist ([list menu]))

or

(if ([Menu "X"]) (vl-cmdf "_-toolbar" "_s" "tb1"))

something like that.
Keep smile...

M-dub

  • Guest
Re: how to detect menu ?
« Reply #3 on: September 23, 2005, 01:47:15 PM »
Lisp, eh?  I think you should have posted this in the Lisp forum.  I'll move it.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: how to detect menu ?
« Reply #4 on: September 23, 2005, 02:02:21 PM »
ok....sorry, :?
Keep smile...

Crank

  • Water Moccasin
  • Posts: 1503
Re: how to detect menu ?
« Reply #5 on: September 23, 2005, 02:12:46 PM »
RTFM  :evil: :

VLISP-help > Menus property, example code

Code: [Select]
Sub Example_Menus()
    ' This example finds the names of all menus in the first menu group.
   
    Dim menuNames As String
    Dim menuCollection As AcadPopupMenus
    Dim menu As AcadPopupMenu
   
    Set menuCollection = ThisDrawing.Application.MenuGroups.Item(0).Menus
    menuNames = ""
    For Each menu In menuCollection
        menuNames = menuNames & menu.name & vbCrLf
    Next menu
    MsgBox menuNames
End Sub
Vault Professional 2023     +     AEC Collection

Andrea

  • Water Moccasin
  • Posts: 2372
Re: how to detect menu ?
« Reply #6 on: September 23, 2005, 02:18:35 PM »
Thanks Crank...
but I found a easier way..

(menugroup groupname)
Keep smile...

Crank

  • Water Moccasin
  • Posts: 1503
Re: how to detect menu ?
« Reply #7 on: September 23, 2005, 02:28:35 PM »
 :-)

Perhaps you can use this function from acadx.com :
Code: [Select]
(defun ax:ListToolbars (groupName / mGroups mGroup lst)
  (vl-load-com)
  (if (not
(vl-catch-all-error-p
  (setq
    mGroup (vl-catch-all-apply
     'vla-item
     (list (vla-get-menugroups (vlax-get-acad-object))
   groupName
     )
   )
  )
)
      )
    (vlax-for tBar (vla-get-toolbars mGroup)
      (setq lst (cons (vla-get-name tBar) lst))
    )
  )
)
Vault Professional 2023     +     AEC Collection

Crank

  • Water Moccasin
  • Posts: 1503
Re: how to detect menu ?
« Reply #8 on: September 23, 2005, 02:35:14 PM »
(to check if the toolbar still exists)
Vault Professional 2023     +     AEC Collection

Andrea

  • Water Moccasin
  • Posts: 2372
Re: how to detect menu ?
« Reply #9 on: September 23, 2005, 02:46:29 PM »
humm... :?

interresting.. thanks.

But how it work ?..
I can found a way to run the routine..
 :|
« Last Edit: September 23, 2005, 02:50:36 PM by Andrea »
Keep smile...

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: how to detect menu ?
« Reply #10 on: September 23, 2005, 03:00:13 PM »
Just for reference:

Code: [Select]
(if (menugroup "ase_partial")
(alert "ASE Partial Menu is loaded.")
(alert "Cannot find specified menu.")
)

Andrea

  • Water Moccasin
  • Posts: 2372
Re: how to detect menu ?
« Reply #11 on: September 23, 2005, 04:23:56 PM »
Just for reference:

Code: [Select]
(if (menugroup "ase_partial")
(alert "ASE Partial Menu is loaded.")
(alert "Cannot find specified menu.")
)

I mean...Crank's routine..
Keep smile...

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: how to detect menu ?
« Reply #12 on: September 23, 2005, 04:28:35 PM »
Just for reference:

Code: [Select]
(if (menugroup "ase_partial")
(alert "ASE Partial Menu is loaded.")
(alert "Cannot find specified menu.")
)

I mean...Crank's routine..

I know...just putting some other code out there for people to mull over...  :evil:

Crank

  • Water Moccasin
  • Posts: 1503
Re: how to detect menu ?
« Reply #13 on: September 23, 2005, 05:27:57 PM »
The routine only returns a list of all toolbars in a menu.
If you want to check if the toolbar exists you'll have to do something like:
Code: [Select]
(if (member "toolbarname" (ax:listtoolbars "menuname"))
   (princ "\nToolbar exists")
   (princ "\nToolbar not present")
)

The menuname and toolbarname are not allways the same as displayed on screen in autocad. You must use the names given in the .mnu/.mns or .cui
« Last Edit: September 23, 2005, 05:32:22 PM by Crank »
Vault Professional 2023     +     AEC Collection

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Re: how to detect menu ?
« Reply #14 on: September 24, 2005, 06:33:38 AM »
For more functions around menus, visit my homepage -> 'Free Stuff' and search for:
VxGetLoadedMenus, VxUnLoadMenuGroup, VxGetPopups and VxGetToolbars
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18