Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download
Setting file types in the savepanel
-
Sorry to drudge up old news, but this is an embarrassingly old issue, be nice to have a filter option in the API by now.
Here was my solution because I didn't like the fact that it could possibly overwrite a file accidentally using TIGs approach (untitled != untitled.txt for example). Anyhow it can be a burden to hit save twice, but I'd rather do that 100x then accidentally save over something important.Where:
EXT = "txt" default_dir = "c;\\temp\\" default_file = "untitled"The following while loop:
name_valid = false while name_valid == false path_to_save_to = UI.savepanel("Save Code File", default_dir, default_file) #path_to_save_to = path_to_save_to.tr("\\","/") # This maybe required. fileext = File.extname(path_to_save_to) # filename with prefix stripped filebase = File.basename(path_to_save_to, ".#{EXT}") #puts fileext.inspect if fileext == "" || fileext == nil default_file = filebase + ".#{EXT}" UI.messagebox "Oops! Including the file extension '#{EXT}'\nThis is an embarrassing workaround...\nPlease hit save again." #puts default_file.inspect else filename = filebase + ".#{EXT}" path_to_save_to = File.dirname(path_to_save_to) + "\\" + filename name_valid = true end end
Advertisement