Im my last Blog I was using some functionality from https://dkprojects.net/openscad-threads/ in order to define a nut and a bolt. I was finding this library with the help of Google.

Like with any software language, it does not make sense if you try to re-invent the wheel (though some key stakeholders of the project actually think that everybody should write their’s own library).

In any case it is worth to check out if some components already exist before you invest a lot of time to build something new.

Revision Management

It is a precondition to have an explicit support for change management: We should be able to define the version of the library that is used. Though it is possible to mess around with local files and clone projects from github – this is definitely not our preferred way because we have the goal, that a workbook produces consistent results wherever it is executed and this is quite difficult if we would need to rely on some local files.

When using the Jupyter OpenSCAD Kernel we therefore propagate the following approach :
– Versioned Libraries are preferably stored on Github (or any other system which allows to access it’s resources with a versioned URL)
– We provide the %include and %use magic commands which load the content from an URL
– It is up to the designer to decide if he wants to include the library from the head (and have the latest code) or from a specific version. We recommend to pin the included library to a specific version, so that your design is not broken when the library changes

Examples:

%include https://raw.githubusercontent.com/revarbat/BOSL/v1.0.1/linear_bearings.scad
%include https://raw.githubusercontent.com/revarbat/BOSL/master/linear_bearings.scad

The first line loads the v1.0.1; the second the master branch version.

In addition to using external libraries
– We can save the complete OpenSCAD code with the help of %saveAs magic function – This will explicitly provide the fully resolved OpenSCAD code that does not contain any include or use statement any more, and therfore is frozen in time.
– You can use to one of the Jupyterlab GIT Extensions to manage your versions of the Notebook and any related saved file format in scad, STL, etc.

I think this proposal makes a lot of sense since most libraries are in fact available on Github. This brings us back to https://dkprojects.net/openscad-threads, which is actually violating our priciples because we only have access to the latest version and it is up to the individual designer to make a judgment if he can take the (small) risk of a breaking change.

Includes in OpenSCAD

I really think that the support of URLs (and not only files) should be a basic OpenSCAD functionality. There is a feature Request from the year 2010 for this. Now after 10 years this is still missing…

Libraries Overview

In my next posts I would like to give an quick overview and introduction of the most important libraries:
– BOSL
– dotSCAD
– NopSCADlib
– BOLTS
– MCAD


0 Comments

Leave a Reply

Your email address will not be published.