Home

Awesome

OpenSCAD for VS Code

Edit OpenSCAD files with all the luxuries of VSCode! Works with OpenSCAD v2019.05.

Project is available at: https://github.com/Antyos/vscode-openscad

This extension builds upon the "scad" extension by Erik Benson and later expanded upon by GitHub user atnbueno https://github.com/atnbueno/vscode-lang-scad

Features

This extension features:

Highlighting comparison

VSCode with OpenSCAD PluginOpenSCAD Editor
comparison-vsccomparison-os

Code: https://files.openscad.org/examples/Basics/intersection.html

Customizer Syntax

Highlights customizer keywords in comments! As of OpenSCAD v2019.5, OpenSCAD itself does not currently do this.

customizer-highlights

Preview Files

Click the Preview in OpenSCAD button to instantly launch and preview your file in OpenSCAD!

Check usage section for more information.

openscad-preview

Export Files

Click the Export Model button to export your model to any of the supported file types! (stl, 3mf, dxf, etc.)

You can also set a naming scheme to automatically name exported files. See Auto-Exporting.

openscad-export

Built-in Cheatsheet

Launch the built-in OpenSCAD cheatsheet with the command Open OpenSCAD Cheatsheet or with the button in the status bar!

open-cheatsheet

Usage

Make sure you have installed OpenSCAD here: https://www.openscad.org/downloads.html

If you install OpenSCAD to the default location for you system, the extension should automatically detect it. If not, you will need to set the openscad.launchPath configuration option in Settings > Extensions > OpenSCAD > Launch Path or by adding the following line to your settings.json file:

{
    "someSetting": "",
    "openscad.launchPath": "path/to/openscad"
}

Note: If you are using Windows, make sure to specify the path to openscad.exe so the extension can properly manage open previews and exports.

To preview a .scad file, you can use the Preview in OpenSCAD command which can be accessed via the Command Pallette, the button in the editor title bar, or by right clicking the file in the title bar or explorer and choosing it from the context menu.

In OpenSCAD, make sure to have Automatic Reload and Preview checked under Design > Automatic Reload and Preview. You may also want to hide the editor and customizer panels in OpenSCAD by checking View > Hide Editor and View > Hide Customizer.

When you save your file in VSCode, OpenSCAD will automatically reload and preview the updated file.

For more information, see: Using an external Editor with OpenSCAD

To-Do

Note: Italicized items on the to-do list are more challenging and I do not know when (if ever) I will get to them.

Changelog

See the changelog here.

Contributing

I made this extension because I like OpenSCAD and there wasn't any language support in VS Code I liked. I currently maintain this extension as a side project, so I can't promise when I will get to adding new features. With that being said, please feel free to submit a pull request!

If you would like to contribute, here's what you can do:

  1. Fork the repository: https://github.com/Antyos/vscode-openscad.git
  2. Install pnpm
  3. Run pnpm install to download node modules
  4. Make changes
  5. Submit a pull request!

Contributing to the Grammar

VSCode can only read tmLanguage files in xml or json format. If you want to make changes to the grammar in the .yaml-tmlanguage file, you will need to convert it to .json before VSCode can use it.

Assuming you have followed the steps above to obtain a local copy of the extension, run the update-grammar script to convert syntaxes/scad.yaml-tmlanguage to syntaxes/scad.tmlanguage.json