sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Setting file types in the savepanel

    Scheduled Pinned Locked Moved Developers' Forum
    21 Posts 8 Posters 1.8k Views 8 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W Offline
      WorCoder
      last edited by

      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!?

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        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 from folder=File.dirname(model.path)
        You could then 'set' the file-name based on the model, so file=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_-]/,"_")
        [The gsub is to avoid making a file name with 'illegal' characters like /:"etc]
        Then file=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))
        Then file=model.title+"_"+time+".xxx"
        Set the path=File.join(folder,file).tr("\\","/")
        [The tr 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 the path 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...

        TIG

        1 Reply Last reply Reply Quote 0
        • W Offline
          WorCoder
          last edited by

          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.
          β˜€

          1 Reply Last reply Reply Quote 0
          • W Offline
            WorCoder
            last edited by

            P.S.: I did send in a report, so maybe there might be a fix in the future...

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @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.

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • W Offline
                WorCoder
                last edited by

                @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.

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  @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.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    @dan rathbun said:

                    @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.

                    Yes - but by default XP hides it.

                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      @thomthom said:

                      Yes - but by default XP hides it.

                      Which is one of the dumbest things Microsoft does.

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        tvcasualty
                        last edited by

                        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
                        
                        
                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 2 / 2
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement