sketchucation logo sketchucation
    • Login
    ⚠️ Attention | Having issues with Sketchucation Tools 5? Report Here

    Exit/Shutdown SU 7 ??

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 7 Posters 3.0k Views 7 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.
    • H Offline
      HPW
      last edited by

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

      Link Preview Image
      Automating Applications with Ruby & The Windows Script Host

      We've talked at length about automating Windows applications through COM/OLE, using the win32ole library. But not all applications expose t...

      favicon

      (rubyonwindows.blogspot.com)

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

      This works for me now.

      1 Reply Last reply Reply Quote 0
      • BurkhardB Offline
        Burkhard
        last edited by

        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. πŸ˜‰

        [http://www.ia-plus.de(http://www.ia-plus.de)]

        1 Reply Last reply Reply Quote 0
        • A Offline
          AlexMozg
          last edited by

          @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.
          πŸ˜„

          1 Reply Last reply Reply Quote 0
          • W Offline
            wikii
            last edited by

            Following ruby code works PC.

            
            system("taskkill /im sketchup.exe /f")
            
            
            1 Reply Last reply Reply Quote 0
            • H Offline
              HPW
              last edited by

              @unknownuser said:

              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?

              @unknownuser said:

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

              Works but shows a cmd-window and is slower.

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @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?

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • H Offline
                  HPW
                  last edited by

                  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.

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    HPW
                    last edited by

                    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.

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

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

                      cross-platform and safe.

                      I'm not here much anymore.

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

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

                        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