OpenSCAD support

OpenSCAD is a software for creating solid 3D CAD objects. It uses a scripting language to describe the CSG operations performed on the solids. We have full support for this file format and also support the parametrization annotations proposed in CloudSCAD as well as a few of our own. Namely, by adding special formatted comments around global variables definitions, it is possible to turn them into design parameters. This feature makes it very simple to turn any OpenSCAD file into a configurable Sculpteo design.

Parametrization

OpenSCAD file variables can be turned into parameters by adding a comment above it describing the parameter and optionnally another comment at the end of the line describing its type and range. For example:

// angle in degree
AX=90;

The following code defines a parameter “AX” described by “angle in degree” in the customization page, and with default value 90. Without other information, the parameter is presented as a text input. To use other types of input, another comment may be added at the end of the line.

// angle in degree
AX=90; // [45:90]

This code will present the parameter as a slider ranging from 45 to 90. Finally it is possible to present a list of choices like so:

// angle in degree
AX=90; // 30,45,60,90

or to name the available choices like so:

// angle in degree
AX=90; // 30:Thirteen,45:Fourty five,60:Sixty,90:Ninety

Example

A sphere minus two cylinders of customizable angle

Download

// angle X
AX=90;
// angle Y
AY=90; // [45:90]

module example001(anglex,angley)
{
    function r_from_dia(d) = d / 2;

    module rotcy(rot, r, h, angle) {
        rotate(angle, rot)
            cylinder(r = r, h = h, center = true);
    }

    difference() {
        sphere(r = r_from_dia(size));
        rotcy([0, 0, 0], cy_r, cy_h, 90);
        rotcy([1, 0, 0], cy_r, cy_h, anglex);
        rotcy([0, 1, 0], cy_r, cy_h, angley);
    }

    size = 50;
    hole = 25;

    cy_r = r_from_dia(hole);
    cy_h = r_from_dia(size * 3);
}
example001(anglex=AX,angley=AY);
Prev: Using JavaScript for scripting designs Next: Tutorials

» webapi documentation » Creating Parametric Designs » OpenSCAD support

Last update: 1970-01-01 01:00 (CET)