OpenScad into Jupyter Notebook?

How to create a dockefile with jupyter notebook with a OpenScad kernel

Nicola Landro
2 min readJun 1, 2023

OpenScad is a 3D modelling software very useful for parametric creation of solids, it is also well usend in many thingiverse projects for 3D printing.

Jupyter notebook are very useful tool to write markdown and code to make easy to exaplain thing to people or also to document much well the code.

In this demo we will use OpenScad into jupyter Notebook and use Docker to run it. The repo of the full project can be founded here.

OpenScad into a jupyter notebook

How to run

In a computer with git and docker installed we can clone the codebase:

git clone https://gitlab.com/nicolalandro/openscadjupyternotebook.git
cd openscadjupyternotebook

We can go into the codebase and run docker-compose

docker-compose up
# or in newest version of docker
docker compose up

Go to localhost:8888 into your browser and you can see jupyter.

Jupyter first screen

Into the dockerfile

Start from python and install jupyter notebook and nbextension

FROM python:3.10

# Install Jupyter notebook
RUN apt-get update && apt-get install -y libzmq3-dev jupyter-notebook

# Configure jupyter plugin for install extension
RUN pip install --upgrade pip && pip install jupyter_contrib_nbextensions
RUN jupyter contrib nbextension install --system
RUN jupyter nbextensions_configurator enable --system

Install the openscad kernel:

# Configure Openscad kernel
RUN apt-get update && apt-get install -y xvfb openscad
RUN pip install --upgrade pip && pip install jupyter-openscad-kernel
RUN python3 -m iopenscad.install
# if you want to use jupyter lab you can also add this two line to have openscad app
# RUN jupyter labextension install jupyterlab-viewer-3d
# RUN jupyter labextension install jupyterlab-openscad-syntax-highlighting

Configure SOS to make notebook with multiple languages

# Configure SOS
RUN pip install --upgrade pip && pip install sos-notebook
RUN python3 -m sos_notebook.install

Specify the workdir and the run command:

WORKDIR /notebooks
CMD jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root --NotebookApp.token=''

Conclusions

This new kernel is another that we can add to the long list: rust, coq and many other unthinkable kernels are waiting you!

Again the opensource software offer to us much coiches and opportunities so continue to use it and if you want, contribute!

--

--

Nicola Landro

Linux user and Open Source fun. Deep learning PhD. , Full stack web developer, Mobile developer, cloud engineer and Musitian.