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

    Odd behavior of Draw

    Scheduled Pinned Locked Moved Developers' Forum
    17 Posts 6 Posters 733 Views 6 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.
    • S Offline
      slbaumgartner
      last edited by

      Here's what I did:

          
         def onMouseMove(flags, x, y, view)
            @ip.pick(view, x, y, @ip1)
            view.invalidate
            view.refresh
          end
      
          def draw(view)
            view.tooltip = @ip.tooltip
            @ip.draw view
      # draw other stuff to the view...
      
      
      

      There are some minor differences, but it's not obvious to me why yours doesn't seem to work.

      Steve

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

        It's recommended to use invalidate instead of refresh unless you have a good specific reason to use refresh. Otherwise you end up unnecessarily redrawing the viewport too often which might impact performance.

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

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by

          @TT,

          what is the underlying difference between refresh and invalidate?

          the API has the same description for both and they are used interchangeably by many...

          On one of my plugins, using both was the only way to guarantee it worked...

          john

          learn from the mistakes of others, you may not live long enough to make them all yourself...

          1 Reply Last reply Reply Quote 0
          • tt_suT Offline
            tt_su
            last edited by

            View.invalidate marks the view for redraw but it might not be updated immediately. It'll be throttled.
            View.redraw force a redraw immediately.

            View.invalidate should be the first choice - View.redraw should be used when you know you really need it.

            I've had to use view.redraw in cases where I make mesh updates in the mouse events (for live mesh preview). There I had to force a redraw otherwise things would appear choppy. But even then I'd try to manually throttle view.redraw.

            1 Reply Last reply Reply Quote 0
            • S Offline
              slbaumgartner
              last edited by

              TT: any idea what logic or basis SketchUp uses to decide when to conduct the next redraw after view.invalidate? That is, I take your answer to mean that SU queues up the draw and then waits for an appropriate opportunity to do it. But what is an "appropriate opportunity"? Is there something besides view.redraw that a Tool can or should do to encourage it? Waiting a random, indeterminate amount of time before the next draw is sure to cause an interactive Tool to be jittery! I'm drawing a "rubber band" tracking the mouse cursor to show dynamically what is happening. Jitters in that would make it quite unusable (maybe on a complex model with a slow redraw it is already so)!

              1 Reply Last reply Reply Quote 0
              • sdmitchS Offline
                sdmitch
                last edited by

                @tt_su said:

                View.invalidate marks the view for redraw but it might not be updated immediately. It'll be throttled.
                View.redraw force a redraw immediately.

                View.invalidate should be the first choice - View.redraw should be used when you know you really need it.

                I've had to use view.redraw in cases where I make mesh updates in the mouse events (for live mesh preview). There I had to force a redraw otherwise things would appear choppy. But even then I'd try to manually throttle view.redraw.

                I don't find view.redraw in the API and it caused an "undefined method" error when I tried to use it.

                Nothing is worthless, it can always be used as a bad example.

                http://sdmitch.blogspot.com/

                1 Reply Last reply Reply Quote 0
                • TIGT Online
                  TIG Moderator
                  last edited by

                  I think tt mistyped ' redraw' for view.refresh πŸ˜’

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • tt_suT Offline
                    tt_su
                    last edited by

                    My bad. What TIG said.

                    1 Reply Last reply Reply Quote 0
                    • sdmitchS Offline
                      sdmitch
                      last edited by

                      Well I have tried all the suggested combinations and nothing seems to solve the "problem". Perhaps it is just my 7 year old laptop!!!!!

                      Nothing is worthless, it can always be used as a bad example.

                      http://sdmitch.blogspot.com/

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

                        Do you have a small reproducible snippet?

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

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          slbaumgartner
                          last edited by

                          @sdmitch said:

                          Well I have tried all the suggested combinations and nothing seems to solve the "problem". Perhaps it is just my 7 year old laptop!!!!!

                          Since these draw operations go directly to OpenGL, this explanation seems quite possible! There could be a bug in either your laptop's OpenGL drivers or an incompatibility in how SketchUp uses OpenGL.

                          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