mirror of
https://github.com/DJSundog/NopSCADlib.git
synced 2024-11-27 09:10:02 -05:00
pcb_component_position() can now be passed an index to differentiate between
multiple components of the same type. Added pcb_grid_pos() function.
This commit is contained in:
parent
53f416eef1
commit
6f93b6af9a
@ -1682,8 +1682,9 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o
|
|||||||
### Functions
|
### Functions
|
||||||
| Function | Description |
|
| Function | Description |
|
||||||
|:--- |:--- |
|
|:--- |:--- |
|
||||||
| ```pcb_component_position(type, name)``` | Return x y position of specified component |
|
| ```pcb_component_position(type, name, index = 0)``` | Return x y position of specified component |
|
||||||
| ```pcb_coord(type, p)``` | Convert offsets from the edge to coordinates relative to the centre |
|
| ```pcb_coord(type, p)``` | Convert offsets from the edge to coordinates relative to the centre |
|
||||||
|
| ```pcb_grid_pos(type, x, y, z = 0)``` | Returns a pcb grid position |
|
||||||
| ```pcb_screw(type, cap = hs_cap)``` | Mounting screw type |
|
| ```pcb_screw(type, cap = hs_cap)``` | Mounting screw type |
|
||||||
|
|
||||||
### Modules
|
### Modules
|
||||||
@ -1703,7 +1704,7 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o
|
|||||||
| ```pcb_component_position(type, name)``` | Position child at the specified component position |
|
| ```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_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_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_grid(type, x, y, z = 0)``` | Positions children at specified grid position |
|
||||||
| ```pcb_screw_positions(type)``` | Positions children at the mounting hole positions |
|
| ```pcb_screw_positions(type)``` | Positions children at the mounting hole positions |
|
||||||
| ```pcb_spacer(screw, height, wall = 1.8, taper = 0)``` | 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 |
|
| ```rj45(cutout = false)``` | Draw RJ45 Ethernet connector |
|
||||||
|
@ -49,9 +49,12 @@ function pcb_grid(type) = type[13]; //! Grid if a perfboard
|
|||||||
function pcb_polygon(type) = type[14]; //! Optional outline polygon for odd shaped boards
|
function pcb_polygon(type) = type[14]; //! Optional outline polygon for odd shaped boards
|
||||||
function pcb_screw(type, cap = hs_cap) = Len(type[15]) ? type[15] : find_screw(cap, screw_smaller_than(pcb_hole_d(type))); //! Mounting screw type
|
function pcb_screw(type, cap = hs_cap) = Len(type[15]) ? type[15] : find_screw(cap, screw_smaller_than(pcb_hole_d(type))); //! Mounting screw type
|
||||||
|
|
||||||
module pcb_grid(type, x, y, z = 0) //! Positions children at specified grid positions
|
function pcb_grid_pos(type, x, y, z = 0) = //! Returns a pcb grid position
|
||||||
translate([-pcb_length(type) / 2 + pcb_grid(type).x + 2.54 * x,
|
[-pcb_length(type) / 2 + pcb_grid(type).x + 2.54 * x,
|
||||||
-pcb_width(type) / 2 + pcb_grid(type).y + 2.54 * y, pcb_thickness(type) + z])
|
-pcb_width(type) / 2 + pcb_grid(type).y + 2.54 * y, pcb_thickness(type) + z];
|
||||||
|
|
||||||
|
module pcb_grid(type, x, y, z = 0) //! Positions children at specified grid position
|
||||||
|
translate(pcb_grid_pos(type, x, y, z))
|
||||||
children();
|
children();
|
||||||
|
|
||||||
// allows negative ordinates to represent offsets from the far edge
|
// allows negative ordinates to represent offsets from the far edge
|
||||||
@ -730,8 +733,8 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pcb_component_position(type, name) = //! Return x y position of specified component
|
function pcb_component_position(type, name, index = 0) = //! Return x y position of specified component
|
||||||
[for(comp = pcb_components(type), p = [pcb_coord(type, [comp.x, comp.y])]) if(comp[3] == name) [p.x, p.y]][0];
|
[for(comp = pcb_components(type), p = [pcb_coord(type, [comp.x, comp.y])]) if(comp[3] == name) [p.x, p.y]][index];
|
||||||
|
|
||||||
module pcb_component_position(type, name) { //! Position child at the specified component position
|
module pcb_component_position(type, name) { //! Position child at the specified component position
|
||||||
for(comp = pcb_components(type)) {
|
for(comp = pcb_components(type)) {
|
||||||
@ -807,9 +810,9 @@ module pcb(type) { //! Draw specified PCB
|
|||||||
pcb_screw_positions(type)
|
pcb_screw_positions(type)
|
||||||
tube(or = max(pcb_land_d(type), 1) / 2, ir = pcb_hole_d(type) / 2, h = t + 2 * eps);
|
tube(or = max(pcb_land_d(type), 1) / 2, ir = pcb_hole_d(type) / 2, h = t + 2 * eps);
|
||||||
|
|
||||||
fr4 = pcb_colour(type) == "green";
|
fr4 = pcb_colour(type) != "sienna";
|
||||||
plating = 0.15;
|
plating = 0.15;
|
||||||
color(fr4 ? "silver" : "gold")
|
color(pcb_colour(type) == "green" ? "silver" : "gold")
|
||||||
translate_z(-plating)
|
translate_z(-plating)
|
||||||
linear_extrude(height = fr4 ? t + 2 * plating : plating)
|
linear_extrude(height = fr4 ? t + 2 * plating : plating)
|
||||||
if(Len(grid)) {
|
if(Len(grid)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user