Loading menu with Lisp

Discussion in 'AutoCAD' started by Marcel Goulet, Nov 22, 2004.

  1. hi,

    I actually load a menu using lisp and I have a problem.

    The menu is loading in the startup of a drawing.

    The Lisp expression is :

    (if (member "SYNCHRONE" (GetMenuGroups))
    (progn
    (command "_.menuunload" "Synchrone")
    (command "_.menuload" (strcat (vl-bb-ref 'path_menu) "Synchrone.mnc"))
    )
    (command "_.menuload" (strcat (vl-bb-ref 'path_menu) "Synchrone.mnc"))
    )
    ;GetMenuGroups is a function that make a list of the loaded menus.

    Then, when I'm in the drawing, I have all those message:

    _.menuload
    Enter name of menu file to load: C:\Program Files\Synchrone\Menu\Synchrone.mnc
    Menu loaded successfully. MENUGROUP: SYNCHRONE
    Command: Initializing VBA System...
    AutoCAD menu utilities ; error: Exception occurred: 0xC0000005 (Access
    Violation)
    ; warning: unwind skipped on exception
    ; error: Exception occurred: 0xC0000005 (Access Violation)
    ; error: Exception occurred: 0xC0000005 (Access Violation)

    and if I open a second drawing, AutoCAD crash with advising.

    Is any one could know the problem ?

    Thank
     
    Marcel Goulet, Nov 22, 2004
    #1
  2. Marcel Goulet

    Jürg Menzi Guest

    Hi Marcel

    That's my solution to load a partial menu:
    Code:
    ;
    ; -- Function MeLoadPartMenu
    ; Loading partial menus.
    ; Arguments [Typ]:
    ;   Grp = Menu group [STR]
    ;   Nme = Menu name [STR]
    ; Return [Typ]:
    ;   > True if file found
    ;   > Nil if not
    ; Notes:
    ;   - Already loaded menu remains
    ;   - Consider changed menu file paths
    ;
    (defun MeLoadPartMenu (Grp Nme / AcaObj FilPth GrpCol MnuLst)
    (setq AcaObj (vlax-get-acad-object)
    GrpCol (vla-get-MenuGroups AcaObj)
    )
    (vlax-for Obj GrpCol
    (setq FilPth (strcase (vla-get-MenuFileName Obj))
    MnuLst (cons
    (strcat
    (vl-filename-directory FilPth)
    "\\" (vl-filename-base FilPth)
    )
    MnuLst
    )
    )
    (vlax-release-object Obj)
    )
    (if (or
    (setq FilPth (findfile (strcat Nme ".mnc")))
    (setq FilPth (findfile (strcat Nme ".mnu")))
    )
    (progn
    (setq FilPth (strcat
    (vl-filename-directory FilPth)
    "\\" (vl-filename-base FilPth)
    )
    )
    (if (menugroup Grp)
    (if (not (member (strcase FilPth) MnuLst))
    (progn
    (MeUnloadMenuGroup Grp)
    (vla-load (vla-get-MenuGroups AcaObj) Nme)
    )
    )
    (vla-load GrpCol Nme)
    )
    T
    )
    (alert
    (strcat
    "Menu file '" Nme ".mnc/.mnu' not found."
    "\nCheck your installation please."
    )
    )
    )
    )
    ;
    ; -- Function MeUnloadPartMenu
    ; Unload a partial menu.
    ; Arguments [Typ]:
    ;   Grp = Menu group name [STR]
    ; Return [Typ]:
    ;   > Null
    ; Notes:
    ;   None
    ;
    (defun MeUnloadPartMenu (Grp)
    (vlax-for Obj (vla-get-MenuGroups (vlax-get-acad-object))
    (if (eq (vla-get-Name Obj) Grp)
    (vla-unload Obj)
    )
    (vlax-release-object Obj)
    )
    (princ)
    )
    
    Cheers
     
    Jürg Menzi, Nov 23, 2004
    #2
  3. Hi Jûrg,

    I tried your function and it's working good but I just remark that if I load the MNU file, the MNS file is not compile !

    Ciao !
     
    Marcel Goulet, Nov 24, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.