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

    Is disabling menu items and or tools possible?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 2 Posters 2.0k Views 2 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.
    • M Offline
      Maggy
      last edited by

      I know that it's very easy to add menu items, tool bars, context menu items with Ruby in Sketchup, but I tried to disable/hide/remove and as far as I can see that's not possible.
      Any suggestions?

      [Maggy]

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

        Remove/Hide: Not on the running process
        Grey=Disable: Depends on the script

        azuby

        *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

        Bad English? PM me, correct me. :smile:**

        1 Reply Last reply Reply Quote 0
        • M Offline
          Maggy
          last edited by

          Thanks.
          Grey sounds good enough. But the only grey I can find is in the class Color document.
          Can you tell me where to find more information?

          [Maggy]

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

            Yes, in the sketchup Ruby API documentation,
            http://download.sketchup.com/sketchuphelp/gsu6_ruby/Docs/Ruby-Menu.html#set_validation_proc
            But the example is a shame. So have a look on these few lines of code:

            grayed_proc = Proc.new { @active_model.path.empty? ? MF_GRAYED ; MF_ENABLED }
            azubymenu = UI.menu("Plugins").add_submenu "Cornflakes"
            azuby_menu_item = azubymenu.add_item "Add milk" do
              UI.messagebox "Adding milk to your cornflakes"
            end
            azubymenu.set_validation_proc azuby_menu_item, &grayed_proc
            # take care for the "&" or write the line;
            azubymenu.set_validation_proc azuby_menu_item do
              @active_model.path.empty? ? MF_GRAYED ; MF_ENABLED
            end
            

            An equal usage is possible for toolbar items.

            azuby

            *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

            Bad English? PM me, correct me. :smile:**

            1 Reply Last reply Reply Quote 0
            • M Offline
              Maggy
              last edited by

              Why didn't I get Ruby in school, when I was 10 years old or so? Now, 40 years later it's very hard to grasp. The most frustrating part it that it looks so easy when I read a perfectly functioning ruby script. But it looks just as easy in a script that's not doing what I expect it to do...

              I copied your code to "cornflakes.rb", loaded it, it shows up in Plugins, it adds milk to my cornflakes, but I do not see it grey out any menu item. So I started editing, editing, editing, each time closing SU, restarting it, reloading Cornflakes.rb till the milk and cornflakes were coming out of my ears, but still no greyed out menu items.

              [Maggy]

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

                Maybe because you have to set the @active_model before using the code - like this:

                @active_model = Sketchup.active_model
                

                I haven't ried the code and at the moment I'm in university and do not have Sketchup installed. I'll care this evening, if it won't work as expected.

                azuby

                *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

                Bad English? PM me, correct me. :smile:**

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

                  For me this code works with the additional line. I put it to a .rb file, load Sketchup, try to use Plugins > Cornflakes > Add mild, it is grayed, I open a .skp file and try the same and get my breakfest.

                  azuby

                  *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

                  Bad English? PM me, correct me. :smile:**

                  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