• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

How to save user settings across sessions?

Scheduled Pinned Locked Moved Developers' Forum
10 Posts 5 Posters 1.8k 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.
  • D Offline
    daiku
    last edited by 26 Nov 2007, 23:40

    I'd like users of my script to be able to set some parameters that affect the behavior of the script, and I'd like those to be saved across sessions. What's the best way to accomplish that? Can you manipulate the registry from within a ruby script? (Windows specific, anyway, so not the best option). A pointer to an example script would be fine. Thanks, CB.

    Clark Bremer
    http://www.northernlightstimberframing.com

    1 Reply Last reply Reply Quote 0
    • A Offline
      azuby
      last edited by 26 Nov 2007, 23:41

      What's the best way depends on your needs. Some people need the Windows Registry, some people like files (ini, xml). If you want to use files, you have to implement the algorithm on your own or load the third party Ruby modules for these jobs like REXML.

      azuby

      *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

      Bad English? PM me, correct me. :smile:**

      1 Reply Last reply Reply Quote 0
      • R Offline
        RickW
        last edited by 26 Nov 2007, 23:42

        I recommend you investigate the Sketchup class . It should prove enlightening on this point.

        RickW
        [www.smustard.com](http://www.smustard.com)

        1 Reply Last reply Reply Quote 0
        • D Offline
          daiku
          last edited by 26 Nov 2007, 23:43

          I See. I assume you are referring to read_defaults and write_defaults? Does this work across platforms? I don't see where you specify the file name, so it must use a central database that the whole sketchup application uses? Thanks, Rick - I'll experiment. CB.

          Clark Bremer
          http://www.northernlightstimberframing.com

          1 Reply Last reply Reply Quote 0
          • T Offline
            todd burch
            last edited by 26 Nov 2007, 23:44

            Yes, it works across platforms. In Windows, it goes into the Registry. On the Mac... I don't know. Perhaps the .plist file. I haven't snooped around enough on the Mac yet.

            Windows has issues with certain characters whne saving to the Registry, so test your values that get saved and retrieved. You may need to encode them somehow.

            Todd

            1 Reply Last reply Reply Quote 0
            • D Offline
              daiku
              last edited by 26 Nov 2007, 23:45

              That worked great for me, guys. Thanks a lot. Rick, I found a good example in your dashed lines script. I noticed that you had dropdowns in your inputbox, and figured out how you did it (not documented in the SU Ruby docs?). I have several Y/N options, but I could only get one drop-down box to work on a given inputbox. Is that a known limitation, or am I doing something wrong? CB.

              Clark Bremer
              http://www.northernlightstimberframing.com

              1 Reply Last reply Reply Quote 0
              • T Offline
                todd burch
                last edited by 26 Nov 2007, 23:45

                Hi Clark. There is a dropdowns.rb script floating around somewhere that shows how to do mutiple dropdowns in a given dialog. (I wrote it, and dashed lines too!) Check the Didier's Depot, or the old SU Ruby Forum.

                Todd

                1 Reply Last reply Reply Quote 0
                • D Offline
                  Didier Bur
                  last edited by 26 Nov 2007, 23:46

                  Alternativelyn you could use attributes to store data within the SKP. That's the best way IMHO to save parameters (platform independent).
                  Regards,

                  DB

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    daiku
                    last edited by 26 Nov 2007, 23:46

                    Todd: Thanks for the tip, and sorry for assuming that what I found at smustard would be Rick's. I use Dashed lines all the time. Thanks for that, too. CB.

                    Clark Bremer
                    http://www.northernlightstimberframing.com

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      RickW
                      last edited by 26 Nov 2007, 23:47

                      I use attributes to store data in a model when it's relevant to the model (like in my ToDoList plugin). But something that would be comparable to a "global" setting is best (IMO) put into something external - registry/ini file/other text file.

                      RickW
                      [www.smustard.com](http://www.smustard.com)

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

                      Advertisement