sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    When do Tools.active_tool_id return 0 ?

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 918 Views 3 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

      http://code.google.com/apis/sketchup/docs/ourdoc/tools.html#active_tool_name

      @unknownuser said:

      Tools.active_tool_name
      The active_tool_name method is used to retrieve the active tool's name.

      NOTE: Calling active_tool_name on an empty Tools collection might cause a crash. Before calling this method, it is important to check whether or not the Tools collection is empty. The Tools collection is empty if the method .active_tool_id returns zero.

      Under what scenario does Tool.active_tool_id return 0 ?

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

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        Two I know of offhand:

        (1) Just after Sketchup starts, there is only 1 tool on the stack. If a script uses Tools.pop_tool the Tools.active_tool_id should return 0. This is the scenario that led me to first report the Tools.active_tool_name BugSplat! bug in the beta forum.

        (2) The SetNorth native tool is bugged in that it does not properly reset the previous tool on the stack when it completes. So the active_tood_id() is 0 and calling active_tool_name() causes a BugSplat! (This is why I had to patch Jim's old version of the CustomToolbars.)

        I "think" I noticed a few other situations when using some feature (like a dialog,) but can't remember.
        I would suggest implementing a messagebox in a ToolsObserver that pops up anytime active_tool_id is 0, so we can compile a better list.

        I'm not here much anymore.

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

          pop_tool can pop tools off the stack that wheren't pushed?

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

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            @thomthom said:

            pop_tool can pop tools off the stack that wheren't pushed?

            Yes... from my reproduce steps in Bug Report SU-0493:

            ` %(#0000BF)[1) Start SU (the SketchTool is active.)
            2) open the Console, and type:
            3) Sketchup.active_model.tools.pop_tool

            • at this point the Sketchup::Tools collection is empty
            1. in the Console, and type:
              Sketchup.active_model.tools.active_tool_name
              ... and SPLAT!

            Note, that at this point, if you instead type:
            Sketchup.active_model.tools.active_tool_id

            0 is returned]`

            Simone has proposed that the active_tool_name() method be fixed to return an empty string when active_tool_id() retruns 0. (internal bug 3424904)

            I also proposed an query method in that report:

            class Sketchup;;Tools
            
              def empty?
                return self.active_tool_id==0
              end
            
            end
            
            

            AND that module Enumerable be mixed into class Sketchup::Tools
            (I tried it myself on the Ruby-side, but was not successful, perhaps because it's a C++ collection.) I noted that there was no way to get the size of a tools instance.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • fredo6F Offline
              fredo6
              last edited by

              By the way, it seems that, on MAC, active_tool_name may return a truncated text (for instance "ctionTool" for SelectionTool, or "angle" for Rectangle).

              Fredo

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @unknownuser said:

                By the way, it seems that, on MAC, active_tool_name may return a truncated text (for instance "ctionTool" for SelectionTool, or "angle" for Rectangle).

                Yes... this is the reason we are treating this issue. We need to use the tool_id rather than the tool_name to work around the Mac bug.

                In SU8 Google did fix the Mac tool name bug for the ToolsObserver, but forgot to fix the Tools collection active_tool_name() method.

                I'm not here much anymore.

                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