Forcing a Screen Update during a Ruby script
-
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.
-
@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()
-
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
enddef change_date_loop
for the_step in 1..365
sleep(0.025)
change_date_by_one_day
end
end -
Did you try with a timer?
Or... Maybe the FrameAnimation class....
Sent from my LT25i using Tapatalk 2
-
This works fine for me.
The dialog updates and so does the view.
The statusbar shows the dayrequire('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 said:
This works fine for me.
The dialog updates and so does the view.
The statusbar shows the dayonly The statusbar text changes on a mac... nothing else
john -
@driven said:
@tig said:
This works fine for me.
The dialog updates and so does the view.
The statusbar shows the dayonly 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 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,
-
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
-
This is the reason the Animation class is there for: http://www.sketchup.com/intl/en/developer/docs/ourdoc/animation.php
Advertisement