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!
    Mac User? | Join the Rayscaper Beta for Mac Learn More

    [Plugin] Recall last tool v1.2

    Scheduled Pinned Locked Moved Plugins
    60 Posts 28 Posters 66.0k Views 28 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.
    • R
      RickW
      last edited by

      Matt,

      Nice work. My suggestion would be to use class variables (@@Matt_Model_Toolid, @@Matt_Model_Toolid2) or instance variables (@Matt_Model_Toolid, @Matt_Model_Toolid2) rather than global variables. Note that class variables must be declared right after the class is declared:

      	class Matt_Observer < Sketchup;;ToolsObserver
      		@@Matt_Model_Toolid = nil
      		@@Matt_Model_Toolid2 = nil
      		def onActiveToolChanged (tools_object, toolname, toolid)
      			# ETC...
      
      

      but instance variables can be delcared anywhere in the class methods.

      RickW
      www.smustard.com

      1 Reply Last reply
      Reply Quote 0
      • M
        Matt666
        last edited by

        Hi Rick!
        Thank you for the comment, I've updated the code... ๐Ÿ˜‰

        Frenglish at its best !
        My scripts

        1 Reply Last reply
        Reply Quote 0
        • EarthMoverE
          EarthMover
          last edited by

          Hey Matt - You are eternally my friend! Thanks for listening to my request. I'm sure it will be useful to many!

          3D Artist at Clearstory 3D Imaging
          Guide Tool at Winning With Sketchup
          Content Creator at Skapeup

          1 Reply Last reply
          Reply Quote 0
          • M
            Matt666
            last edited by

            ๐Ÿ˜‰

            Frenglish at its best !
            My scripts

            1 Reply Last reply
            Reply Quote 0
            • pilouP
              pilou
              last edited by

              Astucieux! ๐Ÿ˜Ž

              Frenchy Pilou
              Is beautiful that please without concept!
              My Little site :)

              1 Reply Last reply
              Reply Quote 0
              • M
                Matt666
                last edited by

                Merci Pilou ๐Ÿ˜‰

                Frenglish at its best !
                My scripts

                1 Reply Last reply
                Reply Quote 0
                • EdsonE
                  Edson
                  last edited by

                  matt,

                  here we go again. unless i do not know how to use your new script, it is not working on mac! sorry...

                  edson mahfuz, architect| porto alegre โ€ข brasil
                  http://www.mahfuz.arq.br

                  1 Reply Last reply
                  Reply Quote 0
                  • M
                    Matt666
                    last edited by

                    Hi Edson... I hope you do not know!! I'm cursed...

                    So : Draw a . Draw a . Press space bar for .
                    Go to Plugins/Recall last tool. Rectangle tool is now recalled.

                    If it does not work, can you open your ruby console, and try again, please?
                    And, at last, can you call rectangle tool, and try to copy this code in the ruby console ?

                    Sketchup.send_action(21022)
                    

                    This code calls selection tool.
                    Thank you Edson. And sorry for the inconvenience.

                    Frenglish at its best !
                    My scripts

                    1 Reply Last reply
                    Reply Quote 0
                    • EdsonE
                      Edson
                      last edited by

                      matt,

                      it did not work. i had done it that way before. below is the ruby console reading.

                      glad to help you. keep your requests coming.


                      Picture 29.png

                      edson mahfuz, architect| porto alegre โ€ข brasil
                      http://www.mahfuz.arq.br

                      1 Reply Last reply
                      Reply Quote 0
                      • BurkhardB
                        Burkhard
                        last edited by

                        I read a lot /users/mahfuz... ๐Ÿ˜‰

                        http://www.ia-plus.de

                        1 Reply Last reply
                        Reply Quote 0
                        • P
                          pecan
                          last edited by

                          @matt666 said:

                          Hi Edson... I hope you do not know!! I'm cursed...

                          Sketchup.send_action(21022)
                          

                          This code calls selection tool.

                          Thank you Edson. And sorry for the inconvenience.

                          On differenct OS's, even the same OS with different menus, that magic number will have changed.

                          What's wrong with Sketchup.send_action(selectSelectionTool:);

                          When the menu structure is updated, then the call will still work even tho the menu id has changed.

                          1 Reply Last reply
                          Reply Quote 0
                          • simon le bonS
                            simon le bon
                            last edited by

                            Bravo Matt !!
                            at the very beginning of my learning SketchUp, I was surprised not to have this feature at disposal. And then I was accustomed to always recall my tools. And Here comes your ruby. It is as if suddenly we had won a great lightness. (F2 is great)

                            it already belongs to my toolbox. ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ˜„simon

                            1 Reply Last reply
                            Reply Quote 0
                            • M
                              Matt666
                              last edited by

                              Merci Simon ! ๐Ÿ˜‰

                              @pecan said:

                              On different OS's, even the same OS with different menus, that magic number will have changed.
                              Hi pecan! Are you sure of that? I use only two different numbers in my code. The rest is a recall of the last number used.
                              But there's a biiig problem with Mac... On Mac, function "send_action" does not accept integers. Only strings! ๐Ÿ˜ž

                              @edson said:

                              It did not work. i had done it that way before. below is the ruby console reading.
                              Thank you Edson!
                              Ouch. I will try to find a solution. Can you test this code below, please?

                              Sketchup.send_action("21022")
                              

                              Frenglish at its best !
                              My scripts

                              1 Reply Last reply
                              Reply Quote 0
                              • EdsonE
                                Edson
                                last edited by

                                it looks good!


                                Picture 30.png

                                edson mahfuz, architect| porto alegre โ€ข brasil
                                http://www.mahfuz.arq.br

                                1 Reply Last reply
                                Reply Quote 0
                                • M
                                  Matt666
                                  last edited by

                                  Ok. But if you have rectangle tool called, when you copy and validate the code, is the selection tool activated?

                                  Frenglish at its best !
                                  My scripts

                                  1 Reply Last reply
                                  Reply Quote 0
                                  • EdsonE
                                    Edson
                                    last edited by

                                    i drew a rectangle, then pressed the space bar, then used the script from the menu. the result is in the picture.


                                    Picture 31.png

                                    edson mahfuz, architect| porto alegre โ€ข brasil
                                    http://www.mahfuz.arq.br

                                    1 Reply Last reply
                                    Reply Quote 0
                                    • M
                                      Matt666
                                      last edited by

                                      Sorry Edson, and all mac users. But I can't do anything with this bug. ๐Ÿ˜ž Function 'send_action' doesn't accept integers (so tool IDs) on Mac.

                                      Frenglish at its best !
                                      My scripts

                                      1 Reply Last reply
                                      Reply Quote 0
                                      • P
                                        pecan
                                        last edited by

                                        Result from SU ruby console

                                        (eval)
                                        result = Sketchup.send_action "selectSelectionTool:"
                                        true

                                        I was in error suggesting it was a num.

                                        1 Reply Last reply
                                        Reply Quote 0
                                        • P
                                          pecan
                                          last edited by

                                          Using the tool name should work:

                                          
                                          def onActiveToolChanged (tools_object, toolname, toolid)
                                                  print tools_object, toolname, toolid
                                          		@@Matt_Model_Toolid = @@Matt_Model_Toolid2 if @@Matt_Model_Toolid2
                                          		#@@Matt_Model_Toolid2 = toolid if not([21022,10508].index toolid)
                                          		@@Matt_Model_Toolid2 = "select#{toolname};";
                                          		puts "1; #{@@Matt_Model_Toolid} 2; #{@@Matt_Model_Toolid2}"
                                          	end
                                          
                                          
                                          1 Reply Last reply
                                          Reply Quote 0
                                          • P
                                            pecan
                                            last edited by

                                            @pecan said:

                                            Using the tool name should work:

                                            
                                            > def onActiveToolChanged (tools_object, toolname, toolid)
                                            >         print tools_object, toolname, toolid
                                            > 		@@Matt_Model_Toolid = @@Matt_Model_Toolid2 if @@Matt_Model_Toolid2
                                            > 		#@@Matt_Model_Toolid2 = toolid if not([21022,10508].index toolid)
                                            > 		@@Matt_Model_Toolid2 = "select#{toolname};";
                                            > 		puts "1; #{@@Matt_Model_Toolid} 2; #{@@Matt_Model_Toolid2}"
                                            > 	end
                                            > 
                                            

                                            Well... almost.

                                            "selectCameraOrbitTool:" doesnt work.
                                            It's action name is simply OrbitTool.
                                            So maybe a hash of returned tool names and the send_action name.

                                            sendActionToolName = {"CameraOrbitTool", "OrbitTool", } etc.
                                            Or maybe a hash of just the exceptions.

                                            Its a shame SU has to be so inconsistent.

                                            1 Reply Last reply
                                            Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better ๐Ÿ’—

                                            Register Login
                                            • 1
                                            • 2
                                            • 3
                                            • 1 / 3
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement