Drafting and drawing tools.
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.
include <omdl-base.scad>;
include <tools/align.scad>;
include <tools/operation_cs.scad>;
include <tools/drafting/draft-base.scad>;
(
[
["line-use-hull", false],
[
"dim-leader-length",
length(3)],
[
"dim-line-distance",
length(3)],
[
"dim-line-extension-length",
length(5)]
],
);
(
[
[[-1, 1]], [[1, 1]], [[-1,-1]], [[1, -1]],
[[0, 1/2], ["H","4"]], [[1, 0], ["H","1"]]
]
)
{
(
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;
a1 = 47.5;
t2 = 5;
function bev(p, a, o, r) = [p, p+r*[cos(a+o), sin(a+o)], p+r*[cos(a-o), sin(a-o)]];
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);
}
for (i=[0:360/t2:360])
translate(o2*[cos(i), sin(i)])
circle(r=r4);
}
color("black")
{
{
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);
}
bt = bev([0, r1-o1-r3], 90, a1, r3);
draft_dim_leader(p=[o2,0], l1=10, v2=0, l2=15, ts=[2,1.5], t=[str(
"D ", r4), str(
"X ", t2)]);
}
}
x_axis2d_uv
<vector-2d> The unit vector of the positive x-axis in 2d Euclidean space.
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.
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.
length_unit_base
<string> The base units for value storage.