Using OpenSCAD Presets

If you use OpenSCAD to design keyguards, you can take advantage of Presets to save your customization options so that you don’t have to recreate them each time you want to modify a design or create a new design that is closely related to a design that you already have.

On this page we’ll describe how to save your customization options and where that data is stored.

You manage OpenSCAD presets via settings in the upper right corner of the OpenSCAD window – at the top of the Customizer pane (surrounded in red):

When you launch OpenSCAD, the presets region will look like this:

Leave “Automatic Preview” checked and leave “Show Details” selected.  The remaining five buttons are used to do the following:

  • “+” – the plus button allows you to define a new preset
  • “-” – the minus button allows you to delete a preset — be careful, if you press this button, the current preset is deleted without a warning
  • save preset – this button saves the current option changes for the current preset
  • reset – changes all options back to the last saved version of the current preset
  • “design default values” – this is the pull-down list where you access all your presets.  Every customization option in OpenSCAD starts with a default value.  The “design default values” preset represents the starting point for the keyguard.scad program.  As you add new presets, the list will expand.

Saving a New Design/Preset

As soon as you make a change to the default design, an asterisk will appear between the pull-down list of presets and the “+” button:

The asterisk indicates that the current customization settings are different from the last saved version of the current preset.  Note that changing the option back to its original value doesn’t make the asterisk disappear – OpenSCAD isn’t really comparing all settings, it just knows that a change was made once since the last save.

If you’re designing a new keyguard and want to save a copy of the changes you made press the “+” button.  A new window will appear:

This is where you provide a name for your preset (OpenSCAD is calling this a “parameter set”).  We recommend that you use the ID of your keyguard as the name of the preset.

Changing a Design/Preset

You can easily load all the customization options for a saved design/preset.  Just choose that preset from the pull-down list of presets:

If you modify any of the customization settings, you will again see an asterisk appear between the list and the “+” button:

If you want to preserve this change for the current design, simply press the “save preset” button.  The asterisk will go away.

On the other hand, if you’re designing a new keyguard and using an existing keyguard design as a starting point, press the “+” button, instead.  That will preserve the settings for the existing keyguard design and save all those settings plus the changes you’ve made to a new preset with a new name.

If you’ve made several changes and realize that you’ve made a mistake you can start over with the last saved version of the design by pressing the “Reset” button.  Note that all changes you’ve made since the last save will be lost.  There’s no “undo last change” feature in OpenSCAD.

Where are all the settings/parameters/presets saved?

OpenSCAD saves all the customization options for a design in a JSON file.  The file will be created by OpenSCAD the first time you save a preset.  The file is created in the same folder as keyguard.scad.  OpenSCAD will give it the same name (including version number) of the keyguard.scad program you are running and will put .json on the end of the name:

We’ve associated Notepad++ with the .json file type.  Every JSON file is a text file so it can be edited with any text editor.  You can look at the file but we don’t recommend changing it with your text editor.  Use OpenSCAD, itself, to edit this file.

Remember, when OpenSCAD launches, it looks for a file in the same folder with the name of the keyguard program it is running and a file type of .json.  So what do you do if you download a new version of keyguard.scad (say: keyguard_v99.scad)?  Just create a copy of the .json file and give it the same name as the new version (keyguard_v99.json).  All your saved presets will show up in the new keyguard designer.

Is every customization to a keyguard saved this way?

No – only the customizations to your design that you make via the Customizer pane in OpenSCAD are saved.  If your keyguard involves special features that you create in the openings_and_additions.txt file, those features are not saved as a preset.  You should ensure that any modifications you make to that file are copied to a folder for safe keeping.  We recommend that you create a folder for every keyguard you design and place the openings_and_additions.txt file in that folder.

You should periodically save the current .json file some place safe, just in case it gets deleted accidentally or you change a preset and save it when you intended to create a new preset instead.  This file can represent lots of work that can be a pain and error-prone to recreate.