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

    OnActiveToolChanged - What RubyTool is it?

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 5 Posters 432 Views 5 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.
    • thomthomT Offline
      thomthom
      last edited by

      I noticed that onActiveToolChanged returns "RubyTool" as the toolname whenever a ruby scripted tool is used. I had expected it to be the classname of the tool which was returned.
      Any way to identify which ruby tool is being used?

      Thomas Thomassen β€” SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Does it respond to .class?

        Hi

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          The tool_name argument returns a string with the tool name, not the tool class itself. So doing .class only returns the String class.

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • A Offline
            avariant
            last edited by

            I think some of the built in tools, like the line tool, return a more specific name. But a lot of them are generic. I suspect that Ruby Tool is a default name that tools can override but seldom do (though I do see any method for that in the API).

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              Yea, I can differ from the built-in tools. But with the large flora of great plugin tools it'd be nice to be able to detect these as well.

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

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

                Whenever I want the name of the active tool, I use:

                Sketchup.active_model.tools.active_tool_name
                

                I've never had "RubyTool" returned as a tool name. Does that work for you?

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

                  I was mistaken. Custom tools are always "RubyTool", no matter what you do. Yes, that's very strange.

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

                    You can identify active tool by its ID. Each tool has its own ID. You can't know its name. Try a look here, I played with tool IDs...
                    πŸ˜‰

                    Frenglish at its best !
                    My scripts

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      @matt666 said:

                      You can identify active tool by its ID. Each tool has its own ID. You can't know its name. Try a look here, I played with tool IDs...
                      πŸ˜‰

                      But is the id the same across sessions and computers? From my other thread on IDs; the ID of even the native tools might not be consistent. So I have4 mu doubts that ruby tools will have consistent IDs

                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      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