• Login
sketchucation logo sketchucation
  • Login
πŸ”Œ Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

Where to Store User Settings?

Scheduled Pinned Locked Moved Developers' Forum
29 Posts 7 Posters 1.7k Views 7 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.
  • D Offline
    Dan Rathbun
    last edited by 30 Oct 2011, 08:31

    @jim said:

    Just wondering if it is wise to use the "APPDATA/Google/SketchUp X" sub-folder name because it is what is actually used by Google SketchUp.

    (1) It's actually %(#8000BF)[%APPDATA%] in command scripts, and ENV['APPDATA'] in Ruby.

    (2) This location is meant to be hidden from the user. But an Administrator can make the dir visible easily on XP, but not so easily on Win 6+. One advantage is that Windows Migration wizard can copy files from APPDATA folders when upgrading to newer OS versions, or to another computer. Note that the %(#8000BF)[%APPDATA%] path is the "roaming" profile (which is OK, especially for a network setup, where the user may logon to any one of many workstations. This is in contrast to the %(#8000BF)[%USERPROFILE%/Local Settings/Application Data] path, which is specific to a particular computer or workstation. XP does not have a environment var that points at this, but Win6+ does: %(#8000BF)[%LOCALAPPDATA%] )
    IF you wish the user to easily see any of these settings, you'd need to make a "log viewer" webdialog, or a GUI dialog.

    @jim said:

    Why wouldn't the settings for my plugin go right in (something like) "APPDATA/Jim Foltz/JF Plugins/My Plugin Name/"

    It could, ie, something like:

    # within your plugin module namespace;
    if RUBY_PLATFORM =~ /(darwin)/
      APPDATA = File.join('Users',ENV['USER'],'Library/Application Support')
      # or; APPDATA = File.join('~','Library/Application Support')
      # or; APPDATA = File.join(ENV['HOME'],'Library/Application Support')
    else # Windows
      APPDATA = File.join( ENV['APPDATA'],'Google' )
    end
    SUFFIX = "Google SketchUp #{Sketchup.version.to_i.to_s}/SketchUp/Plugins"
    APPDATA = File.join(APPDATA,SUFFIX)
    Dir.mkdir(APPDATA) unless Kernel.test(?d,APPDATA)
    PLUGDIR = 'SomeString'
    SUBPATH = 'Jim Foltz/JF Plugins'
    @@datapath = File.join(APPDATA,SUBPATH,PLUGDIR)
    Dir.mkdir(@@datapath) unless Kernel.test(?d,@@datapath)
    

    I'm not here much anymore.

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 30 Oct 2011, 08:36

      OH.. sorry Jim... I missed the real question in your query.

      You want to use YOUR OWN company name folder "Jim Foltz" instead of the "Google" dir...
      .. and then whatever subfolders you wish to organize below that.

      Well YES, IMHO... no problem there. Keep it separate and protected from inadvertant cleansing (such as when someone tries to cleanup their system for a "clean" reinstall of Sketchup.)

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by 24 Nov 2011, 10:42

        Here's an article with some more specific info for working with several recent versions of Windows.

        What’s the Recommended Location for Application Files?

        The article only confirms what has already been said here: %APPDATA% is the correct folder (or better to use your own sub-folder under %APPDATA%.)

        Hi

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 24 Nov 2011, 10:56

          But roaming or local?

          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 24 Nov 2011, 10:59

            Why not always roaming? Is there a specific case for local?

            I might use local if the file(s) were for a license key tied to a specific machine. But otherwise, I can't think of a reason not to use roaming.

            Hi

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 24 Nov 2011, 11:13

              Yea - I wasn't sure if roaming could be used if the user where not on a domain. (I don't have any experience with that kind of stuff...)

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

              1 Reply Last reply Reply Quote 0
              • T Offline
                TIG Moderator
                last edited by 24 Nov 2011, 11:27

                ENV["APPDATA"] returns the PC User's 'Roaming' folder anyway... πŸ˜•

                TIG

                1 Reply Last reply Reply Quote 0
                • K Offline
                  kirill2008
                  last edited by 25 Nov 2011, 11:41

                  I think it is possible to store user settings right in *.skp file. Why not? AutoCAD stores a lot of settings (a plenty of settings) in *.dwg file for example.
                  I'm not sure about problems with such approach, but it works well for some of user settings. I use "Sketchup.active_model.set_attribute" to store user settings.
                  Ok, it's not ideal solution of course: it increases file size, I guess. And it does not fit for user settings, that have to be insensitive for *.skp file. And a lot of excess data will be attached to each *.skp file instead of single *.ini file.

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    thomthom
                    last edited by 25 Nov 2011, 11:54

                    @kirill2008 said:

                    I think it is possible to store user settings right in *.skp file. Why not? AutoCAD stores a lot of settings (a plenty of settings) in *.dwg file for example.
                    I'm not sure about problems with such approach, but it works well for some of user settings. I use "Sketchup.active_model.set_attribute" to store user settings.
                    Ok, it's not ideal solution of course: it increases file size, I guess. And it does not fit for user settings, that have to be insensitive for *.skp file. And a lot of excess data will be attached to each *.skp file instead of single *.ini file.

                    That would then not be User data - but Model data. Two very different things.

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

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      TIG Moderator
                      last edited by 25 Nov 2011, 12:02

                      User data specific to Sketchup can be stored with Sketchup itself in the Registry [Plist on Mac] ?
                      Sketchup.write_default(section,variable{,optional_default}) Sketchup.read_default(section,variable,value)
                      You obviously need to 'compile' the value[s] to write and read back in specific ways.
                      If there are 'many things' to keep across sessions then a saving them into a Users/Name/AppData/Roaming/ Sketchup subfolder, inside a tool specific subfolder or ini file etc would also be possible - not sure about Mac alternative...

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • K Offline
                        kirill2008
                        last edited by 25 Nov 2011, 17:55

                        @thomthom said:

                        That would then not be User data - but Model data. Two very different things.

                        Looks like I interpreted thread subject in a context of my own thoughts 😳
                        I mean, I was going to suggest to use template for storing user settings data.
                        template.png
                        It is less elegant than just click "OK" button in "Settings" dialog of the plugin, of course πŸ˜„ But the user can save his own presets in template file, add description to it, then it will be possible to revert back to any previously saved configuration.

                        UPD.
                        The point is that I was thinking about abstract "application user" not the operating system user. Application means plugin here.
                        So I thought that application (plugin) usually runs "system wide" (not in "per user mode") and the problem is what is the best way to persist application settings (i.e. user preferences *application user here again).
                        Storing plugin settings right in document allows user preferences persistence across different machines and even across operating systems in theory πŸ˜‰ (when I say "user" I mean plugin user). So user can take his *.skp file anywhere and continue working with it on any device that has SU and plugin πŸ˜„ and he does not have to care about configuring plugin again on each device.

                        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