• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Forcing a Screen Update during a Ruby script

Scheduled Pinned Locked Moved Developers' Forum
11 Posts 5 Posters 1.2k Views
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.
  • T Offline
    thomthom
    last edited by 20 Jul 2013, 18:08

    You might need to refactor your loop to use a timer. Timers allow for the rest of the system of do some work. Might just give it enough time to update the viewport.

    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
      Dan Rathbun
      last edited by 23 Jul 2013, 05:05

      @kevinkarney said:

      Anyone know of a way to force a screen refresh while a script is running ??

      The Shadows dialog is actually an "inspector" toolwindow.

      So try this module function call:
      UI.refresh_inspectors()

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • K Offline
        KevinKarney
        last edited by 23 Jul 2013, 19:28

        Dear Dan
        Many thanks for troubling to reply. But I am still stuck! The Inspector just updates when the loop is finished.

        require 'sketchup'
        UI.menu("PlugIns").add_item("Change Date") { change_date_loop }

        def change_date_by_one_day
        Sketchup.active_model.shadow_info["ShadowTime_time_t"] =
        Sketchup.active_model.shadow_info["ShadowTime_time_t"] + 606024
        shadowinfo = Sketchup.active_model.shadow_info
        UI.refresh_inspectors()
        refreshed_view = Sketchup.active_model.active_view.refresh
        end

        def change_date_loop
        for the_step in 1..365
        sleep(0.025)
        change_date_by_one_day
        end
        end

        Best Regards
        Kevin Karney

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 24 Jul 2013, 14:24

          Did you try with a timer?

          Or... Maybe the FrameAnimation class....

          Sent from my LT25i using Tapatalk 2

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

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 24 Jul 2013, 16:12

            This works fine for me.
            The dialog updates and so does the view.
            The statusbar shows the day

            require('sketchup.rb')
            module TIG
            	UI.menu("PlugIns").add_item("All 365 Days"){self.change_date_loop()}
            	def self.change_date_loop()
            		model=Sketchup.active_model
            		365.times{|i|
            			sleep(0.025) ### change step time here
            			model.shadow_info["ShadowTime_time_t"]=model.shadow_info["ShadowTime_time_t"]+(60*60*24)
            			model.active_view.refresh
            			UI.refresh_inspectors()
            			Sketchup.status_text="Day #{i+1}"
            		}
            		UI.beep ### when done
            	end
            end
            

            TIG

            1 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by 24 Jul 2013, 17:56

              @tig said:

              This works fine for me.
              The dialog updates and so does the view.
              The statusbar shows the day

              only The statusbar text changes on a mac... nothing else
              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
              • T Offline
                TIG Moderator
                last edited by 24 Jul 2013, 21:07

                @driven said:

                @tig said:

                This works fine for me.
                The dialog updates and so does the view.
                The statusbar shows the day

                only The statusbar text changes on a mac... nothing else
                john
                on my PC it works fine !
                The shadow dialog changes and the screen image changes at each step...
                If the OP had said they had a MAC we might have avoided a dead-end...

                @driven: Can you make any variant of my PC-good code work?

                Thought: If Users want us to help them efficiently, then they MUST add their Version and OS to their User-Profile... 😒

                TIG

                1 Reply Last reply Reply Quote 0
                • D Offline
                  driven
                  last edited by 24 Jul 2013, 21:15

                  @tig said:

                  @driven: Can you make any variant of my PC-good code work?

                  I'll give it a go... I'm curious why it didn't work out of the box...
                  I often just try bits you and others post to see if they work on a mac.

                  @unknownuser said:

                  Thought: If Users want us to help them efficiently, then they MUST add their Version and OS to their User-Profile... :roll:

                  I think the OP's on a PC, but filling in the profile would be useful,

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

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    driven
                    last edited by 24 Jul 2013, 21:41

                    @Tig

                    this does it for the view

                             model.active_view.refresh || Sketchup.active_model.active_view.invalidate
                    
                    

                    I'll try and find the dialog updater now...

                    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
                    • T Offline
                      thomthom
                      last edited by 25 Jul 2013, 00:52

                      This is the reason the Animation class is there for: http://www.sketchup.com/intl/en/developer/docs/ourdoc/animation.php

                      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
                      1 / 1
                      • First post
                        11/11
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement