Openscad coding techniques

von phildc

Druckbare Dateien (9)

Beschreibung

Openscad coding techniques.

First chapter: module
Demonstrating an Openscad coding technique that combines translate, rotate and definition
in a short form, using a "module" definition.

Added a "vectorized" version based on my understanding of a comment from Bikecyclist. Looks more readable.

Second chapter A pre-coded OpenScad input.

For the last complete version, choose: OSCAD-TEMPLATE.scad

You get a pre-coded combination of primitives (cubes, cylinders, cones and spheres), along with the possibility to import an existing STL file. The operations are unions and differences. Intersections are not (yet ?) supported. The parameters are set in a way that nothing happens until you change some of them.

===================================================================
This is a full code where you just need to change some values to get a result.
You are first in an additive stage, where you can build a part with 2 Openscad "cubes" and 2 cylinders.
In a second stage you remove cubes and cylinders.
In a third you can again add, and finally subtract in a last operation.

Just leave all unused parts size to 0.
The example was done with less than a dozen modifications to the original template.

Template2 will add the possibility to use spheres.

Of course, you are free to add, duplicate modules as necessary to fit your own needs.
Also you can add '#' signs to identify a part, and maybe add other instructions like 'scale' if you need.

Rendering may be lengthy, so delete unnecessary code in your particular project.

In your job preparation, you can refer to the numbers 2A to 5F of the parts to be added and subtracted in the successive 'machining' operations.

V3: cones added
The very simple NEM coupling box just needs entering 6 values

V4: the sphere and cylinder can be scaled, giving an ogival part. Aug.16, 2020
Refer to explain-V4.rtf for explanations

V5 adds a simple import function, to work on an existing STL file.

==================================================
Chapter 3: import stl

Use the import function along the animate function to check the fitting of two (or more) parts.
The coding of the "imp" module allows to easily position the parts in cartesian and angular way.

====================================================
Extrusions:
Added linear and rotate extrusion templates, to help you code