sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Saving components so they "open" nicely?

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 277 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RichMorinR Offline
      RichMorin
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • J Offline
        jessejames
        last edited by

        @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 πŸ˜‰

        Always sleep with a loaded gun under your pillow!

        1 Reply Last reply Reply Quote 0
        • RichMorinR Offline
          RichMorin
          last edited by

          It looks like refresh_thumbnail does the trick; thanks! I'll report back when I have done further testing...

          -r

          1 Reply Last reply Reply Quote 0
          • RichMorinR Offline
            RichMorin
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement