Popup menu position

Discussion in 'AutoCAD' started by Marcel Goulet, May 31, 2004.

  1. Hi,

    In lisp or Vlisp, how can I obtain the position of a popup menu among all the displayed menus?

    For exemple, the menu Draw.

    Thanks
     
    Marcel Goulet, May 31, 2004
    #1
  2. Marcel Goulet

    SpeedCAD Guest

    Hi...

    With this ;):

    (defun PosMenu (menuname / i posicion noexiste)
    (setq i 0)
    (vlax-for menu
    (vla-get-menus
    (vla-item
    (vla-get-menugroups
    (vla-get-application
    (vla-get-activedocument (vlax-get-acad-object))
    )
    )
    "ACAD"
    )
    )
    (if (or (equal (strcase menuname) (strcase (vla-get-name menu)))
    (equal (strcase menuname)
    (strcase (vla-get-namenomnemonic menu))
    )
    )
    (setq posicion i)
    (setq noexiste "\nNo existe")
    )
    (setq i (1+ i))
    )
    (if posicion
    (prompt (strcat "\n" (rtos posicion 2 0)))
    (prompt noexiste)
    )
    (prin1)
    ) ;_defun

    (posmenu "Draw") -> 6
    (posmenu "draw") ->6
    (posmenu "&draw") ->6
    (posmenu "modify") ->9
    (posmenu "speedcad") ->No existe

    Un saludo de SpeedCAD... :)
    CHILE
    FORO: http://www.hispacad.com/foro
     
    SpeedCAD, May 31, 2004
    #2
  3. Hi Mr. SpeedCad ! :)

    I tried your program and it's not exactly what I need.

    For exemple, if I try your program with the Express menu, of course I change the menu group in your program, the answer will be zero. Your program give the position in the menu file not in the current display.

    The answer for the express menu should have been, in my case, position 10.

    So do you think it's still possible to obtain the position in the current display of a popup menu among all the popup menus from different menu group ?

    Thanks
     
    Marcel Goulet, Jun 2, 2004
    #3
  4. How about something like this?

    ; function return the position of [name] on the menubar
    ; Arguments:
    ; [name] - string, menu item name
    ; return: zero based integer or nil
    (defun getMenuPosition (name / lst)
    (vlax-for item (vla-get-menubar (vlax-get-acad-object))
    (setq lst (cons (strcase (vla-get-namenomnemonic item)) lst)))
    (vl-position (strcase name) (reverse lst))
    )


    --

    Autodesk Discussion Group Facilitator


    group in your program, the answer will be zero. Your program give the position in the menu
    file not in the current display.
    popup menu among all the popup menus from different menu group ?
     
    Jason Piercey, Jun 2, 2004
    #4
  5. Thanks alot !
     
    Marcel Goulet, Jun 2, 2004
    #5
  6. You're welcome.
     
    Jason Piercey, Jun 2, 2004
    #6
  7. Perhaps that header should have been stated
    differently as it will only find the first item specified
    by [name], any duplicates would be ignored.

    Duplicate menu names, not much sense, but possible.
     
    Jason Piercey, Jun 2, 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.