From e3a500e9c6ede8467c5ea7a941159149875e5d8e Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Sun, 18 Aug 2019 12:19:48 +0100 Subject: [PATCH] Added pcb_component_position(). --- readme.md | 3 ++- vitamins/pcb.scad | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 9e49a1e..8eae811 100644 --- a/readme.md +++ b/readme.md @@ -1658,11 +1658,12 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o | ```pcb_assembly(type, height, thickness)``` | Draw PCB assembly with spaces and fasteners in place | | ```pcb_base(type, height, thickness, wall = 2)``` | Generate STL for a base with PCB spacers | | ```pcb_component(comp, cutouts = false, angle = undef)``` | Draw pcb component from description | +| ```pcb_component_position(type, name)``` | Position child at the specified component position | | ```pcb_components(type, cutouts = false, angle = undef)``` | Draw list of PCB components on the PCB | | ```pcb_cutouts(type, angle = undef)``` | Make cut outs to clear components on a PCB | | ```pcb_grid(type, x, y, z = 0)``` | Positions children at specified grid positions | | ```pcb_screw_positions(type)``` | Positions children at the mounting hole positions | -| ```pcb_spacer(screw, height, wall = 1.8)``` | Generate STL for PCB spacer | +| ```pcb_spacer(screw, height, wall = 1.8, taper = 0)``` | Generate STL for PCB spacer | | ```rj45(cutout = false)``` | Draw RJ45 Ethernet connector | | ```terminal_35(ways)``` | Draw 3.5mm terminal block | | ```uSD(size, cutout = false)``` | Draw uSD socket | diff --git a/vitamins/pcb.scad b/vitamins/pcb.scad index 5bce753..a0e4c44 100644 --- a/vitamins/pcb.scad +++ b/vitamins/pcb.scad @@ -667,6 +667,22 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon } } +module pcb_component_position(type, name) { //! Position child at the specified component position + for(comp = pcb_components(type)) { + p = pcb_coord(type, [comp.x, comp.y]); + if(comp[3][0] == "-") { + if(comp[3] == str("-", name)) + translate([p.x, p.y]) + vflip() + children(); + } + else + if(comp[3] == name) + translate([p.x, p.y, pcb_thickness(type)]) + children(); + } +} + module pcb_components(type, cutouts = false, angle = undef) { //! Draw list of PCB components on the PCB not_on_bom(pcb_parts_on_bom(type)) for(comp = pcb_components(type)) {