Exit/Shutdown SU 7 ??
-
I tried the API-call from that link.
But unfourtunatly it does not work from a ruby loaded on startup.
When I type it from the Console after startup it closes SU. -
After the problem with the Win32Api-code I searched further and found:
http://rubyonwindows.blogspot.com/2007/05/automating-applications-with-ruby.html
require 'win32ole' wsh = WIN32OLE.new('Wscript.Shell') if wsh.AppActivate(skpbasename+".skp - SketchUp") wsh.SendKeys('%{F4}') end
This works for me now.
-
We have a lot of Bugsplat possiblities to close SU7. ie. it could be easier to create a ruby which select all same materials, set Podium reflection at once. Sketchup closes immediately.
-
@hpw said:
Can I shutdown/exit SU 7 with ruby?
How?def Sketchup;;exit model = Sketchup.active_model model.save "temp_model.tmp" if model.modified? Sketchup.send_action 57602 end#def
Model doezn't realy save.
-
Following ruby code works PC.
system("taskkill /im sketchup.exe /f")
-
@unknownuser said:
Sketchup.send_action 57602
Undocumented feature but it works.
The doc shows:
21560 and up: causes a runtime ErrorSo is it official and where do you find such things?
@unknownuser said:
system("taskkill /im sketchup.exe /f")
Works but shows a cmd-window and is slower.
-
@hpw said:
@unknownuser said:
system("taskkill /im sketchup.exe /f")
Works but shows a cmd-window and is slower.
hmm.... what if you have other SU windows open at that time.. kills them too?
-
Another point to use one of the other methods.
For now I will go for the Sketchup.send_action which seems to be the best/smallest option. -
I revert back to the:
wsh.SendKeys('%{F4}')
because:
Sketchup.send_action 57602
immidiatly shut down SU even when the save-process is not finished.
So its get not saved. -
[code] Sketchup Safe Shutdown method
http://forums.sketchucation.com/viewtopic.php?f=180&t=29162&p=254022#p254022cross-platform and safe.
-
@alexmozg said:
> def Sketchup;;exit > model = Sketchup.active_model > model.save "temp_model.tmp" if model.modified? > Sketchup.send_action 57602 > end#def >
Model doezn't realy save.
Do NOT use exit as a method name !!!
It is already defined as a global method by the Kernel module (and so is inherited by ALL classes and modules.)
exit() Initiates the termination of the Ruby script by raising the SystemExit exception. Also runs any at_exit block methods before termination.
Advertisement