Saving components so they "open" nicely?
-
I have a plugin which saves the component it has been working on in a file, as:
comp_def.save_as(out_path)
All of the saved components import nicely, but some of them don't "open" well. For example, they might not show the entire model, show the model in too large a space, etc.
In some cases, things get really extreme: I have to scroll waaaay out (or use "Camera > ZoomExtents") to see the model properly.
I have tried doing a ZoomExtents inside the plugin, as:
Sketchup.send_action('ZoomExtents;')
or
am = Sketchup.active_model av = am.active_view av = av.zoom_extents
or
Sketchup.active_model.active_view. zoom(Sketchup.active_model.entities)
but this has no effect on the saved file. HOWEVER, the window adjusts itself as desired if I open the saved file and type the command into the Ruby Console, as:
Sketchup.active_model.active_view.zoom_extents
My impression is that zoom_extents is working, but that the extents aren't getting saved by the save_as method.
Help?
-
@richmorin said:
My impression is that zoom_extents is working, but that the extents aren't getting saved by the save_as method.
Help?
I don't know anything about saving components as i've never needed to do that, however there is somewhere a method like "update_thumbnail" or something like that? It might be useful to you...? If i find the correct method i'll edit my post. But remember i'm just purely guessing at this point
-
It looks like refresh_thumbnail does the trick; thanks! I'll report back when I have done further testing...
-r
-
Indeed, it turns out that calling refresh_thumbnail after the call to zoom_extents and before the call to save_as clears up the problem.
Advertisement