sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Where's My Inference Dots?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 804 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.
    • J Offline
      Jim
      last edited by

      Shouldn't this produce inference dots? It's only a slightly modified linetool.rb.

      
      require 'sketchup'
      
      class JimTool
          def activate
              @ip = Sketchup;;InputPoint.new
              @ip1 = Sketchup;;InputPoint.new
          end
          def onMouseMove(flags, x, y, view)
              @ip.pick(view, x, y)
              if @ip != @ip1
                  view.invalidate if @ip.display? or @ip1.display?
                  @ip1.copy!(@ip)
                  view.tooltip = @ip1.tooltip
              end
          end
      end
      
      Sketchup.active_model.select_tool(JimTool.new)
      
      
      
      

      Hi

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

        No, you're not drawing anything - so nothing should appear. Are you getting inference dots?

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

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

          I see, you want to draw the inference points. You must call the .draw method for the InputPoint in the Tool's draw event.

          
          require 'sketchup'
          
          class JimTool
              def activate
                  @ip = Sketchup;;InputPoint.new
                  @ip1 = Sketchup;;InputPoint.new
              end
              def onMouseMove(flags, x, y, view)
                  @ip.pick(view, x, y)
                  if @ip != @ip1
                      view.invalidate if @ip.display? or @ip1.display?
                      @ip1.copy!(@ip)
                      view.tooltip = @ip1.tooltip
                  end
              end
              def draw(view)
                  @ip1.draw if @ip1.valid?
              end
          end
          
          Sketchup.active_model.select_tool(JimTool.new)
          
          

          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

            Thank you. I just wish the answer wasn't so obvious!

            /me smacks forehead.

            Hi

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

              I'm not sure if you need to use two InputPoints...
              The Docs says that the pick method returns true only if the picked entity is different from the last pick. So I'd think it should be enough to just use the one and invalidate only when pick returns true. Think I'm doing this with my current tool I'm working on.

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

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

                I could be way off, but I was thinking it was an optimization thing. I think they are just checking to see if the inputpoint changed, and only if it changes do they refire the draw method. Otherwise each pixel move of the mouse creates a new IP point, and therefore refires the draw method with each pixel movement, even if the IPpoint is already drawn. So testing to see if its a new point will make it only redraw it each time there is a new point to draw. Not each pixel the mouse moves. Again, that is untested recently but that has been my understanding of the example they provide.

                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

                  @chris fullmer said:

                  I could be way off, but I was thinking it was an optimization thing. I think they are just checking to see if the inputpoint changed, and only if it changes do they refire the draw method.
                  Chris

                  But as the manual says:

                  @unknownuser said:

                  true if a valid InputPoint was picked and it is different than it was before.

                  From that, it sounds like the InputPoint object is performing the check for you. It returns true only if it's different from the last time you called pick.]
                  (Note: I haven't tested that the implementation actually works as the manual says it should. We have enough examples of deviance... 😕 )

                  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