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!
    đź«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    can you update it like this?

    Scheduled Pinned Locked Moved Plugins
    1 Posts 1 Posters 34 Views 1 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.
    • designerbursaD Offline
      designerbursa
      last edited by

      Re: [Plugin] Recall last tool v1.2

      can you update it like this?

      code_text
      module Matt
        class MattObserver < Sketchup::ToolsObserver
          @@last_tool_id = nil
          @@toggle = true  # Variable to control toggling
      
          def onActiveToolChanged(tools, tool_name, tool_id)
            # Save the tool ID if it’s not one of the excluded IDs
            @@last_tool_id = tool_id unless [21022, 10508].include?(tool_id) || tool_id >= 50000
            puts "Active tool: #{tool_name} --> ID: #{tool_id}" unless [21022, 10508].include?(tool_id) || tool_id >= 50000
          end
      
          def self.recall_last
            # Get the ID of the currently active tool
            active_tool = Sketchup.active_model.tools.active_tool_id
      
            # If the active tool is the selection tool and there's no other active tool, switch to the last tool
            if [0, 21022].include?(active_tool)
              if @@last_tool_id
                Sketchup.send_action(@@last_tool_id)
              else
                puts "No previous tool. Selecting default tool."
                Sketchup.send_action("selectSelectionTool:")
              end
            else
              # If another tool is active, switch to the selection tool
              Sketchup.send_action("selectSelectionTool:")
            end
          end
        end
      
        # Add the observer to SketchUp's tools
        Sketchup.active_model.tools.add_observer(MattObserver.new)
      
        # Add "ReCall" menu item
        unless file_loaded?(__FILE__)
          menu = UI.menu("Plugins")  # Adds item under the "Plugins" menu
          menu.add_item("ReCall") {
            MattObserver.recall_last  # Calls the recall_last method when clicked
          }
          file_loaded(__FILE__)
        end
      end
      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