将角度/角度配置文件添加到 openscad 倒钩对象

Adding an angle / angle profile to openscad barbed object

我有一个 openscad 对象,我想将角度/角度轮廓一直添加到倒钩对象的底部。

原始(当前创建的内容):

我想要什么:(底部一直不是平坦的,而是像 45,50,60...这样的角度/角度轮廓)

代码:

    ////////////////////////////////////////////////////////
// Created by Paul Tibble - 18/7/19                   //
// https://www.thingiverse.com/Paul_Tibble/about      //
// Please consider tipping, if you find this useful.  //
////////////////////////////////////////////////////////

$fn = 100*1;

// Outer Diameter (bottom)
outer_diameter_1 = 15;
// Wall Thickness (bottom)
wall_thickness_1 = 2;
// Rib Thickness (bottom), set to Zero to remove
barb_size_1 = 0.5;
// Length (bottom)
length_1 = 15;
// Outer Diameter (top), should be smaller than or equal to Outer Diameter (bottom)
outer_diameter_2 = 12;
// Wall Thickness (top)
wall_thickness_2 = 1;
// Rib Thickness (top), set to Zero to remove
barb_size_2 = 0.5;
// Length (top)
length_2 = 15;
// Middle Diameter
mid_diameter = 17;
// Middle Length
mid_length = 5;


//do not change these
inner_diameter_1 = outer_diameter_1 - (wall_thickness_1*2);
inner_diameter_2 = outer_diameter_2 - (wall_thickness_2*2);

module create_profile() {
    ////////
    // Middle
    ///////
    polygon(points=[[inner_diameter_1/2,length_1],[mid_diameter/2,length_1],[mid_diameter/2,length_1+mid_length],[inner_diameter_2/2,length_1+mid_length]]);
    //////
    //length 1
    /////
    translate([inner_diameter_1/2,0,0])square([wall_thickness_1,length_1]);
    //barb 1
    translate([outer_diameter_1/2,0,0])polygon(points=[[0,0],[0,(length_1/5)],[barb_size_1,(length_1/5)]]);
    //barb 2
    translate([outer_diameter_1/2,length_1*0.25,0])polygon(points=[[0,0],[0,(length_1/5)],[barb_size_1,(length_1/5)]]);
    //barb 3
    translate([outer_diameter_1/2,length_1*0.5,0])polygon(points=[[0,0],[0,(length_1/5)],[barb_size_1,(length_1/5)]]);
    //////
    //length 2
    /////
    translate([inner_diameter_2/2,length_1+mid_length,0])square([wall_thickness_2,length_2]);
    //rib 1
    translate([outer_diameter_2/2,(length_1+mid_length+length_2),0])polygon(points=[[0,0],[0,-1*(length_2/5)],[barb_size_2,-1*(length_2/5)]]);
    //rib 2
    translate([outer_diameter_2/2,(length_1+mid_length+length_2)-length_2*0.25,0])polygon(points=[[0,0],[0,-1*(length_2/5)],[barb_size_2,-1*(length_2/5)]]);
    //rib 3
    translate([outer_diameter_2/2,(length_1+mid_length+length_2)-length_2*0.5,0])polygon(points=[[0,0],[0,-1*(length_2/5)],[barb_size_2,-1*(length_2/5)]]);
}

rotate_extrude(angle = 360, convexity = 10) create_profile();
//create_profile();

只需移动倒钩的内上点- resp。肋多边形的内部较低点(第二个点的 y 值)。为此,通过所需角度的切线计算 z-delta。 可以通过为倒钩和肋骨创建模块并将它们放在for循环中来简化代码,这里修改代码:

$fn = 100*1;

// Outer Diameter (bottom)
outer_diameter_1 = 15;
// Wall Thickness (bottom)
wall_thickness_1 = 2;
// Rib Thickness (bottom), set to Zero to remove
barb_size_1 = 0.5;
// Length (bottom)
length_1 = 15;
// Outer Diameter (top), should be smaller than or equal to Outer Diameter (bottom)
outer_diameter_2 = 12;
// Wall Thickness (top)
wall_thickness_2 = 1;
// Rib Thickness (top), set to Zero to remove
barb_size_2 = 0.5;
// Length (top)
length_2 = 15;
// Middle Diameter
mid_diameter = 17;
// Middle Length
mid_length = 5;

// barb angle
ba = 30;

//do not change these

// delta z
// tan(ba) = dz1/barb_size_1
dz1 = barb_size_1*tan(ba);
dz2 = barb_size_2*tan(ba);

inner_diameter_1 = outer_diameter_1 - (wall_thickness_1*2);
inner_diameter_2 = outer_diameter_2 - (wall_thickness_2*2);


module barb(dz) {
    polygon(points=[[0, 0],[0, (length_1/5 + dz)],[barb_size_1, (length_1/5)]]); 
}

module rib(dz) {
    polygon(points=[[0, 0],[0,-1*(length_2/5 + dz)],[barb_size_2,-1*(length_2/5)]]);
}
 
module create_profile() {
    // Middle
    polygon(points=[[inner_diameter_1/2,length_1],[mid_diameter/2,length_1],[mid_diameter/2,length_1+mid_length],[inner_diameter_2/2,length_1+mid_length]]);
    //length 1

    translate([inner_diameter_1/2,0,0])square([wall_thickness_1,length_1]);

    //barbs
    for (z = [0, 0.25, 0.5]) {
        translate([outer_diameter_1/2, length_1*z, 0]) barb(dz1);
    }

    //length_2
    translate([inner_diameter_2/2,length_1+mid_length,0])square([wall_thickness_2,length_2]);

    //ribs
    for (z = [0, 0.25, 0.5]) {
        translate([outer_diameter_2/2,(length_1+mid_length+length_2)-length_2*z,0]) rib(dz2);
    }
}

rotate_extrude(angle = 360, convexity = 10) create_profile();
//create_profile();

看起来像这样:

这是 Openscad 列表帮助我拼凑的一些东西。

////////////////////////////////////////////////////////
// Created by Paul Tibble - 18/7/19 + Openscad group 2021                  //
// https://www.thingiverse.com/Paul_Tibble/about      //
// Please consider tipping, if you find this useful.  //
////////////////////////////////////////////////////////

$fn = 100*1;

// Outer Diameter (bottom)
outer_diameter_1 = 15;
// Wall Thickness (bottom)
wall_thickness_1 = 2;
// Rib Thickness (bottom), set to Zero to remove
barb_size_1 = 0.5;
// Length (bottom)
length_1 = 15;
// Outer Diameter (top), should be smaller than or equal to Outer Diameter (bottom)
outer_diameter_2 = 12;
// Wall Thickness (top)
wall_thickness_2 = 1;
// Rib Thickness (top), set to Zero to remove
barb_size_2 = 0.5;
// Length (top)
length_2 = 15;
// Middle Diameter
mid_diameter = 17;
// Middle Length
mid_length = 5;
// Barb Angles (90 deg) makes it flat 20 to 30
barb_angle = 30; // adjust to get angle you want.  90 or 0 makes it flat rt
// Barb Angles (90 deg) makes it flat 20 to 30
mid_barb_angle = 30; // adjust to get angle you want.  90 or 0 makes it flat rt

barb_angle_tmp_1 = length_1 / barb_angle;
barb_angle_tmp_2 = length_2 / barb_angle;
mid_barb_angle_tmp_1 = mid_diameter / mid_barb_angle - (mid_diameter/2);


//do not change these
inner_diameter_1 = outer_diameter_1 - (wall_thickness_1*2);
inner_diameter_2 = outer_diameter_2 - (wall_thickness_2*2);

module create_profile() {
    ////////
    // Middle
    ///////
    polygon(points=[[inner_diameter_1/2,length_1+mid_barb_angle_tmp_1],[mid_diameter/2,length_1],[mid_diameter/2,length_1+mid_length],[inner_diameter_2/2,length_1+mid_length]]);
    //////
    //length 1
    /////
    translate([inner_diameter_1/2,0,0])square([wall_thickness_1,length_1]);
    //barb 1
    translate([outer_diameter_1/2,0,0])polygon(points=[[0,0],[0,(length_1/5+barb_angle_tmp_1)],[barb_size_1,(length_1/5)]]);
    //barb 2
    translate([outer_diameter_1/2,length_1*0.25,0])polygon(points=[[0,0],[0,(length_1/5+barb_angle_tmp_1)],[barb_size_1,(length_1/5)]]);
    //barb 3
    translate([outer_diameter_1/2,length_1*0.5,0])polygon(points=[[0,0],[0,(length_1/5+barb_angle_tmp_1)],[barb_size_1,(length_1/5)]]);
    //////
    //length 2
    /////
    translate([inner_diameter_2/2,length_1+mid_length,0])square([wall_thickness_2,length_2]);
    //rib 1
    translate([outer_diameter_2/2,(length_1+mid_length+length_2),0])polygon(points=[[0,0],[0,-1*(length_2/5+barb_angle_tmp_2)],[barb_size_2,-1*(length_2/5)]]);
    //rib 2
    translate([outer_diameter_2/2,(length_1+mid_length+length_2)-length_2*0.25,0])polygon(points=[[0,0],[0,-1*(length_2/5+barb_angle_tmp_2)],[barb_size_2,-1*(length_2/5)]]);
    //rib 3
    translate([outer_diameter_2/2,(length_1+mid_length+length_2)-length_2*0.5,0])polygon(points=[[0,0],[0,-1*(length_2/5+barb_angle_tmp_2)],[barb_size_2,-1*(length_2/5)]]);
}

rotate_extrude(angle = 360, convexity = 10) create_profile();
//create_profile();