1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-09-03 12:22:46 +02:00

Compare commits

...

12 Commits

Author SHA1 Message Date
Chris Palmer
bab4c8e8af TO247_size() now also returns lead height and the length of the wide bit.
TO247 leads fixed at 3.
Lead length removed from TO220 and TO247 vitamin string.
2021-09-29 10:42:37 +01:00
Chris Palmer
c449dd0a24 Updated changelog. 2021-09-27 17:50:00 +01:00
Chris Palmer
f16f7ddb09 Images reverted to last OpenSCAD release versions.
Mainly text spacing changes.
2021-09-27 17:45:57 +01:00
Chris Palmer
9b5ec6af1a Fixed new rounded_polygon to work with last OpenSCAD release.
Trainling commas in let().
2021-09-27 17:16:36 +01:00
Chris Palmer
50958b064d Added $show_plugs to show crude reprentations of housings on pin_headers and Molex KK headers. 2021-09-27 16:36:47 +01:00
Chris Palmer
c37373c920 Added TO247() and TO247_size() to component.scad. 2021-09-27 16:21:37 +01:00
Chris Palmer
700f5a2205 fanguard() can now be made without screw holes to get just the grill. 2021-09-27 16:19:38 +01:00
Chris Palmer
4993c3e82d Module blurb parenthesis parsing is now greedy to handle args that default to function calls.
This means that library modules cannot be one liners.
2021-09-27 16:17:08 +01:00
Chris Palmer
c6b280f0e8 _box_assembly() fix for corners = 0. 2021-09-26 11:26:01 +01:00
Chris Palmer
6012787781 Added jack_4mm_plastic(). 2021-09-26 11:25:08 +01:00
Chris Palmer
30db66034c Rounded_polygons are now generated by a function returning a point list.
The module version simply passes this to polygon.
The arcs now sections of a circle4n() rather than a circle().
2021-09-26 10:54:01 +01:00
Chris Palmer
d6f344be3d Updated changelog. 2021-09-16 23:36:47 +01:00
37 changed files with 365 additions and 86 deletions

View File

@@ -3,6 +3,37 @@
This changelog is generated by `changelog.py` using manually added semantic version tags to classify commits as breaking changes, additions or fixes.
### [v16.1.0](https://github.com/nophead/NopSCADlib/releases/tag/v16.1.0 "show release") Additions [...](https://github.com/nophead/NopSCADlib/compare/v16.0.3...v16.1.0 "diff with v16.0.3")
* 2021-09-27 [`f16f7dd`](https://github.com/nophead/NopSCADlib/commit/f16f7ddb0943469a4e9aeb2aec9e6fc9e418c2dc "show commit") [C.P.](# "Chris Palmer") Images reverted to last OpenSCAD release versions.
Mainly text spacing changes.
* 2021-09-27 [`9b5ec6a`](https://github.com/nophead/NopSCADlib/commit/9b5ec6af1aba313df6812a5313470ebb7e8fbdd7 "show commit") [C.P.](# "Chris Palmer") Fixed new `rounded_polygon` to work with last OpenSCAD release.
Trainling commas in `let()`.
* 2021-09-27 [`50958b0`](https://github.com/nophead/NopSCADlib/commit/50958b064d5a6d5ca3fd6525a8c3d3a2c5b20199 "show commit") [C.P.](# "Chris Palmer") Added `$show_plugs` to show crude reprentations of housings on `pin_headers` and Molex KK headers.
* 2021-09-27 [`c37373c`](https://github.com/nophead/NopSCADlib/commit/c37373c920d3b438895ef535b0c06d0d00675609 "show commit") [C.P.](# "Chris Palmer") Added `TO247()` and `TO247_size()` to `component.scad`.
* 2021-09-27 [`700f5a2`](https://github.com/nophead/NopSCADlib/commit/700f5a2205173e12fad42df2f57d2c105608204e "show commit") [C.P.](# "Chris Palmer") `fanguard()` can now be made without screw holes to get just the grill.
* 2021-09-27 [`4993c3e`](https://github.com/nophead/NopSCADlib/commit/4993c3e82deffd933a81e39b670bb14886790b5f "show commit") [C.P.](# "Chris Palmer") Module blurb parenthesis parsing is now greedy to handle args that default to function calls.
This means that library modules cannot be one liners.
* 2021-09-26 [`c6b280f`](https://github.com/nophead/NopSCADlib/commit/c6b280f0e8d6780394bf63fc7efa9c1075589abe "show commit") [C.P.](# "Chris Palmer") `_box_assembly()` fix for corners `=` 0.
* 2021-09-26 [`6012787`](https://github.com/nophead/NopSCADlib/commit/601278778147c66288049b768be291c714fde6e0 "show commit") [C.P.](# "Chris Palmer") Added `jack_4mm_plastic()`.
* 2021-09-26 [`30db660`](https://github.com/nophead/NopSCADlib/commit/30db66034c7fedf0f07b542908a07f73efd9dc08 "show commit") [C.P.](# "Chris Palmer") `Rounded_polygons` are now generated by a function returning a point list.
The module version simply passes this to polygon.
The arcs now sections of a `circle4n()` rather than a `circle()`.
#### [v16.0.3](https://github.com/nophead/NopSCADlib/releases/tag/v16.0.3 "show release") Fixes [...](https://github.com/nophead/NopSCADlib/compare/v16.0.2...v16.0.3 "diff with v16.0.2")
* 2021-09-16 [`f6aa3b3`](https://github.com/nophead/NopSCADlib/commit/f6aa3b342650062cd8947aa36e2ae93242752d4b "show commit") [C.P.](# "Chris Palmer") `fuseholder_hole()` now makes a `poly_hole` when `cnc_bit_r` is 0.
* 2021-09-16 [`91c8c7b`](https://github.com/nophead/NopSCADlib/commit/91c8c7bf4d67cf93c47f41cd5984cb23271205cb "show commit") [C.P.](# "Chris Palmer") `cnc_bit_r` is now set to zero in stl(), so holes are suitable for 3D printing rather than routing.
* 2021-09-16 [`dc93b8d`](https://github.com/nophead/NopSCADlib/commit/dc93b8dcdf484dbb50cdee5908a91a3f322e6610 "show commit") [C.P.](# "Chris Palmer") Added platters and extrusion overrides to the example project.
#### [v16.0.2](https://github.com/nophead/NopSCADlib/releases/tag/v16.0.2 "show release") Fixes [...](https://github.com/nophead/NopSCADlib/compare/v16.0.1...v16.0.2 "diff with v16.0.1")
* 2021-09-14 [`119c2cb`](https://github.com/nophead/NopSCADlib/commit/119c2cb6f46ea00c9238da6d98305e6479f0452c "show commit") [C.P.](# "Chris Palmer") Can now make perfboards with screws holes only at one end.
`I.e`. for making models of chopped down boards.

View File

@@ -50,9 +50,10 @@ eps = 1/128; // small fudge factor to stop CSG barfing on coincident faces.
$fa = 6;
$fs = extrusion_width / 2;
function round_to_layer(z) = ceil(z / layer_height) * layer_height;
function round_to_layer(z) = ceil(z / layer_height) * layer_height; //! Round up to a multiple of layer_height.
// Some additional named colours
function grey(n) = [0.01, 0.01, 0.01] * n; //! Generate a shade of grey to pass to color().
function grey(n) = [0.01, 0.01, 0.01] * n; //! Generate a shade of grey to pass to color().
silver = [0.75, 0.75, 0.75];
gold = [255, 215, 0] / 255;
brass = [255, 220, 100] / 255;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 931 KiB

After

Width:  |  Height:  |  Size: 932 KiB

View File

@@ -588,9 +588,26 @@ module box_back_blank(type, sheet = false) { //! Generates a 2D template for the
sheet_2D(subst_sheet(type, sheet), box_width(type) - sheet_reduction(type), box_height(type) - sheet_reduction(type), 1);
}
module box_base(type) render_2D_sheet(box_base_sheet(type)) box_base_blank(type); //! Default base, can be overridden to customise
module box_top(type) render_2D_sheet(box_top_sheet(type)) box_top_blank(type); //! Default top, can be overridden to customise
module box_back(type) render_2D_sheet(box_sheets(type)) box_back_blank(type); //! Default back, can be overridden to customise
module box_front(type) render_2D_sheet(box_sheets(type)) box_front_blank(type); //! Default front, can be overridden to customise
module box_left(type) render_2D_sheet(box_sheets(type)) box_left_blank(type); //! Default left side, can be overridden to customise
module box_right(type) render_2D_sheet(box_sheets(type)) box_right_blank(type); //! Default right side, can be overridden to customise
module box_base(type) //! Default base, can be overridden to customise
render_2D_sheet(box_base_sheet(type))
box_base_blank(type);
module box_top(type) //! Default top, can be overridden to customise
render_2D_sheet(box_top_sheet(type))
box_top_blank(type);
module box_back(type) //! Default back, can be overridden to customise
render_2D_sheet(box_sheets(type))
box_back_blank(type);
module box_front(type) //! Default front, can be overridden to customise
render_2D_sheet(box_sheets(type))
box_front_blank(type);
module box_left(type) //! Default left side, can be overridden to customise
render_2D_sheet(box_sheets(type))
box_left_blank(type);
module box_right(type) //! Default right side, can be overridden to customise
render_2D_sheet(box_sheets(type))
box_right_blank(type);

View File

@@ -28,7 +28,7 @@ assembly("box") {
t = sheet_thickness(box_sheets(type));
for(corner = [0 : corners - 1]) {
for(corner = [0 : 1 : corners - 1]) {
x = [-1,1,1,-1][corner];
y = [-1,-1,1,1][corner];
translate([x * (box_width(type) / 2 + 25 * exploded()), y * (box_depth(type) / 2 + 25 * exploded())])

View File

@@ -198,12 +198,29 @@ module bbox_back_blank(type, sheet = false) { //! 2D template for the back
}
}
module bbox_base(type) render_2D_sheet(bbox_base_sheet(type)) bbox_base_blank(type); //! Default base, can be overridden to customise
module bbox_top(type) render_2D_sheet(bbox_top_sheet(type)) bbox_top_blank(type); //! Default top, can be overridden to customise
module bbox_back(type) render_2D_sheet(bbox_sheets(type)) bbox_back_blank(type); //! Default back, can be overridden to customise
module bbox_front(type) render_2D_sheet(bbox_sheets(type)) bbox_front_blank(type); //! Default front, can be overridden to customise
module bbox_left(type) render_2D_sheet(bbox_sheets(type)) bbox_left_blank(type); //! Default left side, can be overridden to customise
module bbox_right(type) render_2D_sheet(bbox_sheets(type)) bbox_right_blank(type); //! Default right side, can be overridden to customise
module bbox_base(type) //! Default base, can be overridden to customise
render_2D_sheet(bbox_base_sheet(type))
bbox_base_blank(type);
module bbox_top(type) //! Default top, can be overridden to customise
render_2D_sheet(bbox_top_sheet(type))
bbox_top_blank(type);
module bbox_back(type) //! Default back, can be overridden to customise
render_2D_sheet(bbox_sheets(type))
bbox_back_blank(type);
module bbox_front(type) //! Default front, can be overridden to customise
render_2D_sheet(bbox_sheets(type))
bbox_front_blank(type);
module bbox_left(type) //! Default left side, can be overridden to customise
render_2D_sheet(bbox_sheets(type))
bbox_left_blank(type);
module bbox_right(type) //! Default right side, can be overridden to customise
render_2D_sheet(bbox_sheets(type))
bbox_right_blank(type);
module _bbox_assembly(type, top = true, base = true, left = true, right = true, back = true, front = true) { //! The box assembly, wrap with a local copy without parameters
width = bbox_width(type);

View File

@@ -29,7 +29,7 @@ function fan_guard_wall() = extrusion_width - layer_height / 2 + nozzle / 2 + ex
function fan_guard_corner_r(type) = washer_diameter(screw_washer(fan_screw(type))) / 2 + 0.5; //! Corner radius of the guard
function fan_guard_width(type) = max(2 * (fan_hole_pitch(type) + fan_guard_corner_r(type)), fan_bore(type) + 4 * fan_guard_wall()); //! Width of the guard
module fan_guard(type, name = false, thickness = fan_guard_thickness(), spokes = 4, finger_width = 7, grill = false) { //! Generate the STL
module fan_guard(type, name = false, thickness = fan_guard_thickness(), spokes = 4, finger_width = 7, grill = false, screws = true) { //! Generate the STL
if(thickness)
stl(name ? name : str("fan_guard_", fan_width(type)));
hole_pitch = fan_hole_pitch(type);
@@ -54,7 +54,7 @@ module fan_guard(type, name = false, thickness = fan_guard_thickness(), spokes =
difference() {
rounded_square([width, width], r = width / 2 - hole_pitch);
fan_holes(type, !grill, !grill, h = 0);
fan_holes(type, !grill, !grill && screws, h = 0);
}
if(spokes) {
intersection() {

View File

@@ -105,7 +105,8 @@ module fixing_block(screw = def_screw) { //! Generate the STL
}
}
module fixing_block_assembly(screw = def_screw) pose([55, 180, 25], [0, 4.8, 4.8]) //! Printed part with the inserts inserted
module fixing_block_assembly(screw = def_screw) //! Printed part with the inserts inserted
pose([55, 180, 25], [0, 4.8, 4.8])
assembly(str("fixing_block_M", 20 * screw_radius(screw)), ngb = true) {
translate_z(fixing_block_height(screw))
rotate([0, 180, 0])

View File

@@ -79,7 +79,8 @@ module handle_stl() { //! generate the STL
//
//! Place inserts in the bottom of the posts and push them home with a soldering iron with a conical bit heated to 200°C.
//
module handle_assembly() pose([225, 0, 150], [0, 0, 14]) //! Printed part with inserts in place
module handle_assembly() //! Printed part with inserts in place
pose([225, 0, 150], [0, 0, 14])
assembly("handle", ngb = true) {
translate_z(handle_height())
stl_colour(pp1_colour) vflip() handle_stl();

View File

@@ -81,8 +81,9 @@ module ribbon_clamp(ways, screw = screw) { //! Generate STL for given number of
}
}
module ribbon_clamp_assembly(ways, screw = screw) pose([55, 180, 25]) //! Printed part with inserts in place
assembly(let(screw_d = screw_radius(screw) * 2)str("ribbon_clamp_", ways, screw_d != 3 ? str("_", screw_d) : ""), ngb = true) {
module ribbon_clamp_assembly(ways, screw = screw) //! Printed part with inserts in place
pose([55, 180, 25])
assembly(let(screw_d = screw_radius(screw) * 2)str("ribbon_clamp_", ways, screw_d != 3 ? str("_", screw_d) : ""), ngb = true) {
h = ribbon_clamp_height(screw);
insert = screw_insert(screw);

View File

@@ -71,8 +71,8 @@ A list of changes classified as breaking, additions or fixes is maintained in [C
### Modules
| Module | Description |
|:--- |:--- |
| `7_segment_digit(type, colour = grey(95)` | Draw the specified 7 segment digit |
| `7_segment_digits(type, n, colour = grey(70)` | Draw n digits side by side |
| `7_segment_digit(type, colour = grey(95), pin_length = 6.4)` | Draw the specified 7 segment digit |
| `7_segment_digits(type, n, colour = grey(70), pin_length = 6.4, cutout = false)` | Draw n digits side by side |
![7_segments](tests/png/7_segments.png)
@@ -343,7 +343,7 @@ Individual teeth are not drawn, instead they are represented by a lighter colour
### Modules
| Module | Description |
|:--- |:--- |
| `belt(type, points, belt_colour = grey(20)` | Draw a belt path given a set of points and pitch radii where the pulleys are. Closed loop unless open is specified |
| `belt(type, points, belt_colour = grey(20), tooth_colour = grey(50), open = false, twist = undef, auto_twist = false, start_twist = false)` | Draw a belt path given a set of points and pitch radii where the pulleys are. Closed loop unless open is specified |
![belts](tests/png/belts.png)
@@ -785,6 +785,7 @@ Various electronic components used in hot ends and heated beds.
| Function | Description |
|:--- |:--- |
| `TO220_thickness()` | Thickness of the tab of a TO220 |
| `TO247_size()` | Body dimensions of a T247, hole offset, lead height and lead wide length |
| `fack2spm_bezel_size()` | FACK2SPM Bezel dimensions |
| `fack2spm_screw()` | Screw type for FACK2SPM |
@@ -792,6 +793,7 @@ Various electronic components used in hot ends and heated beds.
| Module | Description |
|:--- |:--- |
| ` TO220(description, leads = 3, lead_length = 16)` | Draw a TO220 package, use `description` to describe what it is |
| ` TO247(description, lead_length = 20)` | Draw a TO247 package, use `description` to describe what it is |
| `al_clad_resistor(type, value, leads = true)` | Draw an aluminium clad resistor |
| `al_clad_resistor_hole_positions(type)` | Position children at the screw holes of an aluminium clad resistor |
| `al_clad_resistor_holes(type, h = 100)` | Drill screw holes for an aluminium clad resistor |
@@ -812,6 +814,7 @@ Various electronic components used in hot ends and heated beds.
| Qty | Module call | BOM entry |
| ---:|:--- |:---|
| 1 | `TO220("Generic TO220 package")` | Generic TO220 package |
| 1 | `TO247("Generic TO247 package")` | Generic TO247 package |
| 8 | `tubing(HSHRNK32)` | Heatshrink sleeving ID 3.2mm x 15mm |
| 1 | `resistor(RWM04106R80J)` | Resistor RWM04106R80J 6R8 3W vitreous enamel |
| 1 | `resistor(RIE1212UB5C5R6)` | Resistor UB5C 5R6F 5R6 3W vitreous enamel |
@@ -909,7 +912,7 @@ Dual inline IC packages and sockets
| Module | Description |
|:--- |:--- |
| `dip(n, part, size, w, pitch, pin)` | Draw DIP package |
| `pdip(pins, part, socketed, w = inch(0.3)` | Draw standard 0.1" PDIP IC package |
| `pdip(pins, part, socketed, w = inch(0.3), pitch = inch(0.1))` | Draw standard 0.1" PDIP IC package |
| `pdip_pin(type, l, end)` | Draw a pin |
![dip](tests/png/dip.png)
@@ -1524,6 +1527,7 @@ E.g. a "brown" socket for mains live needs to be displayed as "sienna" to look r
| Function | Description |
|:--- |:--- |
| `jack_4mm_hole_radius()` | Panel hole radius for 4mm jack |
| `jack_4mm_plastic_flange_radius()` | 4mm plastic jack socket flange radius |
| `jack_4mm_shielded_hole_radius()` | Panel hole radius for 4mm shielded jack |
| `jack_4mm_shielded_nut_radius()` | Largest diameter of 4mm shielded jack |
| `post_4mm_diameter()` | Outer diameter of 4mm binding post |
@@ -1532,6 +1536,7 @@ E.g. a "brown" socket for mains live needs to be displayed as "sienna" to look r
| Module | Description |
|:--- |:--- |
| `jack_4mm(colour, thickness, display_colour = false)` | Draw a 4mm jack socket with nut positioned for specified panel thickness |
| `jack_4mm_plastic(colour, thickness, display_colour = false)` | Draw a 4mm plastic jack socket with nut positioned for specified panel thickness |
| `jack_4mm_shielded(colour, thickness, display_colour = false)` | Draw a 4mm shielded jack |
| `post_4mm(colour, thickness, display_colour = false)` | Draw a 4mm binding post |
| `post_4mm_hole(h = 100, poly = false)` | Drill hole for 4mm binding post |
@@ -1543,6 +1548,7 @@ E.g. a "brown" socket for mains live needs to be displayed as "sienna" to look r
| ---:|:--- |:---|
| 1 | `post_4mm("red", 3)` | 4mm jack binding post red |
| 1 | `jack_4mm("blue", 3, "royalblue")` | 4mm jack socket blue |
| 1 | `jack_4mm_plastic("[0.2, 0.2, 0.2]", 3, [0.2, 0.2, 0.2])` | 4mm plastic jack socket [0.2, 0.2, 0.2] |
| 1 | `jack_4mm_shielded("brown", 3, "sienna")` | 4mm shielded jack socket brown |
@@ -2345,7 +2351,8 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o
| `flex(cutout = false)` | Draw flexistrip connector |
| `hdmi(type, cutout = false)` | Draw HDMI socket |
| `jack(cutout = false)` | Draw 3.5mm jack |
| `molex_254(ways, right_angle = 0, skip = undef)` | Draw molex header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version. |
| `molex_254(ways, right_angle = 0, skip = undef)` | Draw molex KK header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version. |
| `molex_254_housing(ways)` | Draw a Molex KK housing |
| `molex_usb_Ax1(cutout)` | Draw Molex USB A connector suitable for perf board |
| `molex_usb_Ax2(cutout)` | Draw Molex dual USB A connector suitable for perf board |
| `pcb(type)` | Draw specified PCB |
@@ -2489,7 +2496,8 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o
| `flex(cutout = false)` | Draw flexistrip connector |
| `hdmi(type, cutout = false)` | Draw HDMI socket |
| `jack(cutout = false)` | Draw 3.5mm jack |
| `molex_254(ways, right_angle = 0, skip = undef)` | Draw molex header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version. |
| `molex_254(ways, right_angle = 0, skip = undef)` | Draw molex KK header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version. |
| `molex_254_housing(ways)` | Draw a Molex KK housing |
| `molex_usb_Ax1(cutout)` | Draw Molex USB A connector suitable for perf board |
| `molex_usb_Ax2(cutout)` | Draw Molex dual USB A connector suitable for perf board |
| `pcb(type)` | Draw specified PCB |
@@ -3010,10 +3018,10 @@ Linear rails with carriages.
### Modules
| Module | Description |
|:--- |:--- |
| `carriage(type, end_colour = grey(20)` | Draw the specified carriage |
| `carriage(type, end_colour = grey(20), wiper_colour = grey(20))` | Draw the specified carriage |
| `carriage_hole_positions(type)` | Position children over screw holes |
| `rail(type, length, colour = grey(90)` | Draw the specified rail |
| `rail_assembly(carriage, length, pos, carriage_end_colour = grey(20)` | Rail and carriage assembly |
| `rail(type, length, colour = grey(90), use_polycircles = false)` | Draw the specified rail |
| `rail_assembly(carriage, length, pos, carriage_end_colour = grey(20), carriage_wiper_colour = grey(20))` | Rail and carriage assembly |
| `rail_hole_positions(type, length, first = 0, screws = 100, both_ends = true)` | Position children over screw holes |
| `rail_screws(type, length, thickness, screws = 100, index_screws = undef)` | Place screws in the rail |
@@ -4974,7 +4982,7 @@ The ring spacing as well as the number of spokes can be specified, if zero a gas
### Modules
| Module | Description |
|:--- |:--- |
| `fan_guard(type, name = false, thickness = fan_guard_thickness()` | Generate the STL |
| `fan_guard(type, name = false, thickness = fan_guard_thickness(), spokes = 4, finger_width = 7, grill = false, screws = true)` | Generate the STL |
![fan_guard](tests/png/fan_guard.png)
@@ -6312,8 +6320,9 @@ Because the tangents need to be calculated to find the length these can be calcu
| Function | Description |
|:--- |:--- |
| `circle_tangent(p1, p2)` | Compute the clockwise tangent between two circles represented as [x,y,r] |
| `rounded_polygon(points, _tangents = undef)` | Return the rounded polygon from the point list, can pass the tangent list to save it being calculated |
| `rounded_polygon_arcs(points, tangents)` | Compute the arcs at the points, for each point [angle, rotate_angle, length] |
| `rounded_polygon_length(points, tangents)` | Calculate the length given the point list and the list of tangents computed by ` rounded_polygon_tangents` |
| `rounded_polygon_length(points, tangents)` | Calculate the length given the point list and the list of tangents computed by `rounded_polygon_tangents` |
| `rounded_polygon_tangents(points)` | Compute the straight sections between a point and the next point, for each section [start_point, end_point, length] |
### Modules
@@ -6463,7 +6472,7 @@ Simple tube or ring
| `rectangular_tube(size, center = true, thickness = 1, fillet = 0.5)` | Create a rectangular tube with filleted corners |
| `ring(or, ir)` | Create a ring with specified external and internal radii |
| `tube(or, ir, h, center = true)` | Create a tube with specified external and internal radii and height `h` |
| `woven_tube(or, ir, h, center= true, colour = grey(30)` | Create a woven tube with specified external and internal radii, height `h`, colours, warp and weft |
| `woven_tube(or, ir, h, center= true, colour = grey(30), colour2, warp = 2, weft)` | Create a woven tube with specified external and internal radii, height `h`, colours, warp and weft |
![tube](tests/png/tube.png)
@@ -6506,7 +6515,7 @@ The `pose()` module allows assembly views in the readme to be posed differently
|:--- |:--- |
| `arg(value, default, name = "")` | Create string for arg if not default, helper for `vitamin()` |
| `bom_mode(n = 1)` | Current BOM mode, 0 = none, 1 = printed and routed parts and assemblies, 2 includes vitamins as well |
| `exploded()` | Returns the value of `$exploded` if it is defined, else `0` |
| `exploded()` | Returns the value of `$explode` if it is defined, else `0` |
| `show_supports()` | True if printed support material should be shown |
| `value_string(value)` | Convert `value` to a string or quote it if it is already a string |

View File

@@ -81,7 +81,7 @@ def scrape_code(scad_file):
match = re.match(r'^function (.*?\(.*?\)).*?(?://! ?(.*))$', line)
if match:
functions[match.group(1)] = match.group(2)
match = re.match(r'^module (.*?\(.*?\)).*?(?://! ?(.*))$', line)
match = re.match(r'^module (.*?\(.*\)).*?(?://! ?(.*))$', line)
if match:
modules[match.group(1)] = match.group(2)

View File

@@ -42,6 +42,9 @@ module components() {
TO220("Generic TO220 package");
translate([40, 50])
TO247("Generic TO247 package");
translate([40, 80])
panel_USBA();
translate([80, 50])

View File

@@ -22,12 +22,15 @@ use <../vitamins/jack.scad>
module jacks() {
translate([0, 0])
jack_4mm("blue",3, "royalblue");
jack_4mm_plastic("black",3, grey(20));
translate([20, 0])
jack_4mm_shielded("brown", 3, "sienna");
jack_4mm("blue",3, "royalblue");
translate([40, 0])
jack_4mm_shielded("brown", 3, "sienna");
translate([60, 0])
post_4mm("red",3);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View File

@@ -46,7 +46,9 @@ function bom_mode(n = 1) = (is_undef($bom) ? 0 : $bom) >= n && (is_undef($on_bom
function exploded() = is_undef($exploded_parent) ? is_undef($explode) ? 0 : $explode : 0; //! Returns the value of `$explode` if it is defined, else `0`
function show_supports() = !$preview || exploded(); //! True if printed support material should be shown
module no_explode() let($exploded_parent = true) children(); //! Prevent children being exploded
module no_explode() //! Prevent children being exploded
let($exploded_parent = true) children();
module explode(d, explode_children = false, offset = [0,0,0]) { //! Explode children by specified Z distance or vector `d`, option to explode grand children
v = is_list(d) ? d : [0, 0, d];
o = is_list(offset) ? offset : [0, 0, offset];
@@ -67,7 +69,8 @@ module explode(d, explode_children = false, offset = [0,0,0]) { //! Explode
children();
}
module no_pose() let($posed = true, $zoomed = undef) children(); //! Force children not to be posed even if parent is
module no_pose() //! Force children not to be posed even if parent is
let($posed = true, $zoomed = undef) children();
module pose(a = [55, 0, 25], t = [0, 0, 0], exploded = undef, d = undef) //! Pose an STL or assembly for rendering to png by specifying rotation `a`, translation `t` and optionally `d`, `exploded = true for` just the exploded view or `false` for unexploded only.
let($zoomed = is_undef(d)

View File

@@ -38,10 +38,17 @@ function r2sides(r) = $fn ? $fn : ceil(max(min(360/ $fa, r * 2 * PI / $fs), 5));
function r2sides4n(r) = floor((r2sides(r) + 3) / 4) * 4; //! Round up the number of sides to a multiple of 4 to ensure points land on all axes
function limit(x, min, max) = max(min(x, max), min); //! Force x in range min <= x <= max
module translate_z(z) translate([0, 0, z]) children(); //! Shortcut for Z only translations
module vflip(flip=true) rotate([flip ? 180 : 0, 0, 0]) children(); //! Invert children by doing a 180&deg; flip around the X axis
module hflip(flip=true) rotate([0, flip ? 180: 0, 0]) children(); //! Invert children by doing a 180&deg; flip around the Y axis
module ellipse(xr, yr) scale([1, yr / xr]) circle4n(xr); //! Draw an ellipse
module translate_z(z) //! Shortcut for Z only translations
translate([0, 0, z]) children();
module vflip(flip=true) //! Invert children by doing a 180&deg; flip around the X axis
rotate([flip ? 180 : 0, 0, 0]) children();
module hflip(flip=true) //! Invert children by doing a 180&deg; flip around the Y axis
rotate([0, flip ? 180: 0, 0]) children();
module ellipse(xr, yr) //! Draw an ellipse
scale([1, yr / xr]) circle4n(xr);
function slice_str(str, start, end, s ="") = start >= end ? s : slice_str(str, start + 1, end, str(s, str[start])); // Helper for slice()

View File

@@ -24,7 +24,7 @@
//! Because the tangents need to be calculated to find the length these can be calculated separately and re-used when drawing to save calculating them twice.
//
include <../utils/core/core.scad>
use <../utils/maths.scad>
use <maths.scad>
function circle_tangent(p1, p2) = //! Compute the clockwise tangent between two circles represented as [x,y,r]
let(
@@ -49,14 +49,14 @@ function rounded_polygon_arcs(points, tangents) = //! Compute the arcs at the po
v2 = p2 - p,
sr = points[i][2],
r = abs(sr),
a = r < 0.001 ? 0 : let( aa = acos((v1 * v2) / sqr(r)) ) cross(v1, v2) * sign(sr) <= 0 ? aa : 360 - aa,
a = r < 0.001 ? 0 : let( aa = acos(limit((v1 * v2) / sqr(r), -1, 1)) ) cross(v1, v2) * sign(sr) <= 0 ? aa : 360 - aa,
l = PI * a * r / 180,
v0 = [r, 0],
v = let (
vv = norm(v0 - v2) < 0.001 ? 0 : abs(v2.y) < 0.001 ? 180 :
let( aa = acos((v0 * v2) / sqr(r)) ) cross(v0, v2) * sign(sr) <= 0 ? aa : 360 - aa
let( aa = acos( limit((v0 * v2) / sqr(r), -1, 1)) ) cross(v0, v2) * sign(sr) <= 0 ? aa : 360 - aa
) sr > 0 ? 360 - vv : vv - a
) [a, v, l]
) [a, v % 360, l]
];
function rounded_polygon_tangents(points) = //! Compute the straight sections between a point and the next point, for each section [start_point, end_point, length]
@@ -67,36 +67,29 @@ function rounded_polygon_tangents(points) = //! Compute the straight sections be
];
// the cross product of 2D vectors is the area of the parallelogram between them. We use the sign of this to decide if the angle is bigger than 180.
function rounded_polygon_length(points, tangents) = //! Calculate the length given the point list and the list of tangents computed by ` rounded_polygon_tangents`
function rounded_polygon_length(points, tangents) = //! Calculate the length given the point list and the list of tangents computed by `rounded_polygon_tangents`
let(
arcs = rounded_polygon_arcs(points, tangents)
) sumv( map( concat(tangents, arcs), function(e) e[2] ) );
module rounded_polygon(points, _tangents = undef) { //! Draw the rounded polygon from the point list, can pass the tangent list to save it being calculated
len = len(points);
indices = [0 : len - 1];
tangents = _tangents ? _tangents : rounded_polygon_tangents(points);
function rounded_polygon(points, _tangents = undef) = //! Return the rounded polygon from the point list, can pass the tangent list to save it being calculated
let(
len = len(points),
tangents = _tangents ? _tangents : rounded_polygon_tangents(points),
arcs = rounded_polygon_arcs(points, tangents)
) [for(i = [0 : len - 1], last = (i - 1 + len) % len, R = points[i][2]) each [
vec2(tangents[last][1]), // End of last tangent
if(R) // If rounded
let(r = abs(R), // Get radius
n = r2sides4n(r), // Decide number of vertices
step = 360 / n, // Angular step
arc = arcs[i], // Get corner arc details
start = ceil(arc[1] / step + eps), // Starting index
end = floor((arc[0] + arc[1]) / step - eps), // Ending index
c = vec2(points[i]) // Centre of arc
) for(j = R > 0 ? [end : -1 : start] : [start : 1 : end], a = j * step) c + r * [cos(a), sin(a)], // Points on the arc
vec2(tangents[i][0])] // Start of next tangent
];
difference() {
union() {
for(i = indices, last = (i - 1 + len) % len)
if(points[i][2] > 0)
hull() {
translate(vec2(points[i]))
circle(points[i][2]);
polygon([vec2(tangents[last][1]), vec2(tangents[i][0]), vec2(points[i])]);
}
polygon([for(t = tangents) each(vec2(t))], convexity = points);
}
for(i = indices, last = (i - 1 + len) % len)
if(points[i][2] < 0)
hull() {
translate(vec2(points[i]))
circle(-points[i][2]);
polygon([vec2(tangents[last][1]), vec2(tangents[i][0]), vec2(points[i])]);
}
}
}
module rounded_polygon(points, _tangents = undef) //! Draw the rounded polygon from the point list, can pass the tangent list to save it being calculated
polygon(rounded_polygon(points, _tangents), convexity = len(points));

View File

@@ -223,7 +223,7 @@ module TO220(description, leads = 3, lead_length = 16) { //! Draw a TO220 packa
body = 8;
hole_y = 2.9;
vitamin(str("TO220(\"", description, "\"", arg(leads, 3, "leads"), arg(lead_length, 16, "lead_length"), "): ", description));
vitamin(str("TO220(\"", description, "\"", arg(leads, 3, "leads"), "): ", description));
translate([0, -length + hole_y]) {
color("silver") {
@@ -257,6 +257,79 @@ module TO220(description, leads = 3, lead_length = 16) { //! Draw a TO220 packa
children();
}
function TO247_size() = [15.7, 20.82, 4.82, 5.58, 2.5, 3.8]; //! Body dimensions of a T247, hole offset, lead height and lead wide length
module TO247(description, lead_length = 20) { //! Draw a TO247 package, use `description` to describe what it is
size = TO247_size();
hole_y = size[3];
lead_height = size[4];
lead_l = size[5];
metal = [12.81, 13.08, 1.5];
metal_y_offset = 1.35;
hole = 3.5;
metal_hole = 6.85;
lead_t = 0.61;
lead_w2 = 2.5;
lead_w = 1.25;
lead_pitch = 5.56;
vitamin(str("TO247(\"", description, "\"): ", description));
module body_shape()
difference() {
translate([-size.x / 2, 0])
square([size.x, size.y]);
translate([0, size.y - hole_y])
circle(d = hole);
}
translate([0, -size.y + hole_y]) {
color("silver") {
linear_extrude(metal.z)
difference() {
translate([-metal.x / 2, size.y - metal.y - metal_y_offset])
square([metal.x, metal.y]);
translate([0, size.y - hole_y])
circle(d = metal_hole);
}
translate_z(lead_height)
linear_extrude(lead_t)
intersection() {
for(i = [-1 : 1]) {
length = is_list(lead_length) ? lead_length[i + 1] : lead_length;
translate([lead_pitch * i, -length / 2, lead_height])
square([lead_w, length], center = true);
translate([lead_pitch * i, -lead_l / 2, lead_height])
square([lead_w2, lead_l], center = true);
}
square([2 * lead_pitch + lead_w, 100], center = true);
}
}
color("dimgrey")
translate_z(eps) {
linear_extrude(metal.z - 2 * eps)
body_shape();
linear_extrude(size.z)
difference() {
body_shape();
for(side = [-1, 1])
translate([side * size.x / 2, size.y - hole_y])
circle(d = 5);
}
}
}
translate_z(size.z)
children();
}
panel_USBA_pitch = 30;
module panel_USBA_hole_positions() //! Place children at hole positions

View File

@@ -87,6 +87,81 @@ module jack_4mm(colour, thickness, display_colour = false) { //! Draw a 4mm jack
}
}
function jack_4mm_plastic_flange_radius() = 11.66 / 2; //! 4mm plastic jack socket flange radius
module jack_4mm_plastic(colour, thickness, display_colour = false) { //! Draw a 4mm plastic jack socket with nut positioned for specified panel thickness
vitamin(str("jack_4mm_plastic(\"", colour, "\", 3", arg(display_colour, false), "): 4mm plastic jack socket ", colour));
flange_r2 = jack_4mm_plastic_flange_radius();
flange_d1 = 10.75;
flange_t = 4;
flange_id1 = 7.66;
flange_id2 = 5.12;
length = 19.6;
sleaved_d = 6.4;
thread = 16;
thread_d = 8;
thread_p = 0.75;
barrel_d = 5.4;
barrel = 18.5;
solder_bucket = [3.75 / 2, 2.4 / 2, 5.6];
nut_d = 10.8;
nut_t = 3;
colour = display_colour ? display_colour : colour;
explode(length, offset = -length + flange_t) {
color(colour) rotate_extrude() difference() {
union() {
polygon([
[flange_id2 / 2, -eps],
[flange_id1 / 2, flange_t],
[flange_d1 / 2, flange_t],
[flange_r2, -eps],
]);
translate([0, -length])
square([sleaved_d / 2, length]);
translate([0, -thread])
square([(thread_d - (show_threads ? thread_p : 0)) / 2, thread]);
}
square([4.1, 2 * length +1], center = true);
}
color(silver) rotate_extrude() {
difference() {
translate([0, -length + eps])
square([barrel_d / 2, length]);
square([4, 2 * (barrel - 1)], center = true);
}
translate([solder_bucket.y, -length - solder_bucket.z])
square([solder_bucket.x - solder_bucket.y, solder_bucket.z]);
}
if(show_threads)
color(colour)
translate_z(-thread)
male_metric_thread(thread_d, thread_p, thread, false, solid = false);
}
translate_z(-thickness)
explode(-length)
vflip() {
color(silver)
linear_extrude(nut_t)
difference() {
circle(d = nut_d, $fn = 6);
circle(d = thread_d);
}
if(show_threads)
female_metric_thread(thread_d, thread_p, nut_t, false, colour = silver);
}
}
function jack_4mm_shielded_hole_radius() = 12 / 2; //! Panel hole radius for 4mm shielded jack
function jack_4mm_shielded_nut_radius() = 14.4 / 2; //! Largest diameter of 4mm shielded jack

View File

@@ -859,7 +859,28 @@ module terminal_35(ways, colour = "blue") { //! Draw 3.5mm terminal block
single();
}
module molex_254(ways, right_angle = 0, skip = undef) { //! Draw molex header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version.
module molex_254_housing(ways) { //! Draw a Molex KK housing
vitamin(str("molex_254_housing(", ways, "): Molex KK housing ", ways, " way"));
pitch = 2.54;
width = ways * pitch + 0.6;
depth = 4.9;
height = 12.8;
header_depth = 6.35;
tab = [1.73, 0.96, 2.15];
color("white")
translate([(header_depth - depth) / 2, 0]) {
linear_extrude(height)
square([depth, width], center = true);
for(side = [-1, 1])
translate([-depth / 2 - tab.x / 2, side * (pitch / 2 - tab.y / 4) * ways, tab.z / 2])
cube(tab, center = true);
}
}
module molex_254(ways, right_angle = 0, skip = undef) { //! Draw molex KK header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version.
vitamin(str("molex_254(", ways, "): Molex KK header ", ways, " way"));
pitch = 2.54;
width = ways * pitch - 0.1;
@@ -872,10 +893,11 @@ module molex_254(ways, right_angle = 0, skip = undef) { //! Draw molex header, s
pin_w = 0.64;
r = 1;
a = right_angle ? width / 2 - r - pin_w / 2 : above;
ra_offset = 2.72;
ra_offset = 2.2;
color("white")
translate(right_angle ? [-ra_offset, 0, depth / 2] : [ 0, 0, 0])
rotate(right_angle ? right_angle > 0 ? [180, 90, 0] : [0, -90, 0] : [ 0, 0, 0])
rotate(right_angle ? right_angle > 0 ? [180, 90, 0] : [0, -90, 0] : [ 0, 0, 0]) {
union() {
translate([ -depth / 2, -width / 2,])
cube([depth, width, base]);
@@ -885,6 +907,11 @@ module molex_254(ways, right_angle = 0, skip = undef) { //! Draw molex header, s
cube([back, w, height]);
}
if(show_plugs)
translate_z(base + 0.1)
molex_254_housing(ways);
}
color("silver")
for(i = [0 : ways -1])
if(is_undef(skip) || !in(skip, i))
@@ -1007,9 +1034,11 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon
function param(n, default = 0) = len(comp) > n ? comp[n] : default;
rotate(comp.z) {
// Components that have a cutout parameter go in this section
if(show(comp, "2p54header")) pin_header(2p54header, comp[4], comp[5], param(6, false), param(8, false), cutouts, colour = param(7, undef));
if(show(comp, "2p54header")) let($show_plugs = show_plugs && param(9, true))
pin_header(2p54header, comp[4], comp[5], param(6, false), param(8, false), cutouts, colour = param(7, undef));
if(show(comp, "2p54joiner")) pin_header(2p54joiner, comp[4], comp[5], param(6, false), param(8, false), cutouts, colour = param(7, undef));
if(show(comp, "2p54boxhdr")) box_header(2p54header, comp[4], comp[5], param(6, false), cutouts);
if(show(comp, "2p54boxhdr")) let($show_plugs = show_plugs && param(7, true))
box_header(2p54header, comp[4], comp[5], param(6, false), cutouts);
if(show(comp, "2p54socket")) pin_socket(2p54header, comp[4], comp[5], param(6, false), param(7, 0), param(8, false), cutouts, param(9, undef));
if(show(comp, "chip")) chip(comp[4], comp[5], comp[6], param(7, grey(30)), cutouts);
if(show(comp, "rj45")) rj45(cutouts);
@@ -1109,7 +1138,8 @@ module pcb_grid_components(type, components, cutouts = false, angle = undef) //!
}
module pcb_cutouts(type, angle = undef) pcb_components(type, true, angle); //! Make cut outs to clear components on a PCB
module pcb_cutouts(type, angle = undef) //! Make cut outs to clear components on a PCB
pcb_components(type, true, angle);
module pcb_grid_positions(type) {
grid = pcb_grid(type);

View File

@@ -856,7 +856,7 @@ ArduinoNano = let(l = 43.18, w = 17.78, pitch = inch(0.6), pins = 15, poffset =
[ // components
[l / 2 + poffset, w / 2 - pitch / 2, 0, "-2p54joiner", pins, 1],
[l / 2 + poffset, w / 2 + pitch / 2, 0, "-2p54joiner", pins, 1],
[l / 2 + poffset + inch(0.75), w / 2, 0, "2p54header", 2, 3],
[l / 2 + poffset + inch(0.75), w / 2, 0, "2p54header", 2, 3, false, undef, false, false],
[1.75, w / 2, 180, "usb_uA" ],
[l / 2 - inch(0.25), w / 2, 45, "chip", 7, 7, 1.3],
[l / 2 + poffset + inch(0.15), w / 2, 0, "chip", 3.5, 6, 1.8, silver ], // mock button

View File

@@ -21,6 +21,8 @@ include <../utils/core/core.scad>
use <../utils/dogbones.scad>
panel_clearance = 0.2;
housing_height = 14.12; // measured height of a Dupont connector.
housing_colour = grey(25);
function hdr_pitch(type) = type[1]; //! Header pitch
function hdr_pin_length(type) = type[2]; //! Header pin length
@@ -96,7 +98,7 @@ module pin_header(type, cols = 1, rows = 1, smt = false, right_angle = false, cu
}
// Insulator
translate([0, right_angle ? -ra_offset - (rows - 1) * pitch / 2 : 0, right_angle ? width / 2 : 0])
rotate([right_angle ? 90 : 0, 0, 0])
rotate([right_angle ? 90 : 0, 0, 0]) {
color(base_colour)
linear_extrude(h)
for(x = [0 : cols - 1], y = [0 : rows - 1])
@@ -107,12 +109,18 @@ module pin_header(type, cols = 1, rows = 1, smt = false, right_angle = false, cu
square([pitch - chamfer, pitch + eps], center = true);
}
if(show_plugs && hdr_pin_length(type) > 7)
color(housing_colour)
translate_z(h + eps)
linear_extrude(housing_height)
square([cols * pitch , rows * pitch], center = true);
}
}
}
}
module box_header(type, cols = 1, rows = 1, smt = false, cutout = false) { //! Draw box header
pitch = hdr_pitch(type);
pitch = hdr_pitch(type);
size = hdr_box_size(type);
w = cols * pitch + 7.62;
l = rows * pitch + 3.52;
@@ -144,6 +152,11 @@ module box_header(type, cols = 1, rows = 1, smt = false, cutout = false) { //! D
square([4.5, 4.5], center = true);
}
}
if(show_plugs)
color(housing_colour)
translate_z(base)
linear_extrude(housing_height)
square([cols * pitch, rows * pitch], center = true);
}
}
}

View File

@@ -141,7 +141,8 @@ module vero_components(type, cutouts = false, angle = undef)
translate_z(vero_thickness(type))
pcb_component(comp, cutouts, angle);
module vero_cutouts(type, angle = undef) vero_components(type, true, angle); //! Make cutouts to clear components
module vero_cutouts(type, angle = undef) //! Make cutouts to clear components
vero_components(type, true, angle);
module veroboard_assembly(type, height, thickness, flip = false, ngb = false) //! Draw the assembly with components and fasteners in place
assembly(vero_assembly(type), ngb = ngb) {