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

    Contents Menu to other menu locations

    Scheduled Pinned Locked Moved Plugins
    10 Posts 4 Posters 341 Views 4 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.
    • kenK Offline
      ken
      last edited by

      Question is it possible to move any or all context menu plugins to another menu, i.e. Tools or Edit? Seems I am getting to many context menu items and I would like to move some of the plugins to either tools or edit. Are context menu plugins stuck in the context menu selection?

      Ken

      Fight like your the third monkey on Noah's Ark gangway.

      1 Reply Last reply Reply Quote 0
      • GaieusG Offline
        Gaieus
        last edited by

        I guess it would be possible. The code where a menu item should appear is generally somewhere at the end of the scripts (AFAIK).
        Not that I could (probably) modify one successfully... πŸ˜’

        Gai...

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          Yes.
          BUT you need to rewrite the context-menu code...
          For example [made up!]...

          UI.add_context_menu_handler do |menu|
            menu.add_item("Edges from Guide Lines"){xLine2Line()}
          end
          

          would become something like

          UI.menu("Plugins").add_item("Edges from Guide Lines"){xLine2Line()}
          

          TIG

          1 Reply Last reply Reply Quote 0
          • kenK Offline
            ken
            last edited by

            Thanks TIG

            Now what I want to know is how did you guess the line_converter.rb is the very plugin that I wish to change.

            And another question, is there any reason beyond just making it easy to select something and have a context menu pop up, or are there programing restraints that require the context menu.

            I would prefer that no other context menu be written since Sketchup seems to have trouble handling these plugins.

            Again thank you TIG

            Ken

            Fight like your the third monkey on Noah's Ark gangway.

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              @unknownuser said:

              Thanks TIG

              Now what I want to know is how did you guess the line_converter.rb is the very plugin that I wish to change.

              And another question, is there any reason beyond just making it easy to select something and have a context menu pop up, or are there programing restraints that require the context menu.

              I would prefer that no other context menu be written since Sketchup seems to have trouble handling these plugins.

              Again thank you TIG

              Ken

              The code that sets the menu is usually at the end of the script [some, like thomthom are perverse and put it at the start!] Do a 'find' on the script's text for 'menu' or 'context'... that's the code you need to adjust...
              Context menus that are properly st up work fine - they only appear when a specific set of circumstances coincide - e.g. SectionCutFace only appears in the context-menu when you have a one item selection containing a SectionPlane... Sometimes context-menus are used when they are NOT necessary... πŸ˜’

              TIG

              1 Reply Last reply Reply Quote 0
              • kenK Offline
                ken
                last edited by

                TIG

                I my studies of Ruby for Sketchup, I have no problem with finding the context menu, it just seems to me there is always an "if then" statement, proceeding the menu add statement, and I don't see on this the other menus. There are some plugins that appear in more than one menu, and I usually turn off the context menu, and move the plugin to an other memu selection where I wish to have the plugin appear. However, I have not been able to master the coding to get rid of just a context menu with the "if selection is.....".

                Anyway, I will keep trying.

                Thank

                Ken

                Fight like your the third monkey on Noah's Ark gangway.

                1 Reply Last reply Reply Quote 0
                • TIGT Offline
                  TIG Moderator
                  last edited by

                  @unknownuser said:

                  TIG

                  I my studies of Ruby for Sketchup, I have no problem with finding the context menu, it just seems to me there is always an "if then" statement, proceeding the menu add statement, and I don't see on this the other menus. There are some plugins that appear in more than one menu, and I usually turn off the context menu, and move the plugin to an other memu selection where I wish to have the plugin appear. However, I have not been able to master the coding to get rid of just a context menu with the "if selection is.....".

                  Anyway, I will keep trying.

                  Thank

                  Ken

                  The code pseudo-code...
                  if this is not loaded then load it [i.e. make menu items etc] end Now it's loaded
                  code is there to ensure the menu only loads once even if the script is re-loaded...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • kenK Offline
                    ken
                    last edited by

                    TIG

                    If was more of this type of code. Note, I have tried to remove context menu and add this to the Tools menu. So far, haven't had it to work. However, I am still working on it. What I was wondering, if the two line are required to make sure I that I have picked either a line or xline. Still working on it.

                    if( not file_loaded?("xLine.rb") )
                    UI.add_context_menu_handler do |menu|
                    if xLine_validate_selection [b]###THIS LINE RIGHT HERE[/b]
                    menu.add_separator
                    menu.add_item("Convert lines to guide lines") { xLine }
                    end
                    if line_validate_selection [b]### AND THIS LINE[/b]
                    menu.add_separator
                    menu.add_item("Convert guide lines to lines") { xLine2Line }
                    end
                    end

                    Fight like your the third monkey on Noah's Ark gangway.

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      The file_loaded part checks if the file was already loaded,
                      The if xLine_validate_selection part is a check to see if the selection includes suitable entities.
                      If you put a # in front of the 'if' and also in front of its final 'end' then that check is disabled.
                      Alternatively, add a line into the def xLine_validate_selection to return true always...
                      SO on the line immediately after the 'if' line add return true and then the rest of the checking code is ignored anyway....

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • K Offline
                        kyyu
                        last edited by

                        @unknownuser said:

                        TIG

                        I my studies of Ruby for Sketchup, I have no problem with finding the context menu, it just seems to me there is always an "if then" statement, proceeding the menu add statement, and I don't see on this the other menus. There are some plugins that appear in more than one menu, and I usually turn off the context menu, and move the plugin to an other memu selection where I wish to have the plugin appear. However, I have not been able to master the coding to get rid of just a context menu with the "if selection is.....".

                        Anyway, I will keep trying.

                        Thank

                        Ken

                        You could write a intermediate method to do the check. If ok, it runs the plugin. If not valid, then it pop up an error message:

                        def xLine_check_valid
                        	if xLine_validate_selection
                        		xLine
                        	else
                        		UI.messagebox "Invalid selection"
                        	end
                        end
                        
                        if( not file_loaded?("xLine.rb") )
                        	UI.menu("Plugins").add_item("Convert lines to guide lines"){xLine_check_valid}
                        end
                        
                        file_loaded("xLine.rb")
                        
                        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