The Ruby API for Google SketchUp has a function open_file, but I cannot find the function close_file. Since I have to process many files, I want to close each file before moving on to the next one, otherwise the program will crash due to running out of memory.
How can programmatically close SketchUp files?
I am using Mac OS X and am ready to use AppleScript features to signal that the window is closing.
EDIT
I am considering several approaches that have so far proven fruitless.
- Using the Ruby Ruby Descriptor as described in this question . The problem here is that I cannot get SketchUp to recognize my installed gems .
In the same vein, I'm trying to use osascript (a bash program that runs AppleScripts from a shell) to close a window. That is, I call the shell from the SketchUp Ruby console window using one of the following actions:
% x [osascript -e "tell SketchUp to close window 1 ']
% x [osascript -e "tell SketchUp to close window 1 '&]
% x [osascript -e "tell SketchUp to close each window ']
% x [osascript -e 'tell SketchUp to close each window' &]
, , SketchUp . , IRB bash SketchUp, : (, Ruby , ).
script, script . Google SketchUp, . , , SketchUp. , drb. , drb SketchUp, :
: LoadError: (eval): 5: in 'require': - drb
2
, Sketchup Google, AppleScript, , . -, , Sketchup. -, script , , .
, Sketchup AppleScript. script Sketchup, , , AppleScript, , osascript . Sketchup AppleScript, Sketchup , script.
3
close_file, script, . AppleScript :
def close_file()
f = '/temp/mutex.txt'
File.new(f, 'w').close
result = UI.messagebox "Click OK when window has closed."
end
ruby script, AppleScript, "" . AppleScript :
tell application "System Events"
tell process "SketchUp"
set frontmost to true
keystroke return
end tell
end tell
. " ", EDIT 2, .