Author Topic: Menu loaded but couldn't be shown on menu bar  (Read 2725 times)

0 Members and 1 Guest are viewing this topic.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Menu loaded but couldn't be shown on menu bar
« on: July 30, 2014, 07:11:00 AM »
Hello gentlemen .

My following codes able to write and load the menu file "Mechanicals" in AutoCAD but it is not appearing into the Menu Bar .

Anyone can give any advise in this regard ?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ *error* p f o)
  2.   (if (not (menugroup "Mechanicals"))
  3.     (progn (if (and (setq p (findfile "fonts"))
  4.                     (setq f (strcat (substr p 1 (- (strlen p) 5)) "support\\Mechanicals.mnu"))
  5.                     (setq o (open f "w"))
  6.                )
  7.              (progn (foreach x '("***menugroup=Mechanicals\n***POP20\n[Mechanical]"
  8.                                  "ID_Elbow [Type elbow to start]^C^C_Elbow"
  9.                                  "ID_Tee [Type Tee to start]^C^C_Tee"
  10.                                  "[--]"
  11.                                 )
  12.                       (write-line x o)
  13.                     )
  14.                     (close o)
  15.                     (command "menuload" f)
  16.              )
  17.            )
  18.     )
  19.   )
  20.   (princ)
  21. )
  22.  

Much appreciated .

kpblc

  • Bull Frog
  • Posts: 396
Re: Menu loaded but couldn't be shown on menu bar
« Reply #1 on: July 30, 2014, 07:15:01 AM »
I think you have to use vla-insertinmenubar function
Sorry for my English.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Menu loaded but couldn't be shown on menu bar
« Reply #2 on: July 30, 2014, 07:25:46 AM »
I think you have to use vla-insertinmenubar function

Thanks for your input kpblc .

You're right , but I wonder why , if I loaded the menu manually with the use of the command loadmenu it works , but in lisp routine it does not work as shown in the codes above !


kpblc

  • Bull Frog
  • Posts: 396
Re: Menu loaded but couldn't be shown on menu bar
« Reply #3 on: August 01, 2014, 01:40:07 AM »
I don't know the reason. But from ACAD2008 these steps should be done. Perhaps this behavior is associated with workspaces - I'm not sure (((
Sorry for my English.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Menu loaded but couldn't be shown on menu bar
« Reply #4 on: August 01, 2014, 03:17:14 AM »
I don't know the reason. But from ACAD2008 these steps should be done. Perhaps this behavior is associated with workspaces - I'm not sure (((

Thank you kpblc for following up my thread and trying to help . too much appreciated . :-)

The codes that belongs to toolbars creation is working and showing the toolbars smoothly and nicely , so I don't know what cause the menu not to appear in the menu bar although it is being loaded in Autocad .

kpblc

  • Bull Frog
  • Posts: 396
Re: Menu loaded but couldn't be shown on menu bar
« Reply #5 on: August 01, 2014, 03:57:51 AM »
Usually i use construction like (vla-load (vla-get-menugroups (vlax-get-acad-object)) <MenuFile>) and after that something like this:
Code: [Select]
(foreach menugrp <MenuGroupsToLoad>
  (vlax-for submenu (vla-get-menus
                      (vla-item (vla-get-menugroups (vlax-get-acad-object))
                                menugrp
                                ) ;_ end of vla-item
                      ) ;_ end of vla-get-menus
    (vl-catch-all-apply
      (function
        (lambda ()
          (vla-insertinmenubar
            submenu
            (1+ (vla-get-count (vla-get-menubar (vlax-get-acad-object))))
            ) ;_ end of vla-insertinmenubar
          ) ;_ end of lambda
        ) ;_ end of function
      ) ;_ end of vl-catch-all-apply
    ) ;_ end of vlax-for
  ) ;_ end of foreach
Works correct (tested on ACAD2009-2015)
Sorry for my English.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Menu loaded but couldn't be shown on menu bar
« Reply #6 on: August 01, 2014, 04:24:51 AM »
Usually i use construction like (vla-load (vla-get-menugroups (vlax-get-acad-object)) <MenuFile>) and after that something like this:

I did something similar a few months ago as shown here https://www.youtube.com/watch?v=V2VnJobDeiU#! but I found out recently that with the use of file.mnu we can write a better presentation menu that can custom abbreviation keys like Ctrl+ and Shift ... etc and what's more that we have the flexibility to write the menu item as best as we want without a restriction to have the menu item as the name of the routine or command call as you can see in the video .

And having the sub-menu is easy to build , and line separators and many more, very interesting menu construction indeed .   :wink:

Regards