TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrea 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 ?
-
menuload?
Simple enough...
-
sorry....i mean...in lisp..
eg:
(setq menulist ([list menu]))
or
(if ([Menu "X"]) (vl-cmdf "_-toolbar" "_s" "tb1"))
something like that.
-
Lisp, eh? I think you should have posted this in the Lisp forum. I'll move it.
-
ok....sorry, :?
-
RTFM :evil: :
VLISP-help > Menus property, example code
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
-
Thanks Crank...
but I found a easier way..
(menugroup groupname)
-
:-)
Perhaps you can use this function from acadx.com :
(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))
)
)
)
-
(to check if the toolbar still exists)
-
humm... :?
interresting.. thanks.
But how it work ?..
I can found a way to run the routine..
:|
-
Just for reference:
(if (menugroup "ase_partial")
(alert "ASE Partial Menu is loaded.")
(alert "Cannot find specified menu.")
)
-
Just for reference:
(if (menugroup "ase_partial")
(alert "ASE Partial Menu is loaded.")
(alert "Cannot find specified menu.")
)
I mean...Crank's routine..
-
Just for reference:
(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:
-
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:
(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
-
For more functions around menus, visit my homepage -> 'Free Stuff' and search for:
VxGetLoadedMenus, VxUnLoadMenuGroup, VxGetPopups and VxGetToolbars
-
Hey Jürg ..
Interesting web site..
thanks