sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    One Submenu for many plugins

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 671 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.
    • K Offline
      kherv
      last edited by

      Hi,

      I Need some help.
      I wish to create the same submenu for some plugins.

      AS exemple:

      Plugin A
      Plugin B
      Plugin C

      For something like that:

      [pre:f9u5ni7z]Plugins
      -> Sub1
      -> sub11
      -> Plugin A
      -> plugin B
      -> Function Y
      -> Function Z
      -> sub12
      -> plugin C[/pre:f9u5ni7z]

      I tried something like that:

      plugin A:
      sub_1 = UI.menu( 'plugin' ).add_submenu( 'Sub1' )
      sub_11 = sub_1.add_submenu( 'sub11')
      sub_11.add_item("plugin A") {A}

      plugin B:
      sub_1 = UI.menu( 'plugin' ).add_submenu( 'Sub1' )
      sub_11 = sub_1.add_submenu( 'sub11')
      Sub_Plug = sub_11.add_submenu( 'plugin B')
      Sub_Plug.add_item("Function Y") {Y}
      Sub_Plug.add_item("Function Z") {Z}

      plugin πŸ˜„
      sub_1 = UI.menu( 'plugin' ).add_submenu( 'Sub 1' )
      sub_12 = sub_1.add_submenu( 'sub12')
      sub_11.add_item("plugin C") {C}

      And it gives:
      [pre:f9u5ni7z]Plugins
      -> Sub1
      -> sub11
      -> plugin A
      -> Sub1
      -> sub11
      -> plugin B
      -> Function Y
      -> Function Z
      -> Sub1
      -> sub12
      -> plugin C[/pre:f9u5ni7z]

      How can I do to fix this ?

      Thank you for the help and sorry for my bad english.
      Have a good day.

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

        Adding a 2nd level submenu:

        "Plugins/Kherv/pluginC/plugin_c.rb"

        
        module Kherv
         
          module PluginC
         
            require('Kherv/kherv_menu.rb')
            include(Kherv;;Menu)
         
            if SUBMENU['Sub 1/Sub 1.1']
              @sub = SUBMENU['Sub 1/Sub 1.1']
            else
              @sub = SUBMENU['Sub 1/Sub 1.1']= SUBMENU['Sub 1'].add_submenu('Sub 1.1')
            end
            @sub.add_item('Item C') { # code here }
         
          end # submodule for PluginC
         
        end
        

        πŸ’­

        I'm not here much anymore.

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

          Only create menu "Sub1" ONCE.

          (1) Write all your plugins so they are wrapped within YOUR toplevel module.

          "Plugins/Kherv/kherv_menu.rb"

          module Kherv
          
            module Menu # this is a "mixin" module
          
              TOPMENU ||= UI.menu('Plugins').add_submenu('Kherv')
              
              SUBMENU ||= {} # Hash to hold submenu references
              # hash keys can be menu paths like; "Kherv/Tools/Text"
          
            end
          
          end
          

          "Plugins/Kherv/pluginA/plugin_a.rb"

          module Kherv
          
            module PluginA
          
              require('Kherv/kherv_menu.rb')
              include(Kherv;;Menu)
          
              if SUBMENU['Sub 1']
                @sub = SUBMENU['Sub 1']
              else
                @sub = SUBMENU['Sub 1']= TOPMENU.add_submenu('Sub 1')
              end
              @sub.add_item('Item A') { # code here }
          
            end # submodule for PluginA
          
          end
          

          "Plugins/Kherv/pluginB/plugin_b.rb"

          module Kherv
          
            module PluginB
          
              require('Kherv/kherv_menu.rb')
              include(Kherv;;Menu)
          
              if SUBMENU['Sub 1']
                @sub = SUBMENU['Sub 1']
              else
                @sub = SUBMENU['Sub 1']= TOPMENU.add_submenu('Sub 1')
              end
              @sub.add_item('Item B') { # code here }
          
            end # submodule for PluginB
          
          end
          

          I'm not here much anymore.

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

            Although this should work.. because of current API bugs. It will not.

            See thread: http://sketchucation.com/forums/viewtopic.php?f=180&t=49912&p=449979#p449362

            I'm not here much anymore.

            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