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.
- This starts the default version of SketchUp if more than one version is installed.
- 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.
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.
For the record this is how I handle this in my extension.
That’s what I’d recommend as well, inform the user - don’t take the action on their behalf.
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
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.