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

    Translate My Documents

    Scheduled Pinned Locked Moved Developers' Forum
    18 Posts 5 Posters 1.2k Views 5 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.
    • thomthomT Offline
      thomthom
      last edited by

      Norwegian Vista 32bit system:

      ENV.each{|k,v|puts "#{k} - #{v}"} ALLUSERSPROFILE - C:\ProgramData APPDATA - C:\Users\Thomassen\AppData\Roaming CLASSPATH - .;C:\Program Files\Java\jre1.6.0_05\lib\ext\QTJava.zip CommonProgramFiles - C:\Program Files\Common Files COMPUTERNAME - LAPTOP ComSpec - C:\Windows\system32\cmd.exe FP_NO_HOST_CHECK - NO HOMEDRIVE - C: HOMEPATH - \Users\Thomassen LOCALAPPDATA - C:\Users\Thomassen\AppData\Local LOGONSERVER - \\LAPTOP NUMBER_OF_PROCESSORS - 2 OS - Windows_NT Path - C:\Program Files\PC Connectivity Solution\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\PROGRA~1\COMMON~1\ULEADS~1\MPEG;C:\Program Files\QuickTime\QTSystem\ PATHEXT - .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PROCESSOR_ARCHITECTURE - x86 PROCESSOR_IDENTIFIER - x86 Family 6 Model 15 Stepping 13, GenuineIntel PROCESSOR_LEVEL - 6 PROCESSOR_REVISION - 0f0d ProgramData - C:\ProgramData ProgramFiles - C:\Program Files PUBLIC - C:\Users\Public QTJAVA - C:\Program Files\Java\jre1.6.0_05\lib\ext\QTJava.zip SESSIONNAME - Console SystemDrive - C: SystemRoot - C:\Windows TEMP - C:\Users\THOMAS~1\AppData\Local\Temp TMP - C:\Users\THOMAS~1\AppData\Local\Temp USERDOMAIN - Laptop USERNAME - Thomassen USERPROFILE - C:\Users\Thomassen windir - C:\Windows

      I don't see anything that relates to the Documents folder...

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

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

        If you are ok by depending on the win32 module: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/203409

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

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

          USERPROFILE gives you the partial path then use /My Documents/ or the equivalent of each locale - you'll need to construct a 'lookup-table' based on the 'locale'... πŸ˜•

          TIG

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

            @tig said:

            USERPROFILE gives you the partial path then use /My Documents/ or the equivalent of each locale - you'll need to construct a 'lookup-table' based on the 'locale'... πŸ˜•

            The problem here is that even getting the system locale is a problem. Same problem I've struggled with in regard to number formatting and parsing.

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

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

              http://code.google.com/apis/sketchup/docs/ourdoc/sketchup.html#get_locale
              finds the Sketchup locale which is a good start - if the users installs a non-locale version it's a pain BUT you could use the look-up table to check if a folder exists, based on a default and a locale, and if nothing is found then pop-up a dialog asking for the path to the the 'My_Documents' folder ?

              or if it's always on a PC then hack the registry use 'cmd' etc:
              HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders String value: Personal
              which will return the path to the 'My Documents' folder in any locale...
              πŸ˜•

              TIG

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

                @tig said:

                http://code.google.com/apis/sketchup/do ... get_locale
                finds the Sketchup locale which is a good start - if the users installs a non-locale version it's a pain BUT you could use the look-up table to check if a folder exists, based on a default and a locale, and if nothing is found then pop-up a dialog asking for the path to the the 'My_Documents' folder ?

                I use Norwegian locale, and there is not Norwegian SU. I use English SU and Sketchup.get_locale returns "en-US". It can not be relied on to represent the system locale. SU isn't localised to that many languages.

                @tig said:

                or if it's always on a PC then hack the registry use 'cmd' etc:
                HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
                String value: Personal
                which will return the path to the 'My Documents' folder in any locale...

                I think this is what this does:

                @thomthom said:

                If you are ok by depending on the win32 module: http://blade.nagaokaut.ac.jp/cgi-bin/sc ... alk/203409

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

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

                  I think this is becoming too complex...
                  Just make a temporary cmd file in Ruby, then 'openURL' it to read the Registry entry and then write it into a temporary file, that you then read using Ruby to find the path to the current user's 'Documents' folder ?

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    Jim
                    last edited by

                    On the person's computer, ENV["USERPROFILE"] returns:

                    "C:\Users\Jim"

                    When the location is:

                    Doctored Image

                    What is Equipo? Is it "My Computer"?

                    (I will now re-read the thread and see what I missed.)

                    Hi

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      Jim
                      last edited by

                      Just FYI, there is a User Shell Folder key because, from the article (2003)..

                      @unknownuser said:

                      the "Shell Folders" key exists solely to permit four programs written in 1994 to continue running on the RTM version of Windows 95.

                      The gist of the article is do not rely on registry keys directly and use the system library to read the location of the special folder names. The article is aimed at Windows application developers, but it applies here because reading these registry keys isn't giving the desired result.

                      HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

                      Which in my case looks like this:

                      401.png

                      But from my previous post, it would not return the desired path either. The real directory name is Usuarios, and not Users.

                      (My Google skillz rulez!)

                      Hi

                      1 Reply Last reply Reply Quote 0
                      • Chris FullmerC Offline
                        Chris Fullmer
                        last edited by

                        Jim, did you do a full install in spanish? OR just change the language to spanish on your existing system?

                        Lately you've been tan, suspicious for the winter.
                        All my Plugins I've written

                        1 Reply Last reply Reply Quote 0
                        • J Offline
                          Jim
                          last edited by

                          Neither, it's not my computer.

                          Right now, I think the answer is in using Win32API, but need to learn to use it make the system call.

                          The Dir::PERSONAL would probably work, but there are more than a few dependencies, and it complains about the Ruby Version being 1.8.0 (in SketchUp) instead of my installed 1.8.6, so I can't get it to work easily.

                          Update: I think I found a single-file (or 2-file) solution. Test pending...

                          Hi

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

                            @tig said:

                            ... or if it's always on a PC then hack the registry use 'cmd' etc:
                            HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders String value: Personal
                            which will return the path to the 'My Documents' folder in any locale...

                            YES, what TIG said! πŸ‘

                            Because I "think" XP and earlier used "My Documents",
                            and Vista (v6) and later (Win 7) uses "Documents" (more like UNIX, Linux and OSX.)
                            I'm not sure when the change occurs for Windows Server versions.

                            (a) You can call Reg.exe either thru a back-quoted string or IO.popen

                            (b) Use the standard Ruby library for Windows Registry
                            ENV['RUBYLIB'+'/lib/win32/registry.rb']
                            which relies upon Win32API.so

                            
                            def get_docs_dir
                              @dir=''
                            if RUBY_PLATFORM.include?('mswin')
                              reglib = ENV['RUBYLIB']+'/lib/win32/registry.rb'
                              if test( ?e, reglib )
                                require reglib # require uses absolute paths before iterating $;
                                key = 'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
                                Win32;;Registry;;HKEY_CURRENT_USER.open( key ) do |reg|
                                  @dir = reg['Personal']                               
                                end # let block end normally so key gets automatically closed
                              end
                            else
                              raise( NotImplementedError, 'Not a Windows Platform' )
                            end
                              return @dir
                            end # def
                            
                            

                            EDIT: changed string append to concat in line 4

                            I'm not here much anymore.

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

                              require 'win32dir.rb' true p Dir::DESKTOP "C:\\Users\\Thomas\\Desktop" nil p Dir::PERSONAL "C:\\Users\\Thomas\\Documents" nil p Dir::APPDATA "C:\\Users\\Thomas\\AppData\\Roaming" nil p Dir::LOCAL_APPDATA "C:\\Users\\Thomas\\AppData\\Local" nil

                              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:

                                [ruby]require 'win32dir.rb'

                                Where do you get 'win32dir.rb' ??
                                Looks like a Windows extension to the Dir base class.

                                I'm not here much anymore.

                                1 Reply Last reply Reply Quote 0
                                • J Offline
                                  Jim
                                  last edited by

                                  I'm almost sure it is from win32utils, but it must be an earlier version because the current version of the file has changed considerably.

                                  The current version has a list of dependencies on other libraries, while this version only requires win32api.so

                                  I've attached the version here that relies only on win32api.so

                                  I'd be interested if it returns the localized names of Dir::PERSONAL, et al.


                                  dir.rb

                                  Hi

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

                                    I think that on Vista/W7 they changed the windows folder to always be in English, but with an aliasing scheme for presenting them localized to the user in some cases. (I'm a bit confused on how it really is set up.)

                                    But on XP the folder names for sure is localised. I can try later today on my old laptop with Norwegian XP.

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

                                    1 Reply Last reply Reply Quote 0
                                    • J Offline
                                      Jim
                                      last edited by

                                      Hopefully, this file will work. It uses the system call ShGetFolderPath or ShGetSpecialFolerPath to retrieve the folder, so maybe the paths will be localized.

                                      @thomthom said:

                                      But on XP the folder names for sure is localised. I can try later today on my old laptop with Norwegian XP.

                                      I'd be interested to see if it works.

                                      Hi

                                      1 Reply Last reply Reply Quote 0
                                      • 1 / 1
                                      • First post
                                        Last post
                                      Buy SketchPlus
                                      Buy SUbD
                                      Buy WrapR
                                      Buy eBook
                                      Buy Modelur
                                      Buy Vertex Tools
                                      Buy SketchCuisine
                                      Buy FormFonts

                                      Advertisement