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

    [Plugin] Recall last tool v1.2

    Scheduled Pinned Locked Moved Plugins
    60 Posts 28 Posters 59.5k 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.
    • M Offline
      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 Offline
        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 Offline
          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 Offline
            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 Offline
              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 Offline
                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
                • P Offline
                  pecan
                  last edited by

                  Here's a list of the send_actions and the actual tool name returned by the observer.

                  howRubyPanel;
                  viewBack;
                  viewBottom;
                  viewFront;
                  viewIso;
                  viewLeft;
                  viewRight;
                  viewTop;
                  viewPerspective;
                  viewShowAxes;
                  viewShowHidden;
                  viewZoomExtents;
                  viewZoomToSelection;
                  viewUndo;
                  selectOrbitTool; (CameraOrbitTool)
                      ok  selectPositionCameraTool;
                  selectDollyTool; (CameraDollyTool
                  selectTurnTool;
                  selectWalkTool; (CameraWalkTool)
                  selectZoomTool; (CameraZoomTool)
                  selectFieldOfViewTool; (CameraFOVTool) <=== inconsistency
                  selectZoomWindowTool; (CameraZoomWindowTool)
                  pageAdd;
                  pageDelete;
                  pageUpdate;
                  pageNext;
                  pagePrevious;
                  renderWireframe;
                  renderHiddenLine;
                  renderMonochrome&#058;
                  renderShaded;
                  renderTextures;
                      ok  selectArcTool;
                  selectAxisTool; (SketchCSTool)
                      ok  selectCircleTool;
                      ok selectEraseTool;
                      ok  selectFreehandTool;
                  selectLineTool; (SketchTool)
                      ok  selectMeasureTool;
                      ok  selectMoveTool;
                      ok  selectOffsetTool;
                      ok  selectPaintTool;
                  selectPolygonTool; (PolyTool)
                      ok  selectProtractorTool;
                      ok  selectPushPullTool;
                      ok  selectRectangleTool;
                      ok  selectRotateTool;
                      ok  selectScaleTool;
                      ok  selectSectionPlaneTool;
                      ok  selectTextTool;
                      ok  selectDimensionTool;
                      ok  selectExtrudeTool;
                      ok  selectSelectionTool;
                  editUndo;
                  editRedo;
                  editHide;
                  editUnhide;
                  fixNonPlanarFaces;
                  
                  axes is returning SketchCSTool
                  3d text is returning 3DTextTool
                  plugins return RubyTool
                  orbit return CameraOrbitTool
                  pan returns CameraDollyTool
                  zoom returns CameraZoomTool
                  field of view returns CameraFDVTool
                  zoom window returns CameraFOVTool
                  zoom extends return CameraZoomWindowTool
                  walk return CamerWalkTool
                  look returns CameraPanTool
                  line returns selectSketchTool
                  
                  

                  Except for "selectFieldOfViewTool: (CameraFOVTool)" you can remove "Camera" from the observer reported name and prefix "select".
                  Special cases are PolyTool, Line tool, and axis tool.

                  On second thought, a hash like {reportedObserverName, sendSelectName} might be the best bet.

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

                    The following seems to work, and you can add to the exceptions hash when you find 'em.

                    Hope this helps some...

                    
                    # Supports Organizer.rb
                    =begin
                    Copyright 2009, Matt
                    All Rights Reserved
                    
                    THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION,
                    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                    
                    License;   Free
                    
                    Author;     	Matthieu NOBLET
                    Organization;   Matt
                    Name;      		Recall_lst_tool
                    Version;   		1.0
                    SU Version;   	6 and 7
                    Date;      		17/02/2009
                    Description;   	Recall last tool used
                    Usage;      	If you want to have a shortcut, please try with native Sketchup shortcuts...
                    History;
                    	1.000   17/02/2009
                    			First version
                    
                    	1.100	17/02/2009
                    			Global variables replaced by Class variables
                    =end
                    
                    require 'sketchup.rb'
                    
                    class Matt_Observer < Sketchup;;ToolsObserver
                        def initialize
                            @ToolExceptionsHash = {
                               # observerName    send_actionName
                                "FOVTool",       "FieldOfViewTool",
                                "SketchCSTool",  "AxisTool",
                                "SketchTool",    "LineTool",
                                "PolyTool",      "PolygonTool"
                            }
                        end
                    	@@Matt_Model_Toolid = nil
                    	@@Matt_Model_Toolid2 = nil
                    	def onActiveToolChanged (tools_object, toolname, toolid)
                            print tools_object, " ", toolname, " ", toolid, "\n"
                            tname = toolname;
                    		@@Matt_Model_Toolid = @@Matt_Model_Toolid2 if @@Matt_Model_Toolid2
                    		# remove "Camera" prefix reported by ToolObserver"
                    		@@Matt_Model_Toolid2 = (tname[0,6]="" if (tname[0,6] == "Camera"));
                    		tname = @ToolExceptionsHash.fetch(tname, tname);
                    		@@Matt_Model_Toolid2 = "select#{tname};";
                    		puts "1; #{@@Matt_Model_Toolid} 2; #{@@Matt_Model_Toolid2}"
                    	end
                    	def self.recall_last
                            puts "sending action #{@@Matt_Model_Toolid}" if @@Matt_Model_Toolid
                    		return Sketchup.send_action(@@Matt_Model_Toolid) if @@Matt_Model_Toolid
                    		return Sketchup.send_action("selectSelectionTool;")
                    	end
                    end
                    
                    unless file_loaded?(__FILE__)
                       file_loaded(__FILE__)
                       Sketchup.active_model.tools.add_observer(Matt_Observer.new)
                       $submenu ? (organizer = $submenu) ; (organizer = UI.menu("Plugins"))
                       organizer.add_item("Recall last tool"){ Matt_Observer.recall_last }
                    end
                    
                    
                    
                    1 Reply Last reply Reply Quote 0
                    • M Offline
                      Matt666
                      last edited by

                      Hi pecan!
                      Sorry, I didn"t test your plugin, but I think it doesn't work with plugins. So Non native tools...
                      I will test it! Thank you for that Pecan!

                      Frenglish at its best !
                      My scripts

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

                        Hi Pecan! Your method does not work with ruby tools, as expected...
                        A new version has been posted in the first post. It fixes a bug found by Simon Le Bon. Thank you Simon!

                        Frenglish at its best !
                        My scripts

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

                          Hi Matt,
                          Hip Hip! I've just installed your plug v 1.2 and it seems working very well (all tools are seemingly supported)! So cool!!
                          It's too young to see if it remain operative on duration, but i believe this is now fixed.

                          Many thanks for that tool dear Matt 👍 😄

                          I take it!
                          http://i274.photobucket.com/albums/jj245/Spendauballet/Tampon/gull.gif

                          simon.

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

                            @matt666 said:

                            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.

                            would the last update make it usable in macs?

                            edson mahfuz, architect| porto alegre • brasil
                            http://www.mahfuz.arq.br

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

                              @unknownuser said:

                              I take it!
                              👍

                              @unknownuser said:

                              would the last update make it usable in macs?
                              ... Dear Edson... I'm so sorry! 😞 You (and all Mac users!)have some problems with many of my scripts... Included this one...
                              I can't be usable in mac. Mac has a bug with main function used in this script: Sketchup.send_action(ToolID). And I can't do anything.
                              Sorry again Edson... 😳

                              Frenglish at its best !
                              My scripts

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

                                matt,

                                no problem. several other plugins you created work without problems. let's hope this bug gets solved in the future.

                                edson mahfuz, architect| porto alegre • brasil
                                http://www.mahfuz.arq.br

                                1 Reply Last reply Reply Quote 0
                                • plot-parisP Offline
                                  plot-paris
                                  last edited by

                                  great plugin, Matthieu. 👍

                                  just a thought: does it make sense to have a similar tool go through several previously used tools when pressing the shortcut key repeatedly?

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

                                    Hi plot_paris!

                                    That's a good idea... I will give a try! I think we may go through 10 previously used tools, and may undo history (retrun to the last tool used) by activating selection tool.

                                    Frenglish at its best !
                                    My scripts

                                    1 Reply Last reply Reply Quote 0
                                    • Chris FullmerC Offline
                                      Chris Fullmer
                                      last edited by

                                      Hey, I was just thinking about a plugin that would cycle through tools on repeated pressing of a button.

                                      So assign it to the spacebar. Hit the spacebar once and its select. Twice it move, 3 is rotate. But I quickly decided against the silly plugin when I started thinking about having to hit the spacebar 26 times to get to "place camera" or something 😆

                                      But in this context, I think it is quite a good idea,

                                      Chris

                                      Lately you've been tan, suspicious for the winter.
                                      All my Plugins I've written

                                      1 Reply Last reply Reply Quote 0
                                      • plot-parisP Offline
                                        plot-paris
                                        last edited by

                                        another idea, although probably not managable with ruby, is a much more graphical approach:

                                        when you hold down the space bar, a ring with tool buttons appears around your cursor in a circular fashion. you can now left click any button to get the tool. or you can simply turn the scroll wheel to file through them, either clockwise or counterclockwise. by default the selection tool is highlighted - so if you just press the space bar once, you get the select tool.

                                        you can easily customise this tool-circle by holding down the space bar and then dragging unwanted tools out of the circle and vice versa.

                                        well, maybe Google comes up with soemthing similar in the next release 😄

                                        1 Reply Last reply Reply Quote 0
                                        • juan974J Offline
                                          juan974
                                          last edited by

                                          Merci MATT ...

                                          juan974 (Réunion island)
                                          website : http://sketchucation.com/click.php?url=http://www.tarn.us

                                          1 Reply Last reply Reply Quote 0
                                          • B Offline
                                            bitsnbites
                                            last edited by

                                            Thank you very much, Matt666.
                                            That´s the Plugin i was lookin for.

                                            thx a lot

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 2 / 3
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement