sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    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.
    • daikuD Offline
      daiku
      last edited by

      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

        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

          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
          • daikuD Offline
            daiku
            last edited by

            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

              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
              • daikuD Offline
                daiku
                last edited by

                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

                  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
                  • Didier BurD Offline
                    Didier Bur
                    last edited by

                    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
                    • daikuD Offline
                      daiku
                      last edited by

                      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

                        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
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement