sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Save Model using Ruby API on Windows

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 666 Views 4 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.
    • C Offline
      Conchords
      last edited by

      I'm having some problems saving a model using the ruby api on windows, but the code seems to work on mac. When I call model.save and then check if it's modified it says it isn't, as if the model was saved. But when I restart sketchup and open the model the changes aren't there.

      Has anyone run into this?

      1 Reply Last reply Reply Quote 0
      • Chris FullmerC Offline
        Chris Fullmer
        last edited by

        What are the errors being output to the ruby console?

        Lately you've been tan, suspicious for the winter.
        All my Plugins I've written

        1 Reply Last reply Reply Quote 0
        • C Offline
          Conchords
          last edited by

          there aren't any errors. I've had it throw errors on invalid paths in the past but it isn't doing that anymore. I also don't think that it's saving to a completely different path because it works on the mac version.

          1 Reply Last reply Reply Quote 0
          • renderizaR Offline
            renderiza
            last edited by

            The following code I found here... https://groups.google.com/forum/#!msg/sketchupruby/ymKyqD_nxBU/AczVTLjFld4J

            
            # Description;
            #        sketchup's "model.save" does not work.
            #        routine to save a .skp file with the same name as the current model
            #         need to save file with a temporary name, (close model ?),
            #         then move the temporary name to the real name
            def model_save(sfile)
                sfile2 = sfile + '.tmp'
                bret = Sketchup.active_model.save(sfile2)
                return(bret) if !bret
            
                # now move sfile2 to sfile
                # remove existing file
                # need to close existing model first
                Sketchup.file_new
                if File.exists?(sfile)
                    begin
                        File.unlink(sfile)
                    rescue
                        warn "Could not delete file; " + sfile
                        return(false)
                    end
                end
            
                bret2 = File.rename(sfile2, sfile)
                printf("INFO; Saved to \"%s\"\n", sfile)
            end 
            

            [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              From that same thread, Dan mentions you can use this command to simulate the actual File > Save:

              Sketchup.send_action( 57603 )

              Then you could use the regular Model.save for Mac and the send_action for PC's. I've not tried it, but it might be a solution.

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

              1 Reply Last reply Reply Quote 0
              • C Offline
                Conchords
                last edited by

                @chris fullmer said:

                From that same thread, Dan mentions you can use this command to simulate the actual File > Save:

                Sketchup.send_action( 57603 )

                Then you could use the regular Model.save for Mac and the send_action for PC's. I've not tried it, but it might be a solution.

                That worked great, thanks.

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  @conchords said:

                  @chris fullmer said:

                  From that same thread, Dan mentions you can use this command to simulate the actual File > Save:

                  Sketchup.send_action( 57603 )

                  Then you could use the regular Model.save for Mac and the send_action for PC's. I've not tried it, but it might be a solution.

                  That worked great, thanks.

                  Actually at that time I did not know of the cross-platform send action string, "saveDocument:" ...

                  ... so you can just use Sketchup.send_action( "saveDocument:" )

                  I'm not here much anymore.

                  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