Stop sketchup from visualizing changes in model while code is running


#1

Im not really sure how to even ask this, but when I change something like ShadowTime in my ruby code, I can visually see it changing in my Sketchup Model (shadow, toolbar, etc.). If, for example, I had to loop through different times, the visual representation of this would really bog down my execution.

I have noticed that after running for more than a few second, it will stop displaying and go into a loading state (shadows stop updating and the curser changes to the load symbol). Once this happens, the rest of the code executes successfully and much faster.

Sorry if this is confusing but that was my best explanation. Thanks in advance!


#2

on my mac I find ‘Inspector’ windows have a far greater effect than updating the view, and often deliberately call for view.refresh to show progress in the plugin…

If I wrap the code in model.start_operation (“Make Set”,true), all the user will see is the beachball, which few appreciate as a progress indicator…

here’s an example from one of mine that makes sets of images for each scene…

I also believe the running of large loops runs very differently on a mac than a PC…

CREDIT: model and Style set by @DaveR


#3

I’m not sure if you want to stop displaying, or if you want to update the view each time you do something. To update the view, I have done simple animation loops that do not use Sketchup’s animation class. It requires a method call to refresh the view after the model has been modified. I assign a reference to the view object with:
view = Sketchup.active_model.active_view

Then, inside of any code loop that updates the model, the last line or so is:

view.refresh

That does not have to be done if you use the animation class.


#4

Bruce,
sorry, I should have been clear about this, I want to stop the visual display so that my code runs faster.


#5

Make sure you set the second argument of model.start_operation to true. It tells SketchUp to disable UI updates until you commit the operation.
http://www.sketchup.com/intl/en/developer/docs/ourdoc/model#start_operation

The only reason it’s not true by default is backwards compatibility for the API.