omdl  v0.9.5
OpenSCAD Mechanical Design Library
Drafting

Drafting and drawing tools. More...

+ Collaboration diagram for Drafting:

Modules

 Config
 Drafting defaults and configurations.
 
 Dimension
 Drafting dimension operations.
 
 Operations
 Drafting tools and general operations.
 
 Primitives
 Drafting base functions and primitives.
 

Files

file  draft-base.scad
 Drafting include wrapper.
 

Detailed Description

Drafting and drawing tools.

Requires:
include <omdl-base.scad>;
include <tools/align.scad>;
include <tools/operation_cs.scad>;
include <tools/polytope.scad>;
include <tools/drafting/draft-base.scad>;

This module provides basic 2D drafting tools. Below is an example output (png and svg format) and script. Numerous ways exists to generate a printable form of the 2D result. For example: (1) Render the 2D design. (2) Export as DXF. (3) Open the exported DXF file using LibreCAD. (4) Select print preview and change the print scale as needed for the sheet size and target output page. (5) Finally print or save a PDF file.

Drafting example diagram
top
expand top

Drafting example script

include <omdl-base.scad>;
include <tools/align.scad>;
include <tools/operation_cs.scad>;
include <tools/drafting/draft-base.scad>;
draft_layers_show = ["default", "sheet", "titleblock", "table", "note", "dim"];
//draft_layers_show = ["default", "dim"];
//draft_layers_show = ["default"];
(
[ // override defaults
["line-use-hull", false],
["dim-offset", length(3)],
["dim-leader-length", length(3)],
["dim-line-distance", length(3)],
["dim-line-extension-length", length(5)]
],
);
draft_sheet(grid=0);
(
[
[[-1, 1]], [[1, 1]], [[-1,-1]], [[1, -1]],
[[0, 1/2], ["H","4"]], [[1, 0], ["H","1"]]
]
)
{
draft_ruler(order=[1,-1], label_hide=true);
draft_ruler(order=-1, label_hide=true);
(
text=
[
["SPROCKET", "LOWER REAR SECTION, ASSEMBLY 2 OF 3"],
"02/22/2019", "RAS", "X1234567890", "1", "",
["ABS", "BLACK"], "STANDARD", "RAS", "SAR",
"3 COPIES REQUIRED", "APPROX. 30 MINUTE BUILD TIME",
["UNLESS STATED OTHERWISE ALL", "DIMS ARE +/- 0.25", "ANGLES +/- 1", "REMOVE ALL BURRS"]
],
zp=[1,-1], number=false
);
(
map=
[
[ "title", [ "REVISIONS", 3/2 ] ],
[ "heads", [ ["DATE", "REV", "REF", "AUTH"], 3/4 ] ],
[ "cols", [ 3, 2, 2, 2 ] ],
[ "rows", [ [ ["01-01-19", "R0", "X0", "RAS"], 1 ],
[ ["01-14-19", "R1", "X1", "RAS"], 1 ],
[ ["01-21-19", "R2", "X2", "RAS"], 1 ]
]
]
],
zp=[-1,-1]
);
(
head="NOTE:",
note=["INSTALL SPROCKET", "BEFORE HUB-S32", "SEE: X1234567891"],
size=[7, 2, 3/4],
zp=[-1/2,0]
);
}
t1 = 12;
r1 = length(50);
r2 = length(25);
o1 = length(2);
r3 = length(10);
a1 = 47.5;
t2 = 5;
o2 = length(32);
r4 = length(4);
function bev(p, a, o, r) = [p, p+r*[cos(a+o), sin(a+o)], p+r*[cos(a-o), sin(a-o)]];
draft_move ( [ [[1, -1/2], ["E","3"]] ] )
union()
{
difference()
{
circle(r=r1);
circle(r=r2);
for (i=[0:360/t1:360])
{
p1 = (r1-o1)*[cos(i), sin(i)];
p2 = (r1-o1-r3)*[cos(i), sin(i)];
translate(p1) circle(r=r3);
polygon(bev(p2, angle_ll(x_axis2d_uv, p2), a1, r3*2));
}
for (i=[0:360/t2:360])
translate(o2*[cos(i), sin(i)])
circle(r=r4);
}
color("black")
{
draft_in_layers(["dim"])
{
draft_arc(r=r1, s=2, v1=360/t1*2.25, v2=360/t1*0.25);
draft_arc(r=r1-o1, s=2, v1=360/t1*8, v2=360/t1*5);
draft_arc(r=o2, s=2, fn=72);
draft_arc(c=[o1-r1, 0], r=r3, s=2, fn=72);
}
draft_dim_center(c=[o1-r1, 0], r=r3, v=45);
draft_dim_radius(r=r1, v=360/t1*1);
draft_dim_radius(r=r1-o1, v=360/t1*7);
draft_dim_radius(r=o2, v=360/t2*4.5, u="in");
draft_dim_radius(c=[o1-r1, 0], r=r3, v=0, d=true, o=0);
draft_dim_angle(r=r1*(1+1/8), v1 = 360/t2*(t2-1));
bt = bev([0, r1-o1-r3], 90, a1, r3);
b1 = first(bt); b2 = second(bt); b3 = third(bt);
draft_dim_angle(c=b1, r=r3*2, v1=[b1, b3], v2=[b1, b2], e=1+1/10);
draft_dim_line(p1=[0,r1-o1-r3], d=r1*1.4, e=[r1*1.35, r1/4], u="mm");
draft_dim_leader(p=[o2,0], l1=10, v2=0, l2=15, ts=[2,1.5], t=[str("D ", r4), str("X ", t2)]);
}
}
// end_include
x_axis2d_uv
<vector-2d> The unit vector of the positive x-axis in 2d Euclidean space.
Definition: constants.scad:410
function angle_ll(l1, l2, s=true)
Compute the angle between two lines or vectors in a 3d or 2d-space.
function third(v)
Return the third element of an iterable value.
function second(v)
Return the second element of an iterable value.
function first(v)
Return the first element of an iterable value.
function map_merge(m1, m2)
Merge the unique key-value pairs of a second map with those of a first.
draft_layers_show
<string-list> List of active drafting layer names.
Definition: config.scad:554
$draft_scale
<integer> Line construction drafting scale multiplier.
Definition: config.scad:98
draft_table_format_map_ccc
<map> Table format map; centered, centered, centered –justified.
Definition: config.scad:1258
draft_config_map
<map> Drafting configuration defaults map.
Definition: config.scad:860
draft_sheet_size
<string> Drafting sheet size identifier.
Definition: config.scad:318
draft_sheet_scale
<integer> Sheet construction drafting scale multiplier.
Definition: config.scad:101
draft_config_map_style1
<map> A drafting configuration map; style1.
Definition: config.scad:715
module draft_dim_line(p1=origin2d, p2=origin2d, v1, v2, t, u, d=draft_get_config("dim-line-distance"), e=draft_get_config("dim-line-extension-length"), es=draft_get_config("dim-line-extension-style"), w=draft_get_config("dim-line-weight"), s=draft_get_config("dim-line-style"), a=draft_get_config("dim-line-arrow"), a1, a2, o=draft_get_config("dim-offset"), ts=draft_get_config("dim-text-size"), tp=draft_get_config("dim-text-place"), rm=draft_get_config("dim-round-mode"), cmh=draft_get_config("dim-cmh"), cmv=draft_get_config("dim-cmv"), layers=draft_get_config("layers-dim"))
Construct a dimension line between two points.
Definition: dimension.scad:372
module draft_dim_center(c=origin2d, r, v=0, l=draft_get_config("dim-center-length"), e, es=draft_get_config("dim-angle-extension-style"), w=draft_get_config("dim-center-weight"), s=draft_get_config("dim-center-style"), layers=draft_get_config("layers-dim"))
Construct a center mark dimension cross.
Definition: dimension.scad:949
module draft_dim_leader(p=origin2d, v1=30, l1=draft_get_config("dim-leader-length"), v2, l2, h, t, ts, tp, tr, ta="center", bw=draft_get_config("dim-leader-box-weight"), bs=draft_get_config("dim-leader-box-style"), w=draft_get_config("dim-leader-weight"), s=draft_get_config("dim-leader-style"), a=draft_get_config("dim-leader-arrow"), o=draft_get_config("dim-offset"), cmh=draft_get_config("dim-cmh"), cmv=draft_get_config("dim-cmv"), window=false, layers=draft_get_config("layers-dim"))
Construct a dimension leader line at a point.
Definition: dimension.scad:220
module draft_dim_angle(c=origin2d, r=1, v1, v2, fn, cw=false, t, u, e=draft_get_config("dim-angle-extension-ratio"), es=draft_get_config("dim-angle-extension-style"), w=draft_get_config("dim-angle-weight"), s=draft_get_config("dim-angle-style"), a=draft_get_config("dim-angle-arrow"), a1, a2, o=draft_get_config("dim-offset"), ts=draft_get_config("dim-text-size"), tp=draft_get_config("dim-text-place"), rm=draft_get_config("dim-round-mode"), cmh=draft_get_config("dim-cmh"), cmv=draft_get_config("dim-cmv"), layers=draft_get_config("layers-dim"))
Construct a angular dimension arc.
Definition: dimension.scad:776
module draft_dim_radius(c=origin2d, p, r=1, v, t, u, d=false, w=draft_get_config("dim-radius-weight"), s=draft_get_config("dim-radius-style"), a=draft_get_config("dim-radius-arrow"), a1, a2, o=draft_get_config("dim-offset"), ts=draft_get_config("dim-text-size"), tp=draft_get_config("dim-text-place"), rm=draft_get_config("dim-round-mode"), cmh=draft_get_config("dim-cmh"), cmv=draft_get_config("dim-cmv"), layers=draft_get_config("layers-dim"))
Construct a radial dimension line.
Definition: dimension.scad:575
module draft_title_block(text, map=draft_title_block_map_style1, zp=0, number=false, window=false, layers=draft_get_config("layers-titleblock"))
Construct a sheet title block.
module draft_sheet(sheet, frame, zone, grid, origin, check=false, layers=draft_get_config("layers-sheet"))
Construct a drafting sheet with frame, zone, grid, and origin.
Definition: operation.scad:308
module draft_ruler(units="mm", marks=10, groups=5, mark_size=1, group_height=5, label_scale=2/3, label_hide=false, order=1, w=1, layers=draft_get_config("layers-sheet"))
Construct a drafting sheet ruler.
Definition: operation.scad:648
module draft_move(list)
Move one or more child objects to sheet a reference zone.
Definition: operation.scad:225
module draft_table(map, fmap, zp=0, window=false, layers=draft_get_config("layers-table"))
Construct a text table that is populated by rows and columns.
Definition: operation.scad:753
module draft_note(head, note, size, line, halign="left", cmh=draft_get_config("note-cmh"), cmv=draft_get_config("note-cmv"), zp=0, window=false, layers=draft_get_config("layers-note"))
Construct a text note with optional heading and boarder.
module draft_in_layers(layers=draft_get_config("layers-default"))
Assign one or more layers to child objects.
Definition: operation.scad:181
module draft_arc(r=1, c=origin2d, v1=x_axis2d_uv, v2=x_axis2d_uv, fn, cw=true, w=1, s=1, a1=0, a2=0)
Draft an arc with configurable style and optional arrowheads.
function length(v, from=length_unit_default, to=length_unit_base, d=1)
Convert a value from from one units to another with dimensions.
length_unit_default
<string> The default units when unspecified.
Definition: length.scad:739
length_unit_base
<string> The base units for value storage.
Definition: length.scad:736