Author Topic: MENU or TOOLsBAR ??  (Read 2279 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
MENU or TOOLsBAR ??
« on: October 28, 2004, 09:06:33 AM »
Hi all...

How can i detect if some menu or toolbar is loaded...??


thanks.
Keep smile...

whdjr

  • Guest
MENU or TOOLsBAR ??
« Reply #1 on: October 28, 2004, 09:34:12 AM »
Code: [Select]
(defun map (collection / lst)
  (vlax-map-collection
    collection
    '(lambda (x) (setq lst (cons x lst)))
  )
  lst
)

(defun c:menutest (/ acadmenugroup xrefmenu)
  (setq acadmenugroup (car (vl-remove-if-not
    '(lambda (x) (eq (vla-get-name x) "ACAD"))
    (map (vla-get-menugroups (vlax-get-acad-object)))
  )
     )
xrefmenu
     (car (vl-remove-if-not
    '(lambda (x) (wcmatch (vla-get-name x) "*XREF*"))
    (map (vla-get-menus acadmenugroup))
  )
     )
  )
  (vla-addmenuitem
    xrefmenu
    (1+ (vla-get-count xrefmenu))
    "Xref Tester3"
    "(princ \"\nThis is a test\")"
  )
)

This is one I have that I was using to test.  All it does is see if there is an xref menu loaded and then it checks to see if a particular menu item is loaded and if not it creates it.  I hope this example helps.

whdjr

  • Guest
MENU or TOOLsBAR ??
« Reply #2 on: October 28, 2004, 09:36:01 AM »
Code: [Select]
(defun c:bitmenu (/ fn acadobj menus currMenuGroup)
  (vl-load-com)
  (if (not (findfile "C:\\Program Files\\ACAD2000\\SUPPORT\\DeLoach.mns"))
    (progn
      (setq fn (open "C:\\Program Files\\ACAD2000\\SUPPORT\\DeLoach.mns" "w"))
      (close fn)
    )
  )
  (setq acadobj (vlax-get-acad-object))
  (setq menus (vla-get-menuGroups acadobj))
  (if (vl-catch-all-error-p
(vl-catch-all-apply
 '(lambda ()
    (setq currMenuGroup (vla-item menus "DeLoach"))
  )
)
      )
    (setq currMenuGroup (vla-load menus "DeLoach.mns"))
  )
  (if (vl-catch-all-error-p
(vl-catch-all-apply
 '(lambda ()
    (vla-item (vla-get-toolbars currMenuGroup)
      "Block Insert Toolbar"
    )
  )
)
      )
    (createToolbar)
    (princ
      "\nThe Block Insert Toolbar is already loaded"
    )
  )
  (princ)
)


(defun createToolbar (/ newToolbar)
  (setq newToolbar
(vla-add (vla-get-toolbars currMenuGroup)
 "Block Insert Toolbar"
)
  )
  (button
    "door"       "Door Bubble Insert"
    "Door Bubble Insert"       "door"
    "door"
    "Inserts door bubble and increments up from a start number: DOOR"
   )
  (button
    "room48" "1:48 Scale Room Bubble"
    "1:48 Scale Room Bubble" "room48"
    "room48"
    "Inserts the room name and number block @ 1/4\" SCALE:  ROOM48"
   )
  (button
    "room192"
    "1:192 Scale Room Bubble"
    "1:192 Scale Room Bubble"
    "room192"
    "room192"
    "Inserts the room name and number block @ 1/16\"=1'-0\" SCALE:  ROOM192"
   )
  (button
    "room240"    "1:240 Scale Room Bubble"
    "1:240 Scale Room Bubble"    "room240"
    "room240"
    "Inserts the room name and number block @ 1\"=20'-0\" SCALE:  ROOM240"
   )
  (button
    "clg"   "1/8\" Ceiling Bubble"
    "1/8\" Ceiling Bubble"   "ceiling"
    "ceiling"   "Inserts the ceiling number block @ 1/8\" SCALE:  CLG"
   )
  (button
    "floor"    "1/8\" Floor Name Square"
    "1/8\" Floor Name Square"    "floor"
    "floor"    "Inserts the floor number block @ 1/8\" SCALE:  FLOOR"
   )
  (button
    "numinc" "Increment block numbering"
    "Increment block numbering" "increment"
    "increment" "Increments the numbering of blocks: NUMINC"
   )
  (vla-save currMenuGroup acMenuFileCompiled)
  (vla-save currMenuGroup acMenuFileSource)
)



(defun button (macro buttonName   helpStringName    SmallBitmapName
      LargeBitmapName helpString   /     newToolbarButton
     )
  (setq newToolbarButton
(vla-addToolbarButton
  newToolbar
  (1+ (vla-get-count newToolbar))
  buttonName
  helpStringName
  (strcat (chr 3) (chr 3) macro (chr 32))
)
  )
  (vla-setBitmaps
    newToolbarButton
    SmallBitmapName
    LargeBitmapName
  )
  (vla-put-helpString newToolbarButton helpString)
)

This is one i wrote a while back that creates a new menu and toolbars to go with it.  (I did mention this was a while ago, didn't I?)

ML

  • Guest
VBA
« Reply #3 on: October 28, 2004, 10:33:53 AM »
Andrea, if you'd like, I can post a simple VBA Module that will do precisely that.

Let me know

Mark

daron

  • Guest
MENU or TOOLsBAR ??
« Reply #4 on: October 28, 2004, 11:59:17 AM »
Why don't you just type menuload? If it's there, you'd see it.

ML

  • Guest
MENU or TOOLsBAR ??
« Reply #5 on: October 29, 2004, 10:44:52 AM »
Andrea, Here is a VBA Module that I dveloped for that purpose, hope it helps

Mark


Code: [Select]

Sub ListMenuGroups()


Dim MenuGroup As AcadMenuGroup
Dim MenuGroupNames As String


MenuGroupNames = "The following menu groups are currently loaded: "

For Each MenuGroup In ThisDrawing.Application.MenuGroups
If MenuGroup.Type = acBaseMenuGroup Then
MenuGroupNames = MenuGroupNames & vbCrLf & MenuGroup.Name & " : Base Menu"
Else
MenuGroupNames = MenuGroupNames & vbCrLf & MenuGroup.Name & " : Partial Menu"
End If


Next


MsgBox MenuGroupNames, vbInformation


End Sub

ML

  • Guest
MENU or TOOLsBAR ??
« Reply #6 on: October 29, 2004, 01:54:24 PM »
Ok, here is another one that will list out the parts (toolbars and pulldown menus) of the menu group that you enter.

Just type the name of the menu group down where it say, Express, launch this module and it will list out the parts of that menu group



Code: [Select]

Sub ListMenusAndToolbars()

Dim MenuGroup As AcadMenuGroup
Dim PopupMenu As AcadPopupMenu
Dim Toolbar As AcadToolbar
Dim MenusAndToolbars As String
Dim MenuGroupName As String

On Error Resume Next

Set MenuGroup = ThisDrawing.Application.MenuGroups.Item("Express") '<- Type the name of the menu group that you would like to list
MenuGroupName = MenuGroup.Name

If MenuGroup Is Nothing Then
MsgBox "No menu has been selected"
Exit Sub
End If

MenusAndToolbars = _
"The " & MenuGroupName & " menu group is comprised of the following pop menus: " & vbCrLf & vbCrLf

For Each PopupMenu In MenuGroup.Menus
MenusAndToolbars = MenusAndToolbars & PopupMenu.NameNoMnemonic & ","
'The NoMnemonic property is used to display the names of the menus only.
'The name property alone would list all accelerators as well.
Next


MenusAndToolbars = _
MenusAndToolbars & vbCrLf & vbCrLf & "and the following toolbars:" & vbCrLf & vbCrLf

For Each Toolbar In MenuGroup.Toolbars
MenusAndToolbars = MenusAndToolbars & Toolbar.Name & ","
Next

MsgBox MenusAndToolbars, vbInformation

End Sub