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

    How to save the model to a file?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 295 Views 3 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.
    • R Offline
      rvs1977
      last edited by

      Hi!

      How do I save the model to a file?

      I have tried the following but it don't seems to work.

      ` model = Sketchup.active_model

      Save the model using the current SketchUp format

      filename = File.join(ENV['Home'], 'Desktop', 'mysketchup.skp')
      status = model.save(filename)`

      And can anyone tell me what ENV['Home'] is?
      And if I want to save to a diffenrent location than desktop will it then be, eg:
      'c:\my\project\folder'?

      Thanks in advance

      -Rasmus


      Get a Ruby

      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        @rvs1977 said:

        Hi!

        How do I save the model to a file?

        I have tried the following but it don't seems to work.

        ` model = Sketchup.active_model

        Save the model using the current SketchUp format

        filename = File.join(ENV['Home'], 'Desktop', 'mysketchup.skp')
        status = model.save(filename)`

        And can anyone tell me what ENV['Home'] is?
        And if I want to save to a diffenrent location than desktop will it then be, eg:
        'c:\my\project\folder'?

        Thanks in advance

        -Rasmus

        ENV['Home'] is your user account, ie C:/Users/Rasmus. In this case filename would equal 'C:/Users/Rasmus/Desktop/mysketchup.skp'

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • R Offline
          rvs1977
          last edited by

          @sdmitch said:

          ENV['Home'] is your user account, ie C:/Users/Rasmus. In this case filename would equal 'C:/Users/Rasmus/Desktop/mysketchup.skp'

          Great, thanks! I figured it out with your help πŸ˜„

          model = Sketchup.active_model status = model.save('d:/rs_model.skp')

          But ENV['Home'] dont seems to work.
          I have tried:
          test = ENV['Home'] puts(test.to_s)

          and nothing shows...


          Get a Ruby

          1 Reply Last reply Reply Quote 0
          • sdmitchS Offline
            sdmitch
            last edited by

            @rvs1977 said:

            @sdmitch said:

            ENV['Home'] is your user account, ie C:/Users/Rasmus. In this case filename would equal 'C:/Users/Rasmus/Desktop/mysketchup.skp'

            Great, thanks! I figured it out with your help πŸ˜„

            model = Sketchup.active_model status = model.save('d:/rs_model.skp')

            But ENV['Home'] dont seems to work.
            I have tried:
            test = ENV['Home'] puts(test.to_s)

            and nothing shows...

            Interesting! In the Ruby Console, type ENV and press Enter. Does that show anything? How about ENV['HOME'].

            Nothing is worthless, it can always be used as a bad example.

            http://sdmitch.blogspot.com/

            1 Reply Last reply Reply Quote 0
            • R Offline
              rvs1977
              last edited by

              @sdmitch said:

              Interesting! In the Ruby Console, type ENV and press Enter. Does that show anything? How about ENV['HOME'].

              When I type ENV in Ruby Console:

              "PUBLIC"=>"C:\\Users\\Public", "SESSIONNAME"=>"Console", "SystemDrive"=>"C:", "SystemRoot"=>"C:\\windows", "TEMP"=>"C:\\Users\\RASMUS~1\\AppData\\Local\\Temp", "TMP"=>"C:\\Users\\RASMUS~1\\AppData\\Local\\Temp", "USERDOMAIN"=>"RasmusVS-pc-Pc", "USERNAME"=>"RasmusVS-pc", "USERPROFILE"=>"C:\\Users\\RasmusVS-pc", "windir"=>"C:\\windows", "windows_tracing_flags"=>"3", "windows_tracing_logfile"=>"C:\\BVTBin\\Tests\\installpackage\\csilogfile.log"}

              As you can see there is no ENV['Home'] variable.

              I would use ENV['USERPROFILE'] instead.

              I use Sketchup 8.0.15158 - Maybe thats why...?


              Get a Ruby

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

                %HOME% is not defined under MS Windows by default.

                Beginning with SketchUp 2014, SketchUp defines ENV["HOME"] within it's own copy of the environment, thus:
                ENV["HOME"]= ENV["USERPROFILE"] unless ENV["HOME"]

                Ruby itself needs ENV["HOME"] defined in order to expand ~ (the tilde character,) within path strings, to the user's home directory path.

                We (developers,) asked for this, because we all were trying to set ENV["HOME"].

                Be aware that there are differences in the names of ENV variables, between both OSX and MS Windows, and between Windows 6+ and Windows 5 and earlier versions. See:
                Wikipedia: Environment Variables

                I'm not here much anymore.

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

                  @rvs1977 said:

                  @sdmitch said:

                  I use Sketchup 8.0.15158 - Maybe thats why...?

                  Yes.. as I said above, prior to SKetchUp 2014, we had to make sure ENV["HOME"] was set ourselves (as I showed above.)

                  Ruby needs it set.

                  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