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

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

+ Collaboration diagram for Select Common 2d:

Files

file  select_common_2d.scad
 A standard selection and configuration scheme for common 2D shape construction.
 

Functions and/or Modules

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

Usage Details

Selection and configuration for common 2D shapes.

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

Function and/or Module Documentation

◆ select_common_2d_shape()

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

Select configure and construct one of the available 2d 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 2D shapes available in the library, offering a consistent and flexible way to include, configure, and modify 2D 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 1 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 circle r circle()
2 ngon r, n pg_ngon()
3 rectangle size pg_rectangle()
4 rectangle sr size pg_rectangle_rs()
5 rhombus size pg_rhombus()
6 elliptical sector r, v1, v2 pg_elliptical_sector()
7 triangle vertices v1, v2, v3 pg_triangle_ppp()
8 triangle sides s1, s2, s3 pg_triangle_sss()
9 star size, n star2d()
10 corner round r, m, v1, v2 pg_corner_round()

Selection example script

include <omdl-base.scad>;
include <shapes/select_common_2d.scad>;
size = [50, 40, 30];
vr = [1, 5, 5];
vrm = [1, 1, 5];
fn = 9;
type = 8;
argv = [size, vr, vrm, fn];
select_common_2d_shape(type=type, argv=argv, center=true);
// end_include
module select_common_2d_shape(type=0, argv, center=false, verb=0)
Select configure and construct one of the available 2d shapes.

Selection example diagram
top
expand top

custom shape types

t shapes parameters function invocation name
50 custom shape 1 size select_common_2d_shape_50()
51 custom shape 2 size select_common_2d_shape_51()
52 custom shape 3 size select_common_2d_shape_52()
53 custom shape 4 size select_common_2d_shape_53()
54 custom shape 5 size select_common_2d_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_2d_shape_50(size, vr, vrm, fn, center)
{
};

Custom shape example script

include <omdl-base.scad>;
include <shapes/select_common_2d.scad>;
module select_common_2d_shape_50(size, vr, vrm, fn, center)
{
square(size, center=center);
}
size = [50, 40];
vr = undef;
vrm = undef;
fn = undef;
type = 50;
argv = [size, vr, vrm, fn];
select_common_2d_shape(type=type, argv=argv, center=true);
// end_include

Custom shape example diagram
top
expand top

Definition at line 561 of file select_common_2d.scad.

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