GET MENUITEM TAGSTRING OR LABLE OF CLICKED MENUITEM WITH VBA/LISP

Discussion in 'AutoCAD' started by norrin*radd, Oct 1, 2004.

  1. norrin*radd

    norrin*radd Guest

    running AutoCAD map 5, this what I'm trying to do.
    I have several saved queries that I am running from a dropdown menu in a some what clunky way, got an idea to change it but am stumped.
    I want to be able to click on the menu item and have it run a single dvb project (the same one for all) that gets the tagstring of the selected menuitem then runs the query using the 'case' method based on that tag string.
    Right now I've got a separate sub for each menuitem that uses a function call to the query function, and they are filling up my macro manager.
    Is it even possible to get the tagstring of the clicked menuitems/toolbar items? I think this might be a good way to do a block insert toolbar also.
    Thanks for any help, I've been stumped for 2 days.
    willing to use lisp or a combo of the 2 if I have too....
     
    norrin*radd, Oct 1, 2004
    #1
  2. Possible options are using one of the user variables (USERR1-5, USERI1-5,USERS1-5), writing to the registry or writing to a file.
    Regards - Nathan
     
    Nathan Taylor, Oct 5, 2004
    #2
  3. norrin*radd

    norrin*radd Guest

    i think thats the way to go thanks.
     
    norrin*radd, Oct 5, 2004
    #3
  4. This should do what you are looking for. It should be treated as
    pseudo-code. The key is in the KB article noted below.
    ------------------------------
    In the .mnu file:

    //FILENAME: CUTools2.mnu
    //BY: John R. Goodfellow
    //PURPOSE: AutoCAD partial menu.
    //NOTES: CUStart.dvb must already be loaded when menu item is selected in
    order
    // to pass menu tag names as parameters to
    CUStart.ThisDrawing.MenuHit macro.
    ***MENUGROUP=CUTools2
    ***POP17
    **CUTools2
    ID_CUToolsMain [BOM Tools]
    ID_BOMMain [->BOM/CU Options]
    ID_BOMSubCreate [Create Single New BOM and CU]^c^c(command "-VBARUN"
    "CUStart.ThisDrawing.MenuHit" "ID_BOMSubCreate")
    ID_BOMSubUpdAccess [Update Single Access Table From Drawing]^c^c(command
    "-VBARUN" "CUStart.ThisDrawing.MenuHit" "ID_BOMSubUpdAccess")
    ID_BOMSubUpdDwg [Update Single Drawing From Access Table]^c^c(command
    "-VBARUN" "CUStart.ThisDrawing.MenuHit" "ID_BOMSubUpdDwg")
    [--]
    // etc.
    // end CUTools2.mnu

    ------------------------------
    In CUStart.dvb:

    Public Sub MenuHit()
    Dim i As Integer
    Dim sAppPath As String, sTemp As String

    ' See an Autodesk Knowledge Base article titled
    ' "Passing arguments to a Visual Basic for Applications (VBA) macro"
    ' for more information
    gsMenuTag = ThisDrawing.Utility.GetString(False)

    ' save the menu tag of the selected menu item to the application registry
    SaveSetting AppName:="AppName", Section:="CUTools2", key:="MenuHit",
    Setting:=gsMenuTag

    ' get the application path (placed in the application registry elsewhere)
    sAppPath = GetSetting(AppName:="AppName", Section:="CUTools2",
    key:="DVBPath")

    ' load the main application code
    Application.LoadDVB sAppPath & "CUTools2.Dvb"

    ' run the main application
    Application.RunMacro "CUTools2.ThisDrawing.Main"

    ' unload the main application code
    'Application.UnloadDVB sAppPath & "CUTools2.Dvb"

    ' error handling removed
    End Sub

    ------------------------------
    In CUTools2.dvb:

    Public Sub Main()
    Dim sMenuTag As String
    Dim sTblName As String

    ' get menu tag of currently selected menu item, saved in
    CUStart.ThisDrawing.MenuHit
    sMenuTag = GetSetting(AppName:="AppName", Section:="CUTools2",
    key:="MenuHit")

    ' Process the selected menu item
    ' Create Single New BOM and CU
    Select Case sMenuTag
    Case "ID_BOMSubCreate"
    ' do something
    Case "ID_BOMSubUpdAccess"
    ' do something
    Case "ID_BOMSubUpdDwg"
    ' do something
    Case Else
    MsgBox "Main() Unrecognized menu tag: " & sMenuTag, vbOKOnly,
    "Application Message"
    End Select
    ....
    End Sub
    --
    John Goodfellow
    irtfnm
    use john at goodfellowassoc dot com


    some what clunky way, got an idea to change it but am stumped.
    project (the same one for all) that gets the tagstring of the selected
    menuitem then runs the query using the 'case' method based on that tag
    string.
    call to the query function, and they are filling up my macro manager.
    items? I think this might be a good way to do a block insert toolbar also.
     
    John Goodfellow, Oct 8, 2004
    #4
  5. Thanks John,
    Very simple but I never would have thought of it.
    Regards - Nathan
     
    Nathan Taylor, Oct 11, 2004
    #5
  6. norrin*radd

    norrin*radd Guest

    sorry took so long to reply, thanks I'll let you know how it comes out after I get time to get back on it.
    seems like everyone wants everything at the same time now.
    thanks again
     
    norrin*radd, Oct 21, 2004
    #6
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.