finbox mold refactoring

This commit is contained in:
Sébastien Dante Ursini 2025-01-20 22:41:11 -03:00
parent 9d4fa6b330
commit 3450bf2c52
4 changed files with 373 additions and 119 deletions

View File

@ -42,6 +42,59 @@
"show_curve_points": "false",
"show_debug_layers": "false",
"start": "[0, 0]"
},
"New set 2": {
"$fn": "64",
"base_extra_thickness": "40",
"base_tickness": "8",
"build_box": "false",
"build_fin": "false",
"build_mold": "true",
"draw_profile": "false",
"fin_back_angle": "20",
"fin_back_height": "30",
"fin_back_strength": "30",
"fin_back_widthdraw": "20",
"fin_base": "130",
"fin_counter_angle": "30",
"fin_counter_strength": "10",
"fin_edge_angle": "30",
"fin_edge_strength": "30",
"fin_edge_withdraw": "20",
"fin_end_angle": "110",
"fin_end_strength": "30",
"fin_height": "254",
"fin_start_angle": "70",
"fin_sweep": "25",
"fin_thickness": "9",
"fin_top_withdraw": "35",
"fin_width": "270",
"fin_width_tip": "5",
"height": "25",
"merge_holes_diameter": "6",
"mirror_vec": "[1, 1, 0]",
"mold_base_height": "10",
"mold_extra_width": "15",
"mold_part": "all",
"mold_piston_height": "10",
"mold_top_height": "5",
"parts": "all",
"pin_back": "9",
"pin_depth": "16.399999999999999",
"pin_dia": "3",
"piston_depth": "5",
"printable": "true",
"render_drill_template": "false",
"resin_escape_diameter": "4",
"scale_factor": "1",
"screw_dia": "4.5",
"screw_pos": "9.5999999999999996",
"show_curve_points": "false",
"show_debug_layers": "false",
"start": "[0, 0]",
"tab_height": "13",
"thick": "9.1999999999999993",
"thick_cut": "1"
}
}
}

View File

@ -62,7 +62,7 @@ fin_counter_strength = 10; // Length [Point 2]
fin_width_tip = 5; // Width at the tip in mm
fin_thickness = 10; // Thickness of the fin in mm
fin_thickness = 9; // Thickness of the fin in mm
fin_end_angle = 110;
fin_end_strength = 30;
@ -222,15 +222,18 @@ points = flatten([
// *****************
bez_end(end_point,75,40),
]);
profile_curve = translate_path( addBase(asCurve(points,32)),-fin_base/2,0 );
//profile_curve = translate_path( asCurve(points,32),-fin_base/2,0 );
//profile_curve = resample_path(translate_path( asCurve(points,32),-fin_base/2,0 ),64);
assert(is_path_simple(profile_curve));
profile_curve_with_base = translate_path( addBase(asCurve(points,32)),-fin_base/2,0 );
profile = translate_path( asCurve(points,32),-fin_base/2,0 );
//profile_curve_with_base = translate_path( asCurve(points,32),-fin_base/2,0 );
//profile_curve_with_base = resample_path(translate_path( asCurve(points,32),-fin_base/2,0 ),64);
assert(is_path_simple(profile_curve_with_base));
if (show_curve_points)
color("Blue")move_copies(profile_curve) circle($fn=16);
color("Blue")move_copies(profile_curve_with_base) circle($fn=16);
// Draw fin profile
@ -238,60 +241,34 @@ if (draw_profile) {
//left(425) drawProfile( points, true );
layer0 = expandPath(profile_curve,-2);
layer1 = expandPath(profile_curve,-8);
layer2 = expandPath(profile_curve,-15);
layer3 = expandPath(profile_curve,-30);
layer4 = expandPath(profile_curve,-40);
layer0 = expandPath(profile_curve_with_base,-2);
layer1 = expandPath(profile_curve_with_base,-8);
layer2 = expandPath(profile_curve_with_base,-15);
layer3 = expandPath(profile_curve_with_base,-30);
layer4 = expandPath(profile_curve_with_base,-40);
back(10) showDebugPath(layer0);
left(500) {
color("Red") polygon(profile_curve);
color("Red") polygon(profile_curve_with_base);
up(10) polygon(layer0);
up(20) color("Yellow") polygon(layer1);
up(30) color("Brown") polygon(layer2);
}
layers = [profile_curve,layer0,layer1,layer2,layer3,layer4];
layers = [profile_curve_with_base,layer0,layer1,layer2,layer3,layer4];
left (800) color ("Green") polygon(profile_curve);
left (800) color ("Green") polygon(profile_curve_with_base);
left (1000) color ("Green") shell(10) polygon(profile_curve);
left (1000) color ("Green") shell(10) polygon(profile_curve_with_base);
}
/**
* Draws a profile based on Bezier path points with optional debug visualization.
*
* @param points - Array of points defining the Bezier path.
* @param debug - Boolean flag to enable/disable debug visualization. Defaults to true.
*
* This module:
* - Calculates the closest point on the Bezier path to a fixed point.
* - Draws the Bezier path with debug information if debug is true.
* - Optionally shows spheres at specific points for debugging (currently commented out).
*/
module drawProfile( points,debug = true ){
debugPoint (start, "Start", "Red" );
debugPoint (top_point, "Top", "Blue" );
debugPoint (edge_point, "Edge", "Brown" );
debugPoint (counter_edge_point, "Counter Edge", "Brown" );
debugPoint (tail_point, "Tail", "Yellow" );
debugPoint (end_point, "End", "Yellow" );
//pt = [100,0];
//pos = bezpath_closest_point(points, pt);
//xy = bezpath_points(points,pos[0],pos[1]);
debug_bezier(points, N=3,width=1.2);
}
// *****************
// * Fin Drawing *
// *****************
@ -319,8 +296,18 @@ module buildCompletFin() {
module buildBox() {
left(80) xflip()
finfit(fin_base+20, [1,1,0],false,false);
left(80) {
xflip() {
finfit(fin_base+20, [1,1,0],false,false);
}
//up(20) tab_cut();
}
}
module buildBoxMold() {
zrot(-90) chinook_profile(fin_base+20);
zrot(-90) up(-2) offset(chinook_profile(fin_base+20),delta=5);
}
@ -329,18 +316,21 @@ module buildBox() {
*
*/
module buildMold() {
moldContour = expandPath(profile_curve,mold_extra_width);
showDebugPath(moldContour);
moldHeight = 10;
skirtHeight = 30;
moldContour = expandPath(profile,mold_extra_width);
buildMoldSkirt(skirtHeight,mold_extra_width,3);
if (mold_part != "top") {
difference() {
union() {
down(moldHeight) linear_extrude (moldHeight) polygon(moldContour); // bottom
back(5) left(95) cube([20+10,25,moldHeight],anchor=BACK+TOP); // Box shell
//back(5) left(95) cube([20+10,25,moldHeight],anchor=BACK+TOP); // Box shell
up(5) color("Yellow") left(80) buildBoxMold();
};
buildCompletFin();
}
@ -371,11 +361,11 @@ module buildMold() {
*/
}
module buildMoldSkirt( height,offset,thickness ) {
outside = expandPath(profile_curve,offset);
inside = expandPath(profile_curve,offset-thickness);
outside = expandPath(profile,offset);
inside = expandPath(profile,offset-thickness);
down(height) {
// Skirt
linear_extrude (height) difference() {
linear_extrude (height-thick/2) difference() {
polygon(outside);
polygon(inside);
};
@ -474,7 +464,7 @@ module buildDrillTemplate() {
// *****************
module bottomInsert() {
debug=true;
layer_profile = profile_curve;
layer_profile = profile_curve_with_base;
skin( [ layer_profile,expandPath(layer_profile,3) ], z=[0,piston_depth], slices=0 )
up(OFFSET)
buildFinSide(true)
@ -486,7 +476,7 @@ module bottomInsert() {
// *****************
module topPiston() {
debug=true;
layer_profile = profile_curve;
layer_profile = profile_curve_with_base;
difference() {
skin( [ layer_profile,expandPath(layer_profile,3) ], z=[0,piston_depth], slices=0 );
down(OFFSET)
@ -512,14 +502,14 @@ module buildFin( thickness ) {
*/
module buildFinSide(thickness,flip=false) {
//profile_curve1 = subdivide_path (profile_curve,500);
//profile_curve_with_base1 = subdivide_path (profile_curve_with_base,500);
//if (false)
mirror([0,0,flip ? 1 : 0])
color(flip ? "Gray" : "LightGray")
ellipse_extrude( thickness / 2 /*,height=2*/,center=false,twist=-7)
//zrot(30)
polygon( profile_curve);
polygon( profile_curve_with_base);
}
module resin_escape(length) {
@ -541,26 +531,9 @@ module drilling(){
);
}
/*
echo ("bez_begin([-50,0],[0,-20])",bez_begin([-50,0],[0,-20]));
echo ("bez_begin([-50,0],[0,-20])",
flatten([
bez_begin([-50,0],[0,-20]),
bez_end([-50,0],[0,-20])
])
);
*/
echo ("bez_tang([0,0],70,80)",bez_tang(counter_edge_point,60+180,30));
echo ("point 1 ",points[8]);
echo ("point 2",points[9]);
echo ("point 3",points[10]);
function addBase(path) = concat(path,[[fin_base,-base_extra_thickness],[0,-base_extra_thickness]]);
// Function to create a parallel bezier curve offset by a given amount
function offset_bezier_points(points, offset_distance, normal=[0,0,1]) =
@ -604,7 +577,7 @@ function make_bezier_patch_from_curve(base_points, width, length_steps=32, width
if (false) {
//vnf = bezier_vnf(profile_curve, splinesteps=10);
//vnf = bezier_vnf(profile_curve_with_base, splinesteps=10);
/*
vnf = make_bezier_patch_from_curve(points, width=10);
@ -614,9 +587,9 @@ if (false) {
}
*/
/*
polygon(profile_curve);
vnf2 =vnf_from_region(polygon(profile_curve));
//vnf2 = vnf_from_polygons(profile_curve, fast=true);
polygon(profile_curve_with_base);
vnf2 =vnf_from_region(polygon(profile_curve_with_base));
//vnf2 = vnf_from_polygons(profile_curve_with_base, fast=true);
vnf_polyhedron(vnf2);
*/
@ -646,6 +619,33 @@ if (false) {
}
/**
* Draws a profile based on Bezier path points with optional debug visualization.
*
* @param points - Array of points defining the Bezier path.
* @param debug - Boolean flag to enable/disable debug visualization. Defaults to true.
*
* This module:
* - Calculates the closest point on the Bezier path to a fixed point.
* - Draws the Bezier path with debug information if debug is true.
* - Optionally shows spheres at specific points for debugging (currently commented out).
*/
module drawProfile( points,debug = true ){
debugPoint (start, "Start", "Red" );
debugPoint (top_point, "Top", "Blue" );
debugPoint (edge_point, "Edge", "Brown" );
debugPoint (counter_edge_point, "Counter Edge", "Brown" );
debugPoint (tail_point, "Tail", "Yellow" );
debugPoint (end_point, "End", "Yellow" );
//pt = [100,0];
//pos = bezpath_closest_point(points, pt);
//xy = bezpath_points(points,pos[0],pos[1]);
debug_bezier(points, N=3,width=1.2);
}

View File

@ -1,54 +1,79 @@
module chinook(length,screw = true,pin=true)
{
difference()
{
base_cube(length);
tab_cut();
if (screw) screw_cut();
back_round_cut(length);
if (pin) pin_cut(length);
thickness_cut(length, thick/2);
thickness_cut(length, -thick/2);
}
}
include <BOSL2/std.scad>;
module finfit(base_length, mirror_vec,screw = true,pin=true)
{
front_offset = tab_length;
length = base_length + tab_length;
echo ("length:",length);
mirror(mirror_vec)
translate([0,-front_offset, 0])
chinook( length, screw ,pin );
translate([0,-front_offset, 0])
chinook( length, screw ,pin );
}
module base_cube(BaseLength)
module chinook(length,screw = true,pin=true,thick = 9.2,height=25,tab_height=13,)
{
difference()
{
base_cube( length, thick, height );
tab_cut( thick ,height, tab_height );
if (screw)
screw_cut(tab_height);
back_round_cut(length,thick,height);
if (pin)
pin_cut(length,tab_height);
thickness_cut(length,height, thick/2);
thickness_cut(length,height, -thick/2);
}
}
module chinook_profile(length,thick = 9.2,height=25,tab_height=13,tab_round=13,tab_length=9.6*2)
{
difference(){
rect(
[height,length],
rounding=[tab_round,0,0,0],
anchor=BOTTOM+LEFT
)
{
align(RIGHT+BOTTOM,inside=true,shiftout=0.1)
rect( [ height-tab_height, tab_length+tab_round ],rounding=[0,tab_round-1,0,0] );
}
}
//region(difference(shape1,shape2));
}
module base_cube( length,thick,height )
{
translate([0,0,-thick/2])
cube(size=[height,
BaseLength,
thick],
center=false);
cube(
size=[
height,
length,
thick
],
center=false
);
}
module tab_cut()
module tab_cut( thick, height,tab_height,tab_round=13,tab_length=9.6*2 )
{
translate([tab_height,0,-thick/2*1.1])
union()
{
translate([0,-thick,0])
cube(size=[height,
tab_length+thick,
thick*1.1],
cube(
size=[height, tab_length+thick, thick*1.1],
center=false);
translate([tab_round,tab_length,0])
cylinder(h=thick*1.1,
r=tab_round,
center=false);
cylinder(h=thick*1.1,r=tab_round,center=false);
}
}
module screw_cut()
module screw_cut(tab_height,screw_pos=9.6,screw_dia=4.5)
{
translate([tab_height/2,screw_pos,0])
rotate([0,90,0])
@ -57,7 +82,7 @@ module screw_cut()
center=true);
}
module back_round_cut(BaseLength)
module back_round_cut(BaseLength,thick,height,tab_round=13)
{
translate([height-tab_round,
BaseLength-tab_round,
@ -74,25 +99,44 @@ module back_round_cut(BaseLength)
}
}
module pin_cut(BaseLength)
module pin_cut(BaseLength,tab_height,pin_dia=3, pin_back=9,pin_depth=16.4)
{
translate([pin_depth,
BaseLength-pin_back,
0])
rotate([0,0,0])
cylinder(h=tab_height*1.1,
d=pin_dia,
center=true);
rotate([0,0,0])
cylinder(
h=tab_height*1.1,
d=pin_dia,
center=true
);
}
module thickness_cut(BaseLength, zOffset)
module thickness_cut(BaseLength,height, zOffset,pin_depth=16.4, pin_back=9,thick_cut = 1 )
{
translate([pin_depth,
BaseLength-pin_back,
zOffset])
rotate([0,0,45])
cube(size=[pin_depth*2.2,
height*3,
thick_cut],
center=true);
translate([
pin_depth,
BaseLength-pin_back,
zOffset])
rotate([0,0,45])
cube(
size=[
pin_depth*2.2,
height*3,
thick_cut
],
center=true
);
}
if (true) {
chinook(130+20);
//up(5.2) left() color("Yellow")chinook_profile(130+20);
}

157
lib/finbox_us.scad Normal file
View File

@ -0,0 +1,157 @@
include <BOSL2/std.scad>;
include <BOSL2/beziers.scad>;
include <Round-Anything/polyround.scad>
$fn=64;
OFFSET=0.01;
/**
* US Box profile
* @param length - Length of the fin without the tab and back space
*
**/
module boxProfileUS( length ,height=23, tabHeight = 8,tabLength = 20, backRounding = 8, backExtra = 10 ) {
tabExtra = opp_ang_to_adj(height-tabHeight,45);
points = [
[ -tabLength , 0 ,1], // 0
[ length+backExtra , 0 ,2], // 1
[ length+backExtra , -height ,backRounding], // 2
[ tabExtra , -height ,4], // 3
[ 0 , -tabHeight ,4], // 4
[ -tabLength , -tabHeight ,1] // 5
];
polygon(
polyRound(points)
);
}
function profileUS( length,height=23,tabHeight = 8,tabLength = 20, backRounding = 8, backExtra = 10 ) = polyRound([
[ -tabLength , 0 ,1], // 0
[ length+backExtra , 0 ,2], // 1
[ length+backExtra , -height ,backRounding], // 2
[ opp_ang_to_adj(height-tabHeight,45) , -height ,4], // 3
[ 0 , -tabHeight ,4], // 4
[ -tabLength , -tabHeight ,1] // 5
]);
module usBox( length, height=23, thickness = 9, tabLength = 20,pinDiameter = 5,pinInset = 8, backExtra = 10,cutReduction = 0.5,screw_diameter=4.5,drill = true, color="Grey" ) {
color(color) mirror_copy([0,0,1], offset=-OFFSET) difference() {
linear_extrude ( height = thickness/2 ) boxProfileUS( length, tabLength = tabLength, height=height, backExtra=backExtra );
// Thickness cut
translate([length + backExtra + OFFSET,-OFFSET,thickness/2-cutReduction+OFFSET])
thickness_cut( cutReduction , height );
// Pin drill
if (drill) translate([length+backExtra-pinInset,-height+pinInset,0]) color("Red")
cyl(h=thickness*2,d=pinDiameter,$fn=32);
// Screw Cut
if (drill) translate ([-tabLength/2,-height/2+OFFSET,0]) color ("Red") cyl( h=height, d=screw_diameter, orient=FRONT );
}
}
module usBoxMold( length, height=23, thickness = 9, moldThickness = 4,tabLength = 20,part = "bottom",skirtAngle=80 ) {
moldHeight = thickness + 2 * moldThickness;
skirtHeight = 3 * thickness;
deviation = opp_ang_to_adj (skirtHeight,skirtAngle); // Skirt devitation
baseInt = profileUS (length);
baseExt = offset(baseInt,delta=moldThickness , chamfer=false, same_length=true );
topInt = offset(baseInt,delta=deviation , chamfer=false, same_length=true );
topExt = offset(baseInt,delta=deviation+moldThickness , chamfer=false, same_length=true );
union() {
difference() {
// Mold
{
if ( part == "bottom")
down (moldHeight/2) linear_extrude(moldHeight)
offset(r=moldThickness)
boxProfileUS( length, height );
if ( part == "top") {
//baseInt = profileUS (length);
//baseInt = profileUS (length);
//topInt = offset(baseInt,delta=-deviation,chamfer=false,same_length=true);
baseInt2 = offset(baseInt,delta=-moldThickness,chamfer=false,same_length=true);
topInt2 = offset(baseInt,delta=deviation-moldThickness,chamfer=false,same_length=true);
difference(){
skin([baseInt , topInt ],z=[0,skirtHeight],slices=0);
skin([baseInt2 , topInt2 ],z=[thickness/2,skirtHeight+OFFSET],slices=0);
}
/*
down (moldHeight/2) linear_extrude(moldHeight)
offset(r=moldThickness)
boxProfileUS( length, height );
*/
}
}
// US Box to subtract
usBox(length,height,drill=false,color="Red");
// Mask Top
verticalMask =
part == "bottom" ? 0 :
part == "top" ? moldHeight :
100;
down( verticalMask )
linear_extrude( moldHeight )
offset( r = moldThickness*2 )
boxProfileUS( length, height );
}
if ( part == "bottom") {
// offset is a function
//topInt = offset(baseInt,delta=deviation,chamfer=false,same_length=true);
showSkirt = true;
if (showSkirt) difference(){
skin([baseExt,topExt],z=[0,skirtHeight],slices=0);
skin([baseInt,topInt],z=[0,skirtHeight+OFFSET],slices=0);
}
}
if ( part == "top") {
}
}
}
//test = profileUS (100);
//test2 = offset(test,30);
//region1 =
//region([test,test2]);
//polygon(region1);
module thickness_cut(thickness,height) {
color("Orange")
linear_extrude(thickness)
polygon([
[0 , 0 ],
[0 , -height ],
[-height*2 , -height ]
]);
}
//boxProfileUS( length= 188);
//usBox( 130,drill=false );
usBoxMold( 130,part="top" );
down(50) usBoxMold( 130,part="bottom" );