How to reboot SketchUp?

After updating my plugin, is it possible to restart SketchUp by Ruby?

This works for Windows. I’m not sure how to do this on Mac.

Process.spawn("SketchUp.exe")
Sketchup.quit

Quirks:

  1. This starts the default version of SketchUp if more than one version is installed.
  2. In SketchUp 2022 the quit is executed to soon and SketchUp is not restarted.

Also see here.

I would be extremely cautious regarding quitting and restarting SketchUp in an extension. The human user (who should normally be in control of such actions, in my opinion) needs to know and authorize such a major step to avoid losing unsaved work. If the extension is intended to run “unattended” (as may be the case with the topic linked by @Neil_Burkholder) then perhaps fewer cautions may be appropriate.

4 Likes

I’d second what TDahl said; leave this to the user. Display a message if you want, but most users are used to having to restart after installing/updating extensions.

Forcefully restart the application might cause the user to lose data. Even if an extension is updated it doesn’t mean the user needs/wants to use the extension immediately and a restart would be an interruption in their workflow.

3 Likes

For the record this is how I handle this in my extension.

BC Update

5 Likes

That’s what I’d recommend as well, inform the user - don’t take the action on their behalf. :+1::+1:

2 Likes

The quit method is used to terminate the application. This will pop-up the usual model save prompts if there are unsaved models open. User can cancel the model save, in which case the application will not terminate.


Also, - if there is an other instance of Sketchup is running it will not terminated.


Perhaps reload the extension will be enough in case there is no changes in the menus…
e.g.: Reloading my plugins - #2 by eneroth3


Otherwise I agree with @TDahl and @tt_su that inform the user to restart will be necessary to use the new version, and let the user decide what to do…

I’d avoid using this as the prompt to update. The prompt will not explain why the app tries to terminate. And as mentioned, the user might be busy with other tasks where restarting, even a modal prompting an update might be interrupting workflow. Better user experience to notify the user in a non-intrusive way, related to using the extension.

Maybe, but - I’d recommend keeping this as simple as possible. It’s not a use-case that occur very frequently. Not every “problem” needs an engineered solution.

3 Likes

Just an FYI for the readership. I was involved in politicking to get the quit method implemented.
The use case was specifically for batch mode processing of models, by a system batch script that would load models using command line parameters.