Exit/Shutdown SU 7 ??

Exit/Shutdown SU 7 ??

Postby HPW » Wed Aug 05, 2009 12:04 pm

Can I shutdown/exit SU 7 with ruby?

How?
0

HPW 
 

Re: Exit/Shutdown SU 7 ??

Postby Jim » Wed Aug 05, 2009 12:48 pm

Not directly, but you might be able to make a system call that could shut it down.
0
Hi

Jim 
Global Moderator
 

Re: Exit/Shutdown SU 7 ??

Postby HPW » Wed Aug 05, 2009 12:50 pm

After some googling I found a post with the same problem:

http://groups.google.com/group/Ruby-API ... 3cdb6f84a3

I still wonder that such a big API still miss such basic things.
Automating Autocad is still much easier.
0

HPW 
 

Re: Exit/Shutdown SU 7 ??

Postby HPW » Wed Aug 05, 2009 1:00 pm

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.
0

HPW 
 

Re: Exit/Shutdown SU 7 ??

Postby HPW » Wed Aug 05, 2009 2:45 pm

After the problem with the Win32Api-code I searched further and found:

http://rubyonwindows.blogspot.com/2007/ ... -ruby.html

Code: Select all
require 'win32ole'
wsh = WIN32OLE.new('Wscript.Shell')
if wsh.AppActivate(skpbasename+".skp - SketchUp")
  wsh.SendKeys('%{F4}')
end


This works for me now.
0

HPW 
 

Re: Exit/Shutdown SU 7 ??

Postby Burkhard » Wed Aug 05, 2009 8:09 pm

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. ;)
0
User avatar
Burkhard 
Premium Member
Premium Member
 

Re: Exit/Shutdown SU 7 ??

Postby AlexMozg » Wed Aug 05, 2009 11:55 pm

HPW wrote:Can I shutdown/exit SU 7 with ruby?
How?

Code: Select all
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.
:D
0

AlexMozg 
PluginStore Author
PluginStore Author
 

Re: Exit/Shutdown SU 7 ??

Postby wikii » Thu Aug 06, 2009 1:08 am

Following ruby code works PC.
Code: Select all
system("taskkill /im sketchup.exe /f")
0

wikii 
PluginStore Author
PluginStore Author
 

Re: Exit/Shutdown SU 7 ??

Postby HPW » Thu Aug 06, 2009 7:41 am

Sketchup.send_action 57602


Undocumented feature but it works.

The doc shows:
21560 and up: causes a runtime Error

So is it official and where do you find such things?

system("taskkill /im sketchup.exe /f")


Works but shows a cmd-window and is slower.
0

HPW 
 

Re: Exit/Shutdown SU 7 ??

Postby thomthom » Thu Aug 06, 2009 7:52 am

HPW wrote:
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?
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Exit/Shutdown SU 7 ??

Postby HPW » Thu Aug 06, 2009 7:58 am

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.
0

HPW 
 

Re: Exit/Shutdown SU 7 ??

Postby HPW » Thu Aug 06, 2009 8:23 am

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.
0

HPW 
 

Re: Exit/Shutdown SU 7 ??

Postby Dan Rathbun » Mon Dec 27, 2010 7:47 pm

[code] Sketchup Safe Shutdown method
http://forums.sketchucation.com/viewtopic.php?f=180&t=29162&p=254022#p254022

cross-platform and safe.
0
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    Re: Exit/Shutdown SU 7 ??

    Postby Dan Rathbun » Mon Dec 27, 2010 10:41 pm

    AlexMozg wrote:
    Code: Select all
    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.
    0
      I'm not here much anymore. But a PM will fire email notifications.
      User avatar
      Dan Rathbun 
      PluginStore Author
      PluginStore Author
       

      SketchUcation One-Liner Adverts

      by Ad Machine » 5 minutes ago



      Ad Machine 
      Robot
       



       

      Return to Developers' Forum

      Who is online

      Users browsing this forum: No registered users and 10 guests

      Visit our sponsors: