Setting file types in the savepanel
-
It's been reported before - but it doesn't hurt reminding them...
http://forums.sketchucation.com/viewtopic.php?f=11&t=29023 -
Thanks for the effort, guys.
Sadly this doesn't really help.Seems to me as more inconvenient to have to move to the desired folder every time.
What bugs me the most is, that one can't click save and then immediately start typing the filename, in the way that the whole line (including ".xxx")is highlighted.
Since there might be some not really intelligent people handling this, I would love a way for them to immediately start typing, but still have the right extension visible as well.
Do I have to file a bug-report to get this in or is there nothing one can do to try and get functionality of the filetype selector!? -
If the users are so stupid why even give them the chance of saving the file in a weird folder or giving it a stupid name ?
Why not always locate and name the file 'with the model'.
First use a trap(puts "Save SKP!";return nil if model.path==""
in case your SKP is not saved.
You get the folder fromfolder=File.dirname(model.path)
You could then 'set' the file-name based on the model, sofile=model.title+".xxx"
or whatever file type suffix you want.
You could use the Scene name in the name too...
scene=model.pages.selected_page.name.gsub(/[^A-Za-z0-9_-]/,"_")
[Thegsub
is to avoid making a file name with 'illegal' characters like /:"etc]
Thenfile=model.title+"_"+scene+".xxx"
OR you could use a file name based on the 'date/time' which will always be different...
time=sprintf("%.1d\n",(Time.now.to_f*100))
Thenfile=model.title+"_"+time+".xxx"
Set thepath=File.join(folder,file).tr("\\","/")
[Thetr
is only to tidy up if you are to display it later - e.g. in a confirming dialog - as you might get a mix of / and \ on a PC]
Now use thepath
to export, or save as a data file etc...
Alternatively you could let the user set the file name with a simple inputbox
results=inputbox(["File Name: "],[model.title],"Type in XXX File Name [WITHOUT a '.xxx' suffix]") return nil if not results file=(File.basename(results[0]).gsub(/[^A-Za-z0-9_-]/,"_"))+".xxx"
which traps 'stupid' input or file suffix... -
Thanks for those tips! I really appreciate this.
I see your point. Since there are pro and dumb users, the features I would love to include are:
- selecting your own name for the file
- selecting your wished folder to store into
- keep "uneducated" users from messing up the filetype
- keep a clean interface for ease of use and esthetic reasons
And somehow I'm also on the point that talig mentioned
@talig said:
...I find it puzzling that the list of file types exists but it's empty and can't be filled.
Mainly because I think this is just a basic functionality and I don't see the point in this option not being provided.
-
P.S.: I did send in a report, so maybe there might be a fix in the future...
-
@worcoder said:
- keep "uneducated" users from messing up the filetype
Can't you just correct the filename you are returned? If there is not file extension, automatically append it before saving? Since Windows since XP hide the file extension on known files many users are completely unaware of file extensions anyway.
-
@thomthom said:
many users are completely unaware of file extensions anyway.
Sorry for the late reply, was on holiday...
Sure I can correct the file extension, but I'd still love to have the nice looking "clean" solution with a working file type selector.We'll see what the future brings.
-
@thomthom said:
Since Windows since XP hide the file extension on known files many users are completely unaware of file extensions anyway.
Not a given.
On all our machines (or any machine I work on,) I turn file extension display back ON.
-
-
@thomthom said:
Yes - but by default XP hides it.
Which is one of the dumbest things Microsoft does.
-
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