Problem with page.update


#1

I have something like this:

Sketchup.active_model.pages.add('Main')
# scena rzut
page = Sketchup.active_model.pages.add('Top')
Sketchup.send_action('viewTop:')
Sketchup.active_model.active_view.zoom_extents
																							page.update
page.update(1)

And after this view in scene Top is the same like in the scene Main (iso view)


#2

You need to wait for the UI to change the view.

Kernel.sleep(0.5) # more if model is complex

OR,… use a ViewObserer to trigger the scene update call.

OR, use a timer:

UI::start_timer(0.5,false) { page.update(1) }

#3

Dan,
it works for:

Sketchup.active_model.pages.add(‘Main’)
# scena rzut
page = Sketchup.active_model.pages.add(‘Top’)
Sketchup.active_model.active_view.zoom_extents
Sketchup::send_action(“viewTop:”)
UI::start_timer(0.5,false) { page.update(1) }

but doesn’t work for:

 Sketchup.active_model.pages.add('Main')
    # scena rzut
    page = Sketchup.active_model.pages.add('Top')
    Sketchup.active_model.active_view.zoom_extents
    Sketchup::send_action("viewTop:")
  UI::start_timer(0.5,false) { page.update(1) }

page = Sketchup.active_model.pages.add(‘Left’)
Sketchup.send_action(‘viewLeft:’)
Sketchup.active_model.active_view.zoom_extents
UI::start_timer(0.5,false) { page.update(1) }

Page “Left” is OK but ‘Top’ Is not.


#4

Or, try this:

Sketchup::send_action(“viewTop:”)
Kernel.sleep(5)

changing view into top is making after 5 sec.


#5

I’ve asked you before to properly format code in the forums:

```ruby
# code
```

Using lines beginning with > is a quotation, not a code block.


You will have to be more creative, and wait until the first page update is done, before reusing the page reference, and changing the page again. You may need to use a FrameChangeObserver in combination with a ViewObserver.


#6

Try temporarily setting the transition time to zero before setting the view and updating the page, and then reset the transition time. Just a thought…


#7

Thanks, Jim.
I tried it, but doesn’t work.