Because it uses platform OS dialog interfaces. (On Windows the API uses
Yes, there is, and they are from the same OS libraries. They are exposed to the Ruby API via …
There a bit of a difference in their operation.
UI::openpanel always returns a valid filepath (unless the user cancels the dialog). The openpanel also allows multiple filetype filters for the MS Windows platform.)
UI::savepanel allows the suggestion of a filename and file extension, but the user can override these (including giving an incorrect file extension.) The user may also attempt to use invalid characters that are not allowed in path strings and filenames. (Ie, code defensively.) Also, the user can navigate away from your suggested directory path.
As with the other method, the user can cancel the dialog.
The results from these methods (and that of
UI::inputbox) should always be checked for a false eval, and if so … exit the command. (Ie, take it as an indication the user wishes to cancel the task.)
filter = Sketchup.platform == :platform_win ? 'SketchUp Model|*.skp||' : '*.skp'
filepath = UI.openpanel("Select model to load", ENV['HOME'], filter)
return if !filepath # user cancelled !
# Continue with task ...