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

    Accessing submenus / extension manager

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 5 Posters 5.9k Views 5 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.
    • A Offline
      azuby
      last edited by

      Hi folks,

      maybe my question will go to /dev/null when the old Sketchup forum moves, I ask my question here again: I need to access submenus to create an extension manager to organize Ruby scripts and make programming them more easy. I do ask this question, because of the high dynamic behaviour of UI.menu - it returns new objects when you call it for the same string. But when I want to organize scripts, I have to remember menus, submenus and subsub... to put the extensions to the right place. That does not work at the moment, because I had to modify some built-in methods and stay deal with outdated menu objects. I can't use the old UI#add_submenu, because this method is very stupid and adds anything it gets - so this method is the reason for doublettes within the menu structure.

      Also see:
      http://errorinitus.de/?sect=software (extensionmanager)
      Dead link
      Dead link
      Dead link

      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
      • J Offline
        Jim
        last edited by

        What about using a WebDialog? The thought has been brewing in the back of my mind for awhile about a WebDialog based Add-In Manager.

        Have a look at this menu example for a possible idea: http://www.zzee.com/art-html-listing/samples/apache/jsmenuVer.html

        Edit: On second thought, this might not work so well.

        What you want to do is difficult, otherwise it'd be done already 😄

        Hi

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

          Thanks for the idea. It would be possible using webdialogs for extensions. The HTML source needs to be auto-genereated in this case - that's not a big deal. But the disadvantage of this is, that by using a webdialog-extensionmanager two types of extensions will be create: the regular ones for the Sketchup menus and the other ones for the webdialog. I guess, a lot of extensionmanager-hacking could start when using webdialogs 😉

          Look the first link I posted - a nearly working version of the extensionmanager is ready. The only big problem is the described one.

          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

            I've added an example on how easy it is to write/reconstruct Ruby Sketchup extension to use with the extensionmanager. For that I have modified a copy of the Dome script (dome.rb) - actually documented in German (in a PDF), but the code (in PDF an .rb files) should be readable for any extension developer.

            You can download it under the extensionmanager category on http://errorinitus.de/?sect=software

            If the extensionmanager becomes older, there maybe is the work to define categories and sub-categories the extension should be set to. Actually I use the categories from the organizer.rb.

            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
            • R Offline
              RickW
              last edited by

              I wrote a pair of ruby scripts that automatically rewrote the menu section of every script in the plugins folder (except for the utility scripts from SU) and then allowed users to organize their scripts into subfolders. It was temporarily available at http://www.smustard.com

              One downfall was that double-clicking a file in the browser caused the scripts to not load. There might be a way around that now.

              Another problem was that a few scripts couldn't be rewritten by the rewrite script because of strange formatting by the authors.

              RickW
              [www.smustard.com](http://www.smustard.com)

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

                Hi Rick,

                I think you're talking about the organizer.rb also Burkhard supported? I find it very useful. My idea was constistency in the Plugins menu of all users. That had to be done by hand, because @Last/Google does not provide a good Plugin mechanism. Also organizer.rb works with a categorization like my approach.

                Maybe the Google guys are so nice adding a "Menu#submenus[]" or "Menu#parent" to the Menu class. That would simplify the problem. Than the only thing to manage would be to tetermine the categories and subcategories, the rest works automatically (with internationalization 😄 ). Do you know the person I have to contact for this request?

                We would have some advantages of using a kind of my approach:

                • consistency
                • no dublicates in the menus
                • Ruby programmers can write their code with own code style
                • developing extensions gets more simple
                • internationalization
                • Ruby extensions build "the old way" also would work
                • real Sketchup extensions, which you can switch on and off in the preferences

                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
                • BurkhardB Offline
                  Burkhard
                  last edited by

                  @Rick
                  you've found a solution running the script with SU6?
                  Btw. where on smustard is it? There is no organizer script with that name.

                  [http://www.ia-plus.de(http://www.ia-plus.de)]

                  1 Reply Last reply Reply Quote 0
                  • R Offline
                    RickW
                    last edited by

                    Burkhard,

                    Yes, I fixed it last night and just sent it to you. There were a few reasons (like I mentioned above) that I took it off of Smustard, but am considering putting it back up.

                    RickW
                    [www.smustard.com](http://www.smustard.com)

                    1 Reply Last reply Reply Quote 0
                    • jujuJ Offline
                      juju
                      last edited by

                      RickW, please let us know here at the forum if / when you make the revised script available as well as where.

                      Save the Earth, it's the only planet with chocolate.

                      1 Reply Last reply Reply Quote 0
                      • R Offline
                        RickW
                        last edited by

                        Juju,

                        Will do 😄

                        RickW
                        [www.smustard.com](http://www.smustard.com)

                        1 Reply Last reply Reply Quote 0
                        • J Offline
                          Jim
                          last edited by

                          azuby,

                          I came up with this code. It stores the menu object in a Hash on creation. But it doesn't work for the reasons you stated.

                          
                          class Sketchup;;Menu
                             @@submenus = {}
                             alias ;old_add_submenu ;add_submenu
                             def add_submenu(name)
                                @@submenus[name] = old_add_submenu(name)
                             end
                             def self.submenus
                                @@submenus
                             end
                          end
                          
                          

                          Well, it builds the hash correctly, and you can access the sub menus by name:

                          
                          Sketchup;;Menu.submenus["SomeName"].add_item("Say Hi") { UI.messagebox("Hi!") }
                          
                          

                          The above example does not work. It give no error, but it doesn't add the menu item either. Too bad as it would then be dead simple to hijack the add_submenu and add_item methods to create the menu tree, and no script would need changed to fit into a certain category.

                          Hi

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

                            Yes Jim, I know that. If you go into the sources of the extensionmanager (mentioned in the first posting, first link - don't panic allthough it's a german website 😉 ), it is already done - a bit more complicated, because you have to remember the submenus for their parent menu, not all in the Menu object (you could have two "Preferences" menus coming from twot extensions). Thank you very much for verifying my problem.

                            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

                              Isn't this strange:

                              UI.menu().add_submenu '(none)'
                              #<Sketchup;;Menu;0x1fba478>  # => '(none)' in Plugins
                              UI.menu("Plugouts").add_submenu 'Plugouts'
                              #<Sketchup;;Menu;0xfbef4c0>  # => 'Plugouts' in Plugins
                              UI.menu("P").add_submenu 'P'
                              #<Sketchup;;Menu;0xfba8c90> # => 'P' in Plugins
                              UI.menu("p").add_submenu 'p'
                              #<Sketchup;;Menu;0x102da520> # => 'p' in Plugins
                              UI.menu("pong").add_submenu 'pong'
                              #<Sketchup;;Menu;0x102abb70>  # => 'pong' in Plugins
                              UI.menu("Olugins").add_submenu 'Olugins'
                              Exception `ArgumentError' at (eval);475 - Unknown menu olugins
                              Exception `ArgumentError' at (eval);475 - (eval);475;in `menu'; Unknown menu olugins
                              Error; #<ArgumentError; (eval);475;in `menu'; Unknown menu olugins>
                              (eval);475
                              UI.menu("asdf").add_submenu 'asdf'
                              Exception `ArgumentError' at (eval);475 - Unknown menu asdf
                              Exception `ArgumentError' at (eval);475 - (eval);475;in `menu'; Unknown menu asdf
                              Error; #<ArgumentError; (eval);475;in `menu'; Unknown menu asdf>
                              (eval);475
                              

                              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
                              • J Offline
                                Jim
                                last edited by

                                
                                ("a".."z").each { |l| 
                                begin
                                print "Trying #{l};"
                                UI.menu(l).add_submenu('jim')
                                puts "OK"
                                rescue
                                puts "Error on #{l}."
                                end
                                }
                                
                                

                                I don't like the "code" font, by the way; it's hard to read.

                                Hi

                                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