Author Topic: menu swapping  (Read 3043 times)

0 Members and 1 Guest are viewing this topic.

wizman

  • Bull Frog
  • Posts: 290
menu swapping
« on: February 20, 2008, 10:36:30 AM »
hi guys,

we are trying to have a program for menu swapping in our company, but we
encountered that using this code:

(command "_.menuload" "L:\\DWG-LIB\\Global\\myown.cui")

loads the cui, but the problem is it cant be seen on the menubar. but when we checked the
menus in menuload dialog box, its already there.

i think i should be using these next two functions but dont know how to use these ones because
i cant find it on my help file.

vla-get-onmenubar
vla-insertmenuinmenubar

any ideas or discussion you can direct us anyone?many thanks  in advance



ronjonp

  • Needs a day job
  • Posts: 7531
Re: menu swapping
« Reply #1 on: February 20, 2008, 11:02:16 AM »
Take a look at MENUCMD.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

wizman

  • Bull Frog
  • Posts: 290
Re: menu swapping
« Reply #2 on: February 20, 2008, 12:25:21 PM »
thanks ronjonp, i tried menucmd also but still not showing in my menu bar, i finally found vla-get-onmenubar on my help file but directed me to a vba solution (as seen below)


Quote
Sub Example_OnMenuBar()
    ' This example creates a new menu called TestMenu and inserts a menu item
    ' into it. The menu is then displayed on the menu bar, and then
    ' removed from the menu bar.
   
    Dim currMenuGroup As acadMenuGroup
    Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
   
    ' Create the new menu
    Dim newMenu As AcadPopupMenu
    Set newMenu = currMenuGroup.Menus.Add("TestMenu")
   
    ' Add a menu item to the new menu
    Dim newMenuItem As AcadPopupMenuItem
    Dim openMacro As String
    ' Assign the macro string the VB equivalent of "ESC ESC _open "
    openMacro = Chr(3) & Chr(3) & Chr(95) & "open" & Chr(32)
   
    Set newMenuItem = newMenu.AddMenuItem(newMenu.count + 1, "Open", openMacro)
   
    ' Display the menu on the menu bar
    newMenu.InsertInMenuBar (ThisDrawing.Application.MenuBar.count + 1)
    GoSub QUERYMENU
   
    ' Remove the menu from the menu bar
    currMenuGroup.Menus.RemoveMenuFromMenuBar ("TestMenu")
    GoSub QUERYMENU
    Exit Sub
   
QUERYMENU:
    If newMenu.OnMenuBar Then
        MsgBox "The menu called " & newMenu.name & " is on the menu bar."
    Else
        MsgBox "The menu called " & newMenu.name & " is not on the menu bar."
    End If
    Return
       
End Sub



this one works fine also except that i cant see the menu on the menu bar.
Code: [Select]
(defun c:test ()
   (setq acad_app (vlax-get-acad-object))
   (setq curr_doc (vla-get-activeDocument acad_app))
   (setq all_menus (vla-get-menuGroups acad_app))
   
   (vlax-for n all_menus
      (if (= (vla-get-name n) "myown")
(setq flag T)
      )
      (terpri)
      (princ (vla-get-name n))
   )
   (if (null flag)
      (vla-load all_menus "myown.cui")
   )
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: menu swapping
« Reply #3 on: February 20, 2008, 12:36:37 PM »
Here is some of my code for my menu setup.

Code: [Select]
(defun MyErrorCheck (Function Listof / ErrChk)
; Use just like (vl-catch-all-apply....
; Returns nil if an error

(setq ErrChk (vl-catch-all-apply Function Listof))
(if (vl-catch-all-error-p ErrChk)
(setq ErrChk nil)
ErrChk
)
)
;---------------------------------------------
    (setq AcadObj (vlax-get-Acad-Object))
    (setq MnGrp (vla-get-MenuGroups AcadObj))
    (if (not (MyErrorCheck 'vla-Item (list MnGrp "custom")))
        (vla-Load MnGrp "C:/MyCustom/Menus/custom.mns")
    )
    (if (not (setq MnObj (MyErrorCheck 'vla-Item (list MnGrp "custom2"))))
        (setq MnObj (vla-Load MnGrp "C:/MyCustom/Menus/custom2.mns"))
        (setq MnObj (vla-Item MnGrp "custom2"))
    )
    (setq MnBar (vla-get-MenuBar AcadObj))
    (if
        (or
            (not (setq MyMenu (MyErrorCheck 'vla-Item (list MnBar "My&Custom"))))
            (and
                (/= (vla-get-Name (vla-Item MnBar (- (vla-get-Count MnBar) 2))) "My&Custom")
                (not (vla-RemoveFromMenuBar MyMenu))
            )
        )
        (vla-InsertInMenuBar
            (vla-Item (vla-get-Menus MnObj) "My&Custom")
            (1- (vla-get-Count MnBar))
        )
    )
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

wizman

  • Bull Frog
  • Posts: 290
Re: menu swapping
« Reply #4 on: February 20, 2008, 01:59:02 PM »
thanks mr t.wiley, ill try your way tomorrow morning.  :-)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: menu swapping
« Reply #5 on: February 20, 2008, 02:12:23 PM »
thanks mr t.wiley, ill try your way tomorrow morning.  :-)
You're welcome.  Let us know what happens.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

KewlToyZ

  • Guest
Re: menu swapping
« Reply #6 on: February 20, 2008, 07:01:07 PM »
Double check your profile paths to make sure they are available as well.
You may want to set mywon.cui as your enterprise cui.
Possibly create a few default workspaces in it to make sure things load out correctly.
Export the profile of the workstation where it is setup correctly as well, then try importing it on other workstations.

wizman

  • Bull Frog
  • Posts: 290
Re: menu swapping
« Reply #7 on: February 21, 2008, 07:31:23 AM »
your code is very helpful to us mr. willey,it is working and loading the menu now, we really appreciate your help on this one,
thank you very much to you and the guys who replied.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: menu swapping
« Reply #8 on: February 21, 2008, 11:05:11 AM »
your code is very helpful to us mr. willey,it is working and loading the menu now, we really appreciate your help on this one,
thank you very much to you and the guys who replied.
You're welcome.   I'm glad you got something that works for you.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.