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

    Script and custom tool work together ?

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 293 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.
    • Didier BurD Offline
      Didier Bur
      last edited by

      Hi,
      Is this possible ?

      1. Start a script execution
      2. Pause the script and launch a custom tool (such as a "getpoint" tool for instance and return the clicked Point3D)
      3. Resume the main script and use the Point3D variable.
      
      #start script
      #...
      point=Sketchup.active_model.select_tool MyGetPointTool.new
      #...
      # resume script
      
      

      The problem is that if it is not possible, one has to encapsulate all the script in the tool itself.

      Any hint someone ❓

      DB

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

        Pretty sure you can't pause it.

        You don't have to encapsulate the entire script into the Tool class, just make the Tool's deactivate event trigger your main script again.

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

        1 Reply Last reply Reply Quote 0
        • Didier BurD Offline
          Didier Bur
          last edited by

          Hi tt,

          @unknownuser said:

          make the Tool's deactivate event trigger your main script

          Sorry, but how to do that ?

          
          def deactivate()
          ????
          end
          
          

          DB

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

            yeah, exactly.

            def deactivate my_script end

            Just have it call your script again when it de-activates. You could even set up your script to accep arguments so you can send in the point3d.

            Chris

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

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

              Something like:

              module MyModule
              
                def some_method
                  # lalala
                  Sketchup.active_model.tools.push( MyTool.new )
                end
                
                def continue(args)
                  # lalala
                end
                
                class MyTool
                  
                  # Collect data...
                  
                  def deactivate
                    MyModule.continue(args)
                  end
                end
              

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

              1 Reply Last reply Reply Quote 0
              • Didier BurD Offline
                Didier Bur
                last edited by

                Cool, thanks a million 😍

                DB

                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