@trottolino said:
Hello to all.
Who can help me to insert commands to "refresh" and "stop" during the calculation in a routine that generates a drawing with hundreds of faces?
I tried to use the method "invalidate" and "onCancel", but with poor results.
For example, given the following simple procedure for calculation:
**def test_cancel_refresh @my_model = Sketchup.active_model @my_entities = @my_model.entities @step = 10 @n_tot = @step*@step*@step for @z in 1..@step for @y in 1..@step for @x in 1..@step @x0 = @x-1 @y0 = @y-1 @z0 = @z-1 @x1 = @x0+0.5 @y1 = @y0+0.5 @z1 = @z0+0.5 @pt0 = Geom::Point3d.new(@x0,@y0,@z0) @pt1 = Geom::Point3d.new(@x1,@y0,@z0) @pt2 = Geom::Point3d.new(@x1,@y1,@z0) @pt3 = Geom::Point3d.new(@x0,@y1,@z0) @pt4 = Geom::Point3d.new(@x0,@y0,@z1) @pt5 = Geom::Point3d.new(@x1,@y0,@z1) @pt6 = Geom::Point3d.new(@x1,@y1,@z1) @pt7 = Geom::Point3d.new(@x0,@y1,@z1) @my_entities.add_face(@pt0,@pt1,@pt2,@pt3) @my_entities.add_face(@pt4,@pt5,@pt6,@pt7) @my_entities.add_face(@pt0,@pt4,@pt5,@pt1) @my_entities.add_face(@pt3,@pt7,@pt6,@pt2) @my_entities.add_face(@pt0,@pt4,@pt7,@pt3) @my_entities.add_face(@pt1,@pt5,@pt6,@pt2) @prog = @x + (@y-1)*@step + (@z-1)*@step*@step @msg = @prog.to_s Sketchup.status_text = "Status: " + @prog.to_s + "/" + @n_tot.to_s end end end end**
The status message (where I write the progression) is visible since about 50% and after stop, the screen becomes blank and everything freezes until the end of the routine, when finally happens the screen regeneration.
Rather, I would always see the progression and sometimes even regenerate the screen.
It should also be possible to stop at any time of the calculation by pressing the ESC key.How can I effectively incorporate these controls in my script?
I did not find examples of this.
Did I asked a too simple question or no one knows the solution?