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!
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Forcing a Screen Update during a Ruby script

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 5 Posters 1.3k Views 5 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

      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
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        @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

          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
          • thomthomT Offline
            thomthom
            last edited by

            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
            • TIGT Offline
              TIG Moderator
              last edited by

              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

                @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
                • TIGT Offline
                  TIG Moderator
                  last edited by

                  @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

                    @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

                      @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
                      • thomthomT Offline
                        thomthom
                        last edited by

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

                        Advertisement