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!
🚨 Skimp | 25% Off until March 30 Buy Now
can you update it like this?
-
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
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 LoginAdvertisement