omdl  v1.0
OpenSCAD Mechanical Design Library
Select Common 3d

Selection and configuration for common 3D shapes. More...

+ Collaboration diagram for Select Common 3d:

Files

file  select_common_3d.scad
 A standard selection and configuration scheme for common 3D shape construction.
 

Functions and/or Modules

module select_common_3d_shape (type=0, argv, center=false, verb=0)
 Select configure and construct one of the available 3d shapes. More...
 

Usage Details

Selection and configuration for common 3D shapes.

Requires:
include <omdl-base.scad>;
include <shapes/select_common_3d.scad>;

Function and/or Module Documentation

◆ select_common_3d_shape()

module select_common_3d_shape ( type  = 0,
argv  ,
center  = false,
verb  = 0 
)

Select configure and construct one of the available 3d shapes.

Parameters
type<integer> Shape type index.
argv<decimal-list | decimal> Shape dependent argument vector.
center<boolean> Center about origin.
verb<integer> Output verbosity (0-2).

This module provides a standard scheme for selecting and configuring the arguments of most 3D shapes available in the library, offering a consistent and flexible way to include, configure, and modify 3D shapes.

argv

Each shape is configured using the parameter argv. The four elements of this parameter are as follows:

e data type default value parameter description
0 decimal-list-n | decimal 1 size : shape size
1 decimal-list-n | decimal undef vr (sr) : shape rounding
2 integer-list-n | integer 0 vrm : shape rounding mode
3 integer 5 fn : shape rounding facets
4 integer 0 shape modifier

argv[4]: shape modifier

v modifier description
0 none

type

Dimensioning is shape dependent. The required dimensioning arguments for each supported shape are shown in the following table. All supported shapes and their associated arguments are summarized in the following table:

standard shape types

t shapes parameters shape reference
1 cylinder h, r1, r2 cylinder()
2 cone size cone()
3 cuboid size cuboid()
4 ellipsoid size ellipsoid()
5 ellipsoid section size, a1, a2 ellipsoid_s()
6 quadratic pyramid size pyramid_t()
7 triangular pyramid size pyramid_q()
8 star 3d size, n, half star3d()
100+ Polyhedrons database size (see below)

Selection example script

include <omdl-base.scad>;
include <shapes/select_common_3d.scad>;
r = 25;
h = 25;
size = [r, h];
a1 = 0;
a2 = 225;
type = 5;
argv = [[size, a1, a2]];
select_common_3d_shape(type=type, argv=argv, center=true);
// end_include
module select_common_3d_shape(type=0, argv, center=false, verb=0)
Select configure and construct one of the available 3d shapes.

Selection example diagram
topfrontdiag
expand topexpand frontexpand diag

custom shape types

t shapes parameters function invocation name
50 custom shape 1 size select_common_3d_shape_50()
51 custom shape 2 size select_common_3d_shape_51()
52 custom shape 3 size select_common_3d_shape_52()
53 custom shape 4 size select_common_3d_shape_53()
54 custom shape 5 size select_common_3d_shape_54()

User-defined custom shape functions can be selected by defining a shape function using one of the reserved custom shape function names, and then referencing the corresponding shape type listed in the table above. The custom function prototype and an example is provided below.

Prototype:

// custom shape module, type 50
module select_common_3d_shape_50(size, vr, vrm, fn, center)
{
};

Custom shape example script

include <omdl-base.scad>;
include <shapes/select_common_3d.scad>;
module select_common_3d_shape_50(size, vr, vrm, fn, center)
{
cube(size, center=center);
}
size = [50, 40, 30];
vr = undef;
vrm = undef;
fn = undef;
type = 50;
argv = [size, vr, vrm, fn];
select_common_3d_shape(type=type, argv=argv, center=true);
// end_include

Custom shape example diagram
topfrontdiag
expand topexpand frontexpand diag

Polyhedrons database inclusion

Requires:
include <omdl-base.scad>;
include <database/geometry/polyhedra/polyhedra_all.scad>;
include <shapes/polyhedron_db.scad>;
include <shapes/select_common_3d.scad>;

Polyhedra available through ph_db_polyhedron() may also be included in the 3d shape selection options. These shapes are accessible when the ph_db_polyhedron() module is included as shown under ‘Requires:’ above. As described in its documentation, a polyhedron database must also be included. In this example below, the polyhedra_all database is used; however, a smaller database may be configured instead, as described in the ph_db_polyhedron() documentation.

Polyhedrons database selection example script

include <omdl-base.scad>;
include <database/geometry/polyhedra/polyhedra_all.scad>;
include <shapes/polyhedron_db.scad>;
include <shapes/select_common_3d.scad>;
size = [10, 20, 20];
type = 122;
argv = [size];
select_common_3d_shape(type=type, argv=argv, center=true);
// end_include

Polyhedrons database selection example diagram
topfrontdiag
expand topexpand frontexpand diag

Definition at line 809 of file select_common_3d.scad.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: