Hi all,
New openSCAD user here. I'm building a little platform upon which to mount
sensors on a drone, so would like to carve out holes in the platform (a flat
cube) in order to save weight. I'm wondering if there might be some
routines out there that would do this for me in a configurable way? See
image and code below.
Any thoughts greatly appreciated!
Thanks,
Alex
http://forum.openscad.org/file/t2222/2018-04-11_13_29_18-OpenSCAD_-_DLS_GPS_platform.png
code:
$fn = 30;
// from https://www.thingiverse.com/thing:9347
module roundedRect(size, radius)
{
x = size[0];
y = size[1];
z = size[2];
linear_extrude(height=z)
hull()
{
// place 4 circles in the corners, with the given radius
translate([(-x/2)+radius, (-y/2)+radius, 0])
circle(r=radius);
translate([(x/2)-radius, (-y/2)+radius, 0])
circle(r=radius);
translate([(-x/2) + radius, (y/2)-radius, 0])
circle(r=radius);
translate([(x/2)-radius, (y/2)-radius, 0])
circle(r=radius);
}
}
// from
https://github.com/dannystaple/OpenSCAD-Parts-Library/blob/master/prism.scad
//Draw a prism based on a right angled triangle
//l - length of prism
//w - width of triangle
//h - height of triangle
module prism(l, w, h) {
polyhedron(points=[
[0,0,h], // 0 front top corner
[0,0,0],[w,0,0], // 1, 2 front left & right bottom corners
[0,l,h], // 3 back top corner
[0,l,0],[w,l,0] // 4, 5 back left & right bottom corners
], faces=[ // points for all faces must be ordered clockwise when
looking in
[0,2,1], // top face
[3,4,5], // base face
[0,1,4,3], // h face
[1,2,5,4], // w face
[0,3,5,2], // hypotenuse face
]);
}
*prism(10,5,5);
attach_thickness = 3;
attach_width = 15;
attach_length = 16;
attach_hole = 3.5/2;
hole_pos = [attach_width/2, 9, 0];
attach_tri_height = 1.5;
attach_sep = 2.8;
attach_base_border = 5;
base_thick = 3;
module attachment_leg(width, length, thick, hole_rad, tri_height, hole_pos){
difference() {
union(){
cube([width, length - width/2, thick]);
translate([width/2, length - width/2, 0]) cylinder(h = thick, r = width/2);
// triangle at base of leg
// adding 0.1 so they will extend into the base in the attachment_legs
module
translate([0, (thick + attach_sep)/2, thick/2]) rotate([0,45,270])
prism(width, (thick + attach_sep)/sqrt(2) + 0.1, (thick +
attach_sep)/sqrt(2) + 0.1);
}
// screw hole
translate(hole_pos) scale([1,1,2.5]) cylinder(h = thick, r = hole_rad,
center = true);
}
}
*attachment_leg(attach_width, attach_length, attach_thickness, attach_hole,
attach_tri_height, hole_pos);
module attachment_legs(width, length, thick, hole_rad, tri_height,
hole_pos){
attachment_leg(width, length, thick, hole_rad, tri_height, hole_pos);
translate([0, 0, attach_thickness + attach_sep]) attachment_leg(width,
length, thick, hole_rad, tri_height, hole_pos);
// base for legs
legs_base_width = width + attach_base_border*2;
legs_base_len = thick*2 + attach_sep*2 + attach_base_border*2;
rotate([90,0,0]) translate([width/2 - legs_base_width/2, thick +
attach_sep/2 - legs_base_len/2])
cube([legs_base_width, legs_base_len, base_thick]);
}
*attachment_legs(attach_width, attach_length, attach_thickness, attach_hole,
attach_tri_height, hole_pos);
module DLS_holes(thick) {
dist = 40;
rad = 2.5;
cylinder(h = thick * 3, r = rad, center = true);
translate([40, 0, 0]) cylinder(h = thick * 3, r = rad, center = true);
}
*DLS_holes(attach_thickness);
module baseplate(width, length, thick, radius) {
difference() {
translate([width/2, length/2, 0]) roundedRect([width,length,thick], 5);
translate([(width - 40)/2, 6, 0]) DLS_holes(thick);
}
}
baseplate(55, 120, 3, 5);
translate([(attach_thickness*2 + attach_sep)/2 + 55/2, 10, 0])
rotate([270,0,90])
attachment_legs(attach_width, attach_length, attach_thickness, attach_hole,
attach_tri_height, hole_pos);
--
Sent from: http://forum.openscad.org/
You can difference somehow translated objects to get holes. Use cube(),
cylinder() or like the following example shows roundedRect().
Also play with your slicer's infill parameter to save weight.
difference()
{
roundedRect([55, 120, 3], 5);
translate([0, 10])
roundedRect([45, 90, 4], 5);
}
module roundedRect(size, radius) // more elegant version
linear_extrude(height = size.z, center=true)
offset(radius) offset(-radius)
square([size.x, size.y], center = true);
--
Sent from: http://forum.openscad.org/
Thanks Parkinbot.
--
Sent from: http://forum.openscad.org/
There are some pretty over the top options if you want to go deep. You could
specify the points you care about, put components at those locations, and
then generate a Delaunay triangulation of beams to connect them. Similarly,
you can do an adaptive subdivision thing.
If you don't want something fancy, you can do the plate as a grid...
meshplate.scad http://forum.openscad.org/file/t2140/meshplate.scad
--
Sent from: http://forum.openscad.org/
wow, that's awesome. Thanks NateTG!
If you have references of those over-the-top options you mentioned, i'd be
keen to check them out (google searching doesn't result in anything too
obvious), but the grid seems really good regardless.
--
Sent from: http://forum.openscad.org/
So the grid thing is basically just a plate with a lot of holes, which is OK.
(Depending on printer settings it could actually be heavier than a 'solid'
plate, but that's a different topic.)
The thing is when people really want to make something light, they usually
use something like a space frame. (
https://en.wikipedia.org/wiki/Space_frame ) So you could write something
where you pick out the attachment points that you care about, and it
generates a space frame that holds them together. One way to generate that
frame is a Delaunay triangulation.
(https://en.wikipedia.org/wiki/Delaunay_triangulation). Another option
would be an adaptive subdivision algorithm something a bit like
https://github.com/Ultimaker/CuraEngine/issues/381 .
--
Sent from: http://forum.openscad.org/
gotcha, thanks Nate. i understand what you're saying about actually
increasing weight by adding holes - i'd actually started to think of that as
well; perhaps best to let the slicer use routines to build a rigid and light
structure, if the slicer is smart enough.
space frames, etc... very cool... perhaps i'll sniff around these topics
when I have some time to do so. thanks again Nate - cool info.
--
Sent from: http://forum.openscad.org/
I created a routine for cutting rounded equilateral triangles out of flat
(cubic) shapes, which I used on my webcam holder here
https://www.thingiverse.com/thing:701159 and my racing drone here
https://www.thingiverse.com/thing:937814 .
It was mainly an exercise in maths but the outcome works well for things
that I want to take on a 'truss' appearance, which is light yet can still be
strong in certain directions!
--
Sent from: http://forum.openscad.org/