How to add a new menu item to an existing menu?

Discussion in 'AutoCAD' started by Thurl Amick II, May 12, 2004.

  1. I'm trying to add a new menu item to an existing pulldown menu
    programmatically after its been loaded into ACAD, I don't want to modify the
    ..MNU file. I can do this using VBA but would rather do it using VLisp.
    Does anyone out there know how to do this?

    Thanks,
    TMA
     
    Thurl Amick II, May 12, 2004
    #1
  2. Thurl Amick II

    Walt Engle Guest

    What's wrong with modifying the acad.mnu? I do it all the time. I keep a copy on
    my zip drive and elsewhere, but modify it and recompile it. If I've made a
    mistake (and the gods know I have), I edit it again and recompile. Simple and
    straight forward.
     
    Walt Engle, May 13, 2004
    #2
  3. Thurl Amick II

    Jeff Mishler Guest

    This should get you started

    (setq menugroups (vla-get-menugroups (vlax-get-acad-object))
    menu (vla-item menugroups "Mymenu")
    menus (vla-get-menus menu)
    )
    (setq newBarItem (vla-add menus "myMenu"))
    (vla-addmenuitem newBarItem "End" "Testing" "'redraw")
    (vla-insertinmenubar newbaritem 18)

    Good Luck,
    Jeff
     
    Jeff Mishler, May 13, 2004
    #3
  4. Thanks Jeff, this is exactly what I needed.

    TMA
     
    Thurl Amick II, May 13, 2004
    #4
  5. Thurl Amick II

    OLD-CADaver Guest

    <<What's wrong with modifying the acad.mnu?>>

    Nothing really. But the next acad release makes upgrading to the new menu a lot more work.

    If you leave the basic ACAD.mn? stuff alone and menuload custom menus behind it, it makes the upgrade to the next release a little smoother.

    Now that said. editing the MN file can cause you to lose any customization done during a acad session. If you add or modify the menu using the customize toolbar feature during an acad session ONLY the MN'S is modified and new MC and MN are created. Nothing is changed in the MN. If after that you modify the MN and recompile the menu, you'll lose all the customization saved in the MN'S.

    Some people delete the MNU's entirely to avoid that mistake.
     
    OLD-CADaver, May 13, 2004
    #5
  6. Thurl Amick II

    Walt Engle Guest

    Just a matter of choice. That's why I customize the mnu file and do not use the customize toolbar feature and never had any problems with upgrading.
     
    Walt Engle, May 13, 2004
    #6
  7. Thurl Amick II

    OLD-CADaver Guest

    <<That's why I customize the mnu file and do not use the customize toolbar feature >>

    Oh, you key it all in for a new button?


    <<and never had any problems with upgrading.>>

    It just a hassle to cut-n-paste custom stuff out of the old menu into the new one. We just move from one to the next without any editing, often without a recompile.
     
    OLD-CADaver, May 13, 2004
    #7
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.