Making changes visible
-
I have a plugin which adds a number of colored faces to the model. Sometimes, the faces do not appear unless the user plays with the view. I'd like a way for the plugin to make them appear.
Details
The incoming model has three layers (Layer0, outline, spaces), stacked as horizontal planes. The plugin adds a fourth layer (walls) above the first three. Normally, the model is viewed from the top, allowing the user to view the composition of the layers (eg, walls superimposed on spaces).
Sometimes, when the plugin is finished, the walls do not appear. However, they can be made to appear by selecting a different view (eg, oblique) and then switching back to the top view. I've tried a few things (eg, View.refresh) without success. Suggestions, anyone?
-r
-
How about:
A)
view.zoom_extents view.zoom(0.98)
B) toggle the "walls" layer off then back on
C) if there are more than 1 members of the
Pages
collection, switch to another page then back to the current one.
Speed it up thus:
model.options['PageOptions']['ShowTransition']=false
-
Sample model / script?
-
What about
Sketchup.active_model.active_view.invalidate
? (that is one of the few that work outside of a tool)Edit: Ok, that is probably equal to View.refresh
-
@aerilius said:
Edit: Ok, that is probably equal to View.refresh
Not quite.
View.invalidate
is a polite request and SketchUp will update the view when it feels like it. So many invalidations in quick succession might be ignored.View.refresh
is an order - if you call this repeatedly it'll slow down the viewport. -
I added this code
active_view = Sketchup.active_model.active_view active_view.zoom_extents active_view.zoom(1.0)
and the window now refreshes. However, the position and scaling are modified.
Is there any way to just get the refresh or refresh to the old state?-r
-
You have to save the view's camera properties to a new
Sketchup::Camera
instance, then restore it.view = Sketchup.active_model.active_view vcam = view.camera props = [vcam.eye,vcam.target,vcam.up,vcam.perspective?] cam = Sketchup;;Camera.new(*props) view.zoom_extents view.camera= cam
Advertisement