sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Reusing menus - what is going on?

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 6 Posters 551 Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Chris FullmerC Offline
      Chris Fullmer
      last edited by

      This isn't an official answer, just from what I've seen playing around, but yeah, you've got it all sorted out. They can be added together when SU starts up, but after it is started, those sub menus are no longer accessible.

      I didn't know you could add multiple into a new submenu after startup, that is interesting. Not too surprising I guess, but still new to me.

      Lately you've been tan, suspicious for the winter.
      All my Plugins I've written

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Also, you can't from the console:

        m = UI.menu('Plugins')
        m.add_item(...){}

        But you can chain it:

        UI.menu('Plugins').add_item(..){}

        Sent from my LT25i using Tapatalk 2

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • A Offline
          Aerilius
          last edited by

          I think toolbars behave similar, don't they?
          When is the UI (submenus or toolbars) "locked up", when it's first displayed or earlier?

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @aerilius said:

            I think toolbars behave similar, don't they?
            When is the UI (submenus or toolbars) "locked up", when it's first displayed or earlier?

            Good questions - I thought it was when it was displayed. But I might be wrong...

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              Within the docs for the C++ SDK, is explained why the C++ references may not be persistent.

              Basically at the beginning of every SDK call, the coder must get a handle to the SketchUp application.
              From that reference, you go on to get handles to child objects of the app, such as the App's window object, menubar object, etc.
              This application handle (reference) gets discarded at the end of the called function.

              I think it is a bit weird, as the application handle (and it's app window, main menubar, etc.) should not change during the session.. and constant references could be created for them. (And I have done so using C and Win32API.so.)

              I would think it should also be possible also in C++, because the API does create constant references to some other things.

              It is annoying each time you call UI.menu("MenuName") a new and different reference is created on the Ruby-side.

              What I wish for.. is the UI.menu method to accept menu pathname (sometimes called an xpath,) .. for example:
              UI.menu('/') # the root menubar ref
              UI.menu('/Draw') # top level 'Draw' menu
              UI.menu('/Draw/Guide') # the 'Guide' submenu of the 'Draw' topmenu

              So let's say I want to create a toplevel "Ruby" menu (and I've wanted to for SO LONG!)
              I would do something like this:
              RUBY_MENU = UI.menu('/').add_submenu('Ruby') verb = RUBY_MENU.add_item('$VERBOSE') { $VERBOSE = !$VERBOSE } RUBY_MENU.add_validation_proc(verb) { $VERBOSE ? MF_CHECKED : MF_UNCHECKED }

              Of course we need persistent Ruby-side references to UI objects.

              πŸ’­

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                +1

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • fredo6F Offline
                  fredo6
                  last edited by

                  I am also facing this problem in the situation where a plugin is freshly enabled

                  • either from the Preferences dialog box
                  • or via the installers (Add Extension, EWH, Plugin Store).

                  I put the menus of my scripts under Tools > Fredo6 Collection. I keep the handle of this top menu.

                  However, if the extension of a plugin is enabled, the handle to this menu is no longer 'valid' for methods such as add_item or add_submenu. It does not really crash or even report an error, but nothing appear under the menu.

                  Basically, this means that when a user will enable or install a plugin 'on the fly', I cannot make it load in the current SU Session. Instead, I'll have to display a message "will load next time you start Sketchup".

                  Note that the problem exists when you group your Plugins under a single menu entry, usually the author name, which is precisely the recommended practice.

                  Reading the present thread, I don't think there is anything to do to circumvent this problem.

                  Fredo

                  1 Reply Last reply Reply Quote 0
                  • Chris FullmerC Offline
                    Chris Fullmer
                    last edited by

                    Yeah, no work arounds Fredo. The user will have to restart SU.

                    Lately you've been tan, suspicious for the winter.
                    All my Plugins I've written

                    1 Reply Last reply Reply Quote 0
                    • fredo6F Offline
                      fredo6
                      last edited by

                      @chris fullmer said:

                      Yeah, no work arounds Fredo. The user will have to restart SU.

                      Chris,

                      Then we need to show a message stating this when the plugin is loaded / reloaded from SU extension manager, EWH or Plugin Store.

                      The toolbar works however, but the fact that the menu are missing may be misleading

                      Fredo

                      1 Reply Last reply Reply Quote 0
                      • Chris FullmerC Offline
                        Chris Fullmer
                        last edited by

                        A message would be nice. That is something each developer will have to put into their own scripts for now.

                        Lately you've been tan, suspicious for the winter.
                        All my Plugins I've written

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          Would it be possible to change the menu API to give persistent references to menus?

                          Thomas Thomassen β€” SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            tomot
                            last edited by

                            @thomthom said:

                            So it appear that it only work if it's all done within one action. Which is why my menu plugin works when SketchUp starts up, because the all the plugins are loaded within the same "loop" (??). ... This is awkward and annoying.

                            I can probably make it work, what I want to do, but it'll hard to debug as I need to actually restart SketchUp every time...

                            😞

                            http://sketchucation.com/forums/viewtopic.php?f=180&t=52489&start=30

                            Yes its a great way to waste more time!
                            Its enough to make one take up quantum computing instead πŸ€“

                            [my plugins](http://thingsvirtual.blogspot.ca/)
                            tomot

                            1 Reply Last reply Reply Quote 0
                            • 1 / 1
                            • First post
                              Last post
                            Buy SketchPlus
                            Buy SUbD
                            Buy WrapR
                            Buy eBook
                            Buy Modelur
                            Buy Vertex Tools
                            Buy SketchCuisine
                            Buy FormFonts

                            Advertisement