Author Topic: Menu Loaded?  (Read 2867 times)

0 Members and 1 Guest are viewing this topic.

A_LOTA_NOTA

  • Guest
Menu Loaded?
« on: September 06, 2007, 05:54:00 PM »
Any way to test to see if a Popup Menu is already loaded before running the code on the link below?

http://www.theswamp.org/index.php?topic=13477.0

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Menu Loaded?
« Reply #1 on: September 06, 2007, 08:06:41 PM »

Do you know the source menuGroupName and menuPop Name ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Menu Loaded?
« Reply #2 on: September 06, 2007, 09:04:02 PM »
I'll probably be asleep when you come back, so see if this gives you any ideas in the mean time ..
Code: [Select]
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
(DEFUN KDUB:ASSERTITEM (collection item / returnvalue)
    (IF (NOT (VL-CATCH-ALL-ERROR-P
                 (SETQ returnvalue (VL-CATCH-ALL-APPLY 'VLA-ITEM
                                                       (LIST collection item)
                                   )
                 )
             )
        )
        returnvalue
    )
)         
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;; Return list of all collection member names
;;;
(DEFUN kdub:ListCollectionMemberNames (collection / itemname returnvalue)
   (SETQ returnvalue '())
   (VLAX-FOR each collection
      (SETQ itemname    (VLA-GET-NAME each)
            returnvalue (CONS itemname returnvalue)
      )
   )
   (REVERSE returnvalue)
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;;;; IAcadApplication Object
(OR GV:IACADAPPLICATION
    (SETQ GV:IACADAPPLICATION (VLAX-GET-ACAD-OBJECT)))
;;;; IAcadDocument Object
(OR GV:IACADDOCUMENT
    (SETQ GV:IACADDOCUMENT (VLA-GET-ACTIVEDOCUMENT GV:IACADAPPLICATION)))
;;;; IAcadDocuments Collection
(OR GV:IACADDOCUMENTS
    (SETQ GV:IACADDOCUMENTS (VLA-GET-DOCUMENTS GV:IACADAPPLICATION)))
;;;; IAcadPreferences Collection
(OR GV:IACADPREFERENCES
    (SETQ GV:IACADPREFERENCES (VLA-GET-PREFERENCES GV:IACADAPPLICATION)))
;;;; IAcadMenuGroups Collection
(OR  GV:IACADMENUGROUPS
     (SETQ (VLA-GET-MENUGROUPS GV:IACADAPPLICATION)))
;;;; IAcadMenuBar Collection
(OR GV:IACADMENUBAR
    (SETQ GV:IACADMENUBAR (VLA-GET-MENUBAR GV:IACADAPPLICATION)))
;;;; IAcadModelspace Object
(OR GV:IACADMODELSPACE
    (SETQ GV:IACADMODELSPACE (VLA-GET-MODELSPACE GV:IACADDOCUMENT)))
;;;; IAcadUtility Object
(OR GV:IACADUTILITY
    (SETQ GV:IACADUTILITY (VLA-GET-UTILITY GV:IACADDOCUMENT)))
;;;; IAcadBlocks Collection
(OR GV:IACADBLOCKS
    (SETQ GV:IACADBLOCKS (VLA-GET-BLOCKS GV:IACADDOCUMENT)))
;;;; IAcadLayers Collection
(OR GV:IACADLAYERS
    (SETQ GV:IACADLAYERS (VLA-GET-LAYERS GV:IACADDOCUMENT)))
;;;;
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
Code: [Select]
(setq menuGroupList (kdub:ListCollectionMemberNames gv:IAcadMenuGroups))

(setq MenuGroupName "SDSTEELTOOLS_MAIN")
     
(setq IAcadMenuGroup (kdub:AssertItem GV:IACADMENUGROUPS MenuGroupName))

         
(VLAX-FOR menu (VLA-GET-MENUS IAcadMenuGroup)
    (princ"\n")
    (princ (VLA-GET-NAMENOMNEMONIC menu))
   
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Menu Loaded?
« Reply #3 on: September 06, 2007, 09:15:52 PM »
and this is the bit you'll need for the pops ..


Code: [Select]
(setq IAcadPopupMenus (VLA-GET-MENUS IAcadMenuGroup))
(setq PopupMenusList (kdub:ListCollectionMemberNames IAcadPopupMenus))
Quote
      ;;=> ("&Object Snap Cursor Menu" "CTA17_Main" "CTA17_Buppy")
         
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

A_LOTA_NOTA

  • Guest
Re: Menu Loaded?
« Reply #4 on: September 07, 2007, 07:46:45 AM »

Do you know the source menuGroupName and menuPop Name ?

Yes, The ones I'm adding with that lisp are "NWM Drawings" & NWM Parts".

Thanks for your help!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Menu Loaded?
« Reply #5 on: September 07, 2007, 11:04:10 AM »

You're welcome.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

A_LOTA_NOTA

  • Guest
Re: Menu Loaded?
« Reply #6 on: September 07, 2007, 03:55:22 PM »

You're welcome.

I must be doing something wrong.... The code you posted bombs....

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Menu Loaded?
« Reply #7 on: September 07, 2007, 07:29:29 PM »

bombs where and on what ?
How are you using it in relation to your problem resolution ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Menu Loaded?
« Reply #8 on: September 07, 2007, 08:37:34 PM »

A_LOTA_NOTA  ,

I've just had a look at Daniels code that you reference.
He has a test included for the existence of the menu item in the menugroup.

I really think you need to post the code you are trying to use otherwise we will be playing guessing games to resolve your problem.




kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

A_LOTA_NOTA

  • Guest
Re: Menu Loaded?
« Reply #9 on: September 08, 2007, 12:45:22 PM »
Kerry,

 I thought his code must have a test in it, but I don't understand all the "vla" & "vlax" stuff.

I was messing with this code at work & don't have it at home, so I can't post what I had. I will see what I can come up with today & post it.

 I'm wanting to write a lisp that will be added to the pull down menu. So I wanted to do  test to see if the pull down menu existed or not. If not run Daniels code or if it had been loaded do nothing.

A_LOTA_NOTA

  • Guest
Re: Menu Loaded?
« Reply #10 on: September 08, 2007, 05:24:23 PM »
Kerry,


Thanks for your help! After read a little on www.afralisp.net about VLISP, I was able to use parts of your code to do the testing I wanted! Its not pretty, but it does the job.

Thanks again!!!  :-)