I am new to Openscad so bear with me. As part of a larger model, I have created an octagon with a circle cut out of the middle. I want to create a depressed circle in middle of each side of the octagon with a diameter of 11mm and depth of 6mm. Unfortunately, I have no idea how to do this. Can someone please point me in the right direction? A snippet of my code is below:
$fn = 150; // Smoothness for round parts
outer_diameter = 103; // Outer diameter of the hose connection
inner_diameter = 100; // Inner diameter (to fit hose)
adapter_height = 50; // Height of the adapter
lip_height = 25 ; // Height of the lip for magnetic connection
lip_width = 40; // Thickness of the lip
// Octagonal Magnetic Lip
module magnetic_lip() {
difference() {
// Outer lip with octagonal shape
linear_extrude(height=lip_height)
offset(delta=lip_width, chamfer=false)
circle(d=inner_diameter, $fn=8); // Octagon shape
// Inner lip hole
translate([0, 0, -1])
cylinder(h=lip_height + 2, d=outer_diameter);
}
}
// Complete Assembly
module hose_adapter() {
union() {
magnetic_lip();
}
}
// Render the adapter
hose_adapter();
With the help of ChatGPT (it can write Openscad code!), I got the following using the code below:
$fn = 150; // Smoothness for round parts
outer_diameter = 103; // Outer diameter of the hose connection
inner_diameter = 100; // Inner diameter (to fit hose)
adapter_height = 50; // Height of the adapter
lip_height = 25; // Height of the lip for magnetic connection
lip_width = 40; // Thickness of the lip
hole_diameter = 12.5; // Diameter of the holes
hole_depth = 4; // Depth of the holes
num_holes = 8; // Number of holes
// Octagonal Magnetic Lip
module magnetic_lip() {
difference() {
// Outer lip with octagonal shape
linear_extrude(height=lip_height)
offset(delta=lip_width, chamfer=false)
circle(d=inner_diameter, $fn=8); // Octagon shape
// Inner lip hole
translate([0, 0, -1])
cylinder(h=lip_height + 2, d=outer_diameter);
// Drill holes on the top horizontal surface, centered between inner circle and outer edge
for (i = [0 : 360 / num_holes : 360 - (360 / num_holes)]) {
rotate([0, 0, i]) {
// Calculate midpoint radius between inner circle and outer edge of the octagon
radius_midpoint = (inner_diameter / 2 + (inner_diameter / 2 + lip_width)) / 2;
translate([radius_midpoint, 0, lip_height]) {
cylinder(h=hole_depth, d=hole_diameter, center=true);
}
}
}
}
}
// Complete Assembly
module hose_adapter() {
union() {
magnetic_lip();
}
}
// Render the adapter
hose_adapter();