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_extentsor
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_extentsMy 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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement