How to save the model to a file?
-
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
-
@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'
-
@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...
-
@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'].
-
@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...?
-
%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 -
Advertisement