discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Rotation problem.

O
onekk
Sat, May 5, 2018 8:12 AM

Hi to all, I have done some work on OpenSCAD to make a duct for cooling my
electronics, now I'm facing a problem, the duct is OK, but I have not figure
out how to position the other components.

<code> duct(2,[15,15],50,0,50,[80,80],45,15);

module duct(thick,xy_a=[80,80],off_x,off_y,off_z,xy_b=[10,20],angle_b,pipe){
difference(){
port(thick,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe);
scale(1.01)
port(0,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe);
}
}

module port(d,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe){
hull() {
echo(xy_a,,off_x,off_z,xy_b,angle_b);
cube([xy_a.x+d2,xy_a.y+d2,pipe],center=true);
translate([off_x,off_y,off_z])
rotate([0,angle_b,0])
cube([xy_b.x+d2,xy_b.y+d2,pipe],center=true);

}
}

</code>

want a mean to place an object on the xy_b cube in my case the fan mount but
I didn't find a manner to properly place in this position.

I have thought of replicate the lines

<code> translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); </code>

but I need some advice, I could think i have to make some trigonometrics
transformation on the rotate part to match the angles, as the only thing I
have managed to is to make the "cube" but it is shifted and didn't match the
duct.

Sorry for my bad english

TIA and Regards

Carlo D.

--
Sent from: http://forum.openscad.org/

Hi to all, I have done some work on OpenSCAD to make a duct for cooling my electronics, now I'm facing a problem, the duct is OK, but I have not figure out how to position the other components. <code> duct(2,[15,15],50,0,50,[80,80],45,15); module duct(thick,xy_a=[80,80],off_x,off_y,off_z,xy_b=[10,20],angle_b,pipe){ difference(){ port(thick,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); scale(1.01) port(0,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); } } module port(d,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe){ hull() { echo(xy_a,,off_x,off_z,xy_b,angle_b); cube([xy_a.x+d*2,xy_a.y+d*2,pipe],center=true); translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); } } </code> want a mean to place an object on the xy_b cube in my case the fan mount but I didn't find a manner to properly place in this position. I have thought of replicate the lines <code> translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); </code> but I need some advice, I could think i have to make some trigonometrics transformation on the rotate part to match the angles, as the only thing I have managed to is to make the "cube" but it is shifted and didn't match the duct. Sorry for my bad english TIA and Regards Carlo D. -- Sent from: http://forum.openscad.org/
O
onekk
Sat, May 5, 2018 5:45 PM

Problem solved it was my fault, now it is working.

<code> use <modules/fanmount.scad>;

duct(2,[16,115],65,-20,40,[76,76],60,15);

module duct(thick,xy_a=[80,80],off_x,off_y,off_z,xy_b=[10,20],angle_b,pipe){
difference(){
port(thick,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe);
scale(1.01)
port(0,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe);
}
translate([off_x,off_y,off_z])
rotate([0,angle_b,0])
translate([0,0,pipe/2])
fan_mount(size=80,thick=4,center_obj=[-40,-40,-0.2]) ;

}

module port(d,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe){
hull() {
echo(xy_a,,off_x,off_z,xy_b,angle_b);
cube([xy_a.x+d2,xy_a.y+d2,pipe],center=true);
translate([off_x,off_y,off_z])
rotate([0,angle_b,0])
cube([xy_b.x+d2,xy_b.y+d2,pipe],center=true);

}

}

with the module fan_mount:

<code> ////////////////////////////////////////////////////////// // // OPENSCAD Library file by the DoomMeister // Modified by Dormeletti Carlo - 2018 // Initial commit // 2018-05-04 Added 50x50mm fan, added option to center the holder // ////////////////////////////////////////////////////////// // // Mounting surround for small DC fans (25 - 120mm) // // Data taken from various places around the internet. // http://www.qwikflow.com/dc_fans.html // // Released under the terms of the GNU GPL v3.0 // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY, without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
//////////////////////////////////////////////////////////

module fan_mount(size=40, thick = 4, center_obj=[0,0,0])
{
if(size == 25)
{
_fan_mount(
fan_size = 25,
fan_mounting_pitch = 20,
fan_m_hole_dia = 3,
holder_thickness = thick,
center = center_obj
);
}
if(size == 30)
{
_fan_mount(
fan_size = 30,
fan_mounting_pitch = 24,
fan_m_hole_dia = 3,
holder_thickness = thick,
center = center_obj
);
}

if(size == 40)
{
    _fan_mount(
        fan_size = 40,
        fan_mounting_pitch = 32,
        fan_m_hole_dia = 3.5,
        holder_thickness = thick,
        center = center_obj
    );
}
if(size == 45)
{
    _fan_mount(
        fan_size = 45,
        fan_mounting_pitch = 37,
        fan_m_hole_dia = 4.3,
        holder_thickness = thick,
        center = center_obj
    );
}
if(size == 50)
{
    _fan_mount(
        fan_size = 50,
        fan_mounting_pitch = 42,
        fan_m_hole_dia = 4.3,
        holder_thickness = thick,
        center = center_obj
    );
}

if(size == 60)
{
    _fan_mount(
        fan_size = 60,
        fan_mounting_pitch = 50,
        fan_m_hole_dia = 4.4,
        holder_thickness = thick,
        center = center_obj
    );
}
if(size == 80)
{
    _fan_mount(
        fan_size = 80,
        fan_mounting_pitch = 71.5,
        fan_m_hole_dia = 4.4,
        holder_thickness = thick,
        center = center_obj
    );
}

if(size == 120)
{
    _fan_mount(
        fan_size = 120,
        fan_mounting_pitch = 105,
        fan_m_hole_dia = 4.4,
        holder_thickness = thick,
        center = center_obj
    );
}

}

//inner module
module _fan_mount(
fan_size, //nominsl size of fan
fan_mounting_pitch, //pitch between mounting holes
fan_m_hole_dia, //mounting hole diameter
holder_thickness, //user defined thickness
center // center the created object
)
{

offset1 = (fan_size-(fan_mounting_pitch + fan_m_hole_dia))/2;
offset2 = (fan_size-(fan_mounting_pitch))/2;
offset3 = offset2 + fan_mounting_pitch;
thickness = (fan_size-fan_mounting_pitch)/2;    

//difference()
//{
 
    translate(center)
    linear_extrude(height = holder_thickness)
    union()
    {       
        difference()
        {
            translate([fan_m_hole_dia/2,fan_m_hole_dia/2,0])
            minkowski()
            {       
                square([fan_size - fan_m_hole_dia,fan_size -

fan_m_hole_dia]);
circle(r= fan_m_hole_dia/2, $fn=20);
}

            translate([offset1,offset1,0])
            square([fan_mounting_pitch +

fan_m_hole_dia,fan_mounting_pitch + fan_m_hole_dia]);
}
translate([offset2,offset2,0])
rotate([0,0,0])_corner_hole();
translate([offset3,offset2,0])
rotate([0,0,90])_corner_hole();
translate([offset2,offset3,0])
rotate([0,0,90])_corner_hole();
translate([offset3,offset3,0])
rotate([0,0,0])_corner_hole();
}

    module _corner_hole()
    {
        difference(){
            union(){
                difference(){
                    square([fan_m_hole_dia + thickness,fan_m_hole_dia +

thickness],center=true);
square([(fan_m_hole_dia +
thickness)/2,(fan_m_hole_dia + thickness)/2],center=false);
translate([-(fan_m_hole_dia +
thickness)/2,-(fan_m_hole_dia + thickness)/2])
square([(fan_m_hole_dia +
thickness)/2,(fan_m_hole_dia + thickness)/2],center=false);
}
circle(r=(fan_m_hole_dia + thickness)/2, $fn=20);
}
circle(r=(fan_m_hole_dia)/2, $fn=20);
}
}

    echo(offset1,offset2,thickness);
};

//};

Here if someone is wondering how to make a fanduct with some customization

Regards

Carlo D.

<code/> <code/>

--
Sent from: http://forum.openscad.org/

Problem solved it was my fault, now it is working. <code> use <modules/fanmount.scad>; duct(2,[16,115],65,-20,40,[76,76],60,15); module duct(thick,xy_a=[80,80],off_x,off_y,off_z,xy_b=[10,20],angle_b,pipe){ difference(){ port(thick,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); scale(1.01) port(0,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); } translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) translate([0,0,pipe/2]) fan_mount(size=80,thick=4,center_obj=[-40,-40,-0.2]) ; } module port(d,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe){ hull() { echo(xy_a,,off_x,off_z,xy_b,angle_b); cube([xy_a.x+d*2,xy_a.y+d*2,pipe],center=true); translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); } } with the module fan_mount: <code> ////////////////////////////////////////////////////////// // // OPENSCAD Library file by the DoomMeister // Modified by Dormeletti Carlo - 2018 // Initial commit // 2018-05-04 Added 50x50mm fan, added option to center the holder // ////////////////////////////////////////////////////////// // // Mounting surround for small DC fans (25 - 120mm) // // Data taken from various places around the internet. // http://www.qwikflow.com/dc_fans.html // // Released under the terms of the GNU GPL v3.0 // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY, without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // ////////////////////////////////////////////////////////// module fan_mount(size=40, thick = 4, center_obj=[0,0,0]) { if(size == 25) { _fan_mount( fan_size = 25, fan_mounting_pitch = 20, fan_m_hole_dia = 3, holder_thickness = thick, center = center_obj ); } if(size == 30) { _fan_mount( fan_size = 30, fan_mounting_pitch = 24, fan_m_hole_dia = 3, holder_thickness = thick, center = center_obj ); } if(size == 40) { _fan_mount( fan_size = 40, fan_mounting_pitch = 32, fan_m_hole_dia = 3.5, holder_thickness = thick, center = center_obj ); } if(size == 45) { _fan_mount( fan_size = 45, fan_mounting_pitch = 37, fan_m_hole_dia = 4.3, holder_thickness = thick, center = center_obj ); } if(size == 50) { _fan_mount( fan_size = 50, fan_mounting_pitch = 42, fan_m_hole_dia = 4.3, holder_thickness = thick, center = center_obj ); } if(size == 60) { _fan_mount( fan_size = 60, fan_mounting_pitch = 50, fan_m_hole_dia = 4.4, holder_thickness = thick, center = center_obj ); } if(size == 80) { _fan_mount( fan_size = 80, fan_mounting_pitch = 71.5, fan_m_hole_dia = 4.4, holder_thickness = thick, center = center_obj ); } if(size == 120) { _fan_mount( fan_size = 120, fan_mounting_pitch = 105, fan_m_hole_dia = 4.4, holder_thickness = thick, center = center_obj ); } } //inner module module _fan_mount( fan_size, //nominsl size of fan fan_mounting_pitch, //pitch between mounting holes fan_m_hole_dia, //mounting hole diameter holder_thickness, //user defined thickness center // center the created object ) { offset1 = (fan_size-(fan_mounting_pitch + fan_m_hole_dia))/2; offset2 = (fan_size-(fan_mounting_pitch))/2; offset3 = offset2 + fan_mounting_pitch; thickness = (fan_size-fan_mounting_pitch)/2; //difference() //{ translate(center) linear_extrude(height = holder_thickness) union() { difference() { translate([fan_m_hole_dia/2,fan_m_hole_dia/2,0]) minkowski() { square([fan_size - fan_m_hole_dia,fan_size - fan_m_hole_dia]); circle(r= fan_m_hole_dia/2, $fn=20); } translate([offset1,offset1,0]) square([fan_mounting_pitch + fan_m_hole_dia,fan_mounting_pitch + fan_m_hole_dia]); } translate([offset2,offset2,0]) rotate([0,0,0])_corner_hole(); translate([offset3,offset2,0]) rotate([0,0,90])_corner_hole(); translate([offset2,offset3,0]) rotate([0,0,90])_corner_hole(); translate([offset3,offset3,0]) rotate([0,0,0])_corner_hole(); } module _corner_hole() { difference(){ union(){ difference(){ square([fan_m_hole_dia + thickness,fan_m_hole_dia + thickness],center=true); square([(fan_m_hole_dia + thickness)/2,(fan_m_hole_dia + thickness)/2],center=false); translate([-(fan_m_hole_dia + thickness)/2,-(fan_m_hole_dia + thickness)/2]) square([(fan_m_hole_dia + thickness)/2,(fan_m_hole_dia + thickness)/2],center=false); } circle(r=(fan_m_hole_dia + thickness)/2, $fn=20); } circle(r=(fan_m_hole_dia)/2, $fn=20); } } echo(offset1,offset2,thickness); }; //}; Here if someone is wondering how to make a fanduct with some customization Regards Carlo D. <code/> <code/> -- Sent from: http://forum.openscad.org/
JB
Jordan Brown
Sat, May 5, 2018 5:58 PM

On 5/5/2018 1:12 AM, onekk wrote:

Hi to all, I have done some work on OpenSCAD to make a duct for cooling my
electronics, now I'm facing a problem, the duct is OK, but I have not figure
out how to position the other components.

<code> duct(2,[15,15],50,0,50,[80,80],45,15);

module duct(thick,xy_a=[80,80],off_x,off_y,off_z,xy_b=[10,20],angle_b,pipe){
difference(){
port(thick,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe);
scale(1.01)
port(0,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe);
}
}

module port(d,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe){
hull() {
echo(xy_a,,off_x,off_z,xy_b,angle_b);
cube([xy_a.x+d2,xy_a.y+d2,pipe],center=true);
translate([off_x,off_y,off_z])
rotate([0,angle_b,0])
cube([xy_b.x+d2,xy_b.y+d2,pipe],center=true);

}

}

</code>

want a mean to place an object on the xy_b cube in my case the fan mount but
I didn't find a manner to properly place in this position.

I have thought of replicate the lines

<code> translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); </code>

but I need some advice, I could think i have to make some trigonometrics
transformation on the rotate part to match the angles, as the only thing I
have managed to is to make the "cube" but it is shifted and didn't match the
duct.

When you say ""on the xy_b cube", what exactly do you mean?

Remember that the xy_b cube is centered.

    translate([off_x,off_y,off_z])
    rotate([0,angle_b,0])
(some object)

will put the 0,0,0 point for the object at the same point as the 0,0,0
point of the xy_b cube.  Is that what you want?  If not, you'll probably
want to translate it, before the rotate and translate and translate that
put it into the final location.

For instance, here's a 10x10x10 cube floating on the surface of the xy_b
cube.

duct(2,[15,15],50,0,50,[80,80],45,15);

module duct(thick,xy_a=[80,80],off_x,off_y,off_z,xy_b=[10,20],angle_b,pipe){
difference(){
port(thick,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe);
scale(1.01)
port(0,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe);
}

// Add a floating cube above the wide end.
// Note the inner translate that moves the floater to
// rest atop the "b" cube.
floater_size = 10;
translate([off_x, off_y, off_z])
    rotate([0, angle_b, 0])
    translate([0, 0, pipe/2 + floater_size/2])
    cube([floater_size, floater_size, floater_size], center=true);

}

module port(d,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe){
hull() {
echo(xy_a,,off_x,off_z,xy_b,angle_b);
cube([xy_a.x+d2,xy_a.y+d2,pipe],center=true);
translate([off_x,off_y,off_z])
rotate([0,angle_b,0])
cube([xy_b.x+d2,xy_b.y+d2,pipe],center=true);
}
}

On 5/5/2018 1:12 AM, onekk wrote: > Hi to all, I have done some work on OpenSCAD to make a duct for cooling my > electronics, now I'm facing a problem, the duct is OK, but I have not figure > out how to position the other components. > > <code> > duct(2,[15,15],50,0,50,[80,80],45,15); > > module duct(thick,xy_a=[80,80],off_x,off_y,off_z,xy_b=[10,20],angle_b,pipe){ > difference(){ > port(thick,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); > scale(1.01) > port(0,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); > } > } > > module port(d,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe){ > hull() { > echo(xy_a,,off_x,off_z,xy_b,angle_b); > cube([xy_a.x+d*2,xy_a.y+d*2,pipe],center=true); > translate([off_x,off_y,off_z]) > rotate([0,angle_b,0]) > cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); > > } > } > > </code> > > want a mean to place an object on the xy_b cube in my case the fan mount but > I didn't find a manner to properly place in this position. > > I have thought of replicate the lines > > <code> > translate([off_x,off_y,off_z]) > rotate([0,angle_b,0]) > cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); > </code> > > but I need some advice, I could think i have to make some trigonometrics > transformation on the rotate part to match the angles, as the only thing I > have managed to is to make the "cube" but it is shifted and didn't match the > duct. When you say ""on the xy_b cube", what exactly do you mean? Remember that the xy_b cube is centered. translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) (some object) will put the 0,0,0 point for the object at the same point as the 0,0,0 point of the xy_b cube.  Is that what you want?  If not, you'll probably want to translate it, before the rotate and translate and translate that put it into the final location. For instance, here's a 10x10x10 cube floating on the surface of the xy_b cube. duct(2,[15,15],50,0,50,[80,80],45,15); module duct(thick,xy_a=[80,80],off_x,off_y,off_z,xy_b=[10,20],angle_b,pipe){ difference(){ port(thick,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); scale(1.01) port(0,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); } // Add a floating cube above the wide end. // Note the inner translate that moves the floater to // rest atop the "b" cube. floater_size = 10; translate([off_x, off_y, off_z]) rotate([0, angle_b, 0]) translate([0, 0, pipe/2 + floater_size/2]) cube([floater_size, floater_size, floater_size], center=true); } module port(d,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe){ hull() { echo(xy_a,,off_x,off_z,xy_b,angle_b); cube([xy_a.x+d*2,xy_a.y+d*2,pipe],center=true); translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); } }
P
Parkinbot
Sun, May 6, 2018 9:14 AM

For better printing you might want to orientate the design with the large
cube staying at the xy-plane.

--
Sent from: http://forum.openscad.org/

For better printing you might want to orientate the design with the large cube staying at the xy-plane. -- Sent from: http://forum.openscad.org/
O
onekk
Fri, May 11, 2018 3:45 PM

Many thanks to all.

I have investigated some more and now the project is almost done.

I have found some way to rotate and even add some accessories.

but the hull function generate some weird objects, with much angles and at
even some "holes" in the produced object.

So I think that an approach like those in
Curved-bent-conical-tubing
http://forum.openscad.org/Curved-bent-conical-tubing-td20686.html

could generate a more good shape. But this approach is geared towar circular
tubing, i have to apply to athe square tubing.

At a first glance it could be adapted by creating different shapes, but then
i has to be some polyedron that are difficult to generate.

I have to create a duct that made a transition to a 80x80mm fan to a
rectangular shape of 115x15mm to cool the stepper driver of my 3d printer (A
p3stell with an MKS GEN v1.2 board), but the duct has to be adapted as the X
motor is in the way and it movw up ad down with the Z axis, so a bend is
needed, but this is a simple shape, the transition to the square to
rectangular has to be like this code:

// txz = translation on the xz plane, ie the side of the solid
function txz(s,a) =
[((s.x/2)*cos(a)+(s.z/2)*sin(a)),((s.x/2)*sin(a)+(s.z/2)*cos(a))];

// tyz = translation on the xy plane, ie the top/bottom of the solid
function tyz(s,a) =
[((s.y/2)*cos(a)+(s.z/2)*sin(a)),((s.y/2)*sin(a)+(s.z/2)*cos(a))];

// pt2ptx = calculate the ending point given an angle and distance, on xy
plane (if you give xz)
function pt2ptx(pt,l,a) = [pt.x+(lcos(a)),pt.y+(lsin(a))];

duct(2,[16,115,10],90,[0,0,0],[80,80,10],10,45);

module duct(thick, prt_a=[80,80,3], an_a = 0, off = [0,0,0],
prt_b=[10,20,2],bd_l,an_b){

pt1_a = txz(prt_a,an_a);

// pt2_a is the centre of rotation of the side wall of the duct    
// on the xz plane
pt2_a = pt2ptx(pt1_a,prt_a.z/2,90-an_a);

// pt1_b is the side of the top duct, TODO: it has to be translate in xz
pt1_b = txz(prt_b,an_b);

off_cor = [ off.x+prt_a.x+pt1_b.x, off.y, off.z+pt1_a.y+pt1_b.y];




union(){


    //port A - bottom port
    translate([pt1_a.x,0,pt1_a.y]){

        port(thick,prt_a,an_a);
    }

    //port B - top port

    translate(off_cor){
        port(thick,prt_b,an_b);
    }




}

}

module port(d,prt,an_a){

da_x = prt.x-d*2;
da_y = prt.y-d*2;

difference() {
    rotate([0,an_a,0] ){
        cube(prt,center=true);
    }

    rotate([0,an_a,0]){
        translate([0,0,-0.05]){
            cube([da_x,da_y,prt.z+0.15],center=true);
        }
    }
}

}

Sorry for my bad english and even worse explication.

Carlo D.

--
Sent from: http://forum.openscad.org/

Many thanks to all. I have investigated some more and now the project is almost done. I have found some way to rotate and even add some accessories. but the hull function generate some weird objects, with much angles and at even some "holes" in the produced object. So I think that an approach like those in Curved-bent-conical-tubing <http://forum.openscad.org/Curved-bent-conical-tubing-td20686.html> could generate a more good shape. But this approach is geared towar circular tubing, i have to apply to athe square tubing. At a first glance it could be adapted by creating different shapes, but then i has to be some polyedron that are difficult to generate. I have to create a duct that made a transition to a 80x80mm fan to a rectangular shape of 115x15mm to cool the stepper driver of my 3d printer (A p3stell with an MKS GEN v1.2 board), but the duct has to be adapted as the X motor is in the way and it movw up ad down with the Z axis, so a bend is needed, but this is a simple shape, the transition to the square to rectangular has to be like this code: // txz = translation on the xz plane, ie the side of the solid function txz(s,a) = [((s.x/2)*cos(a)+(s.z/2)*sin(a)),((s.x/2)*sin(a)+(s.z/2)*cos(a))]; // tyz = translation on the xy plane, ie the top/bottom of the solid function tyz(s,a) = [((s.y/2)*cos(a)+(s.z/2)*sin(a)),((s.y/2)*sin(a)+(s.z/2)*cos(a))]; // pt2ptx = calculate the ending point given an angle and distance, on xy plane (if you give xz) function pt2ptx(pt,l,a) = [pt.x+(l*cos(a)),pt.y+(l*sin(a))]; duct(2,[16,115,10],90,[0,0,0],[80,80,10],10,45); module duct(thick, prt_a=[80,80,3], an_a = 0, off = [0,0,0], prt_b=[10,20,2],bd_l,an_b){ pt1_a = txz(prt_a,an_a); // pt2_a is the centre of rotation of the side wall of the duct // on the xz plane pt2_a = pt2ptx(pt1_a,prt_a.z/2,90-an_a); // pt1_b is the side of the top duct, TODO: it has to be translate in xz pt1_b = txz(prt_b,an_b); off_cor = [ off.x+prt_a.x+pt1_b.x, off.y, off.z+pt1_a.y+pt1_b.y]; union(){ //port A - bottom port translate([pt1_a.x,0,pt1_a.y]){ port(thick,prt_a,an_a); } //port B - top port translate(off_cor){ port(thick,prt_b,an_b); } } } module port(d,prt,an_a){ da_x = prt.x-d*2; da_y = prt.y-d*2; difference() { rotate([0,an_a,0] ){ cube(prt,center=true); } rotate([0,an_a,0]){ translate([0,0,-0.05]){ cube([da_x,da_y,prt.z+0.15],center=true); } } } } Sorry for my bad english and even worse explication. Carlo D. -- Sent from: http://forum.openscad.org/
O
onekk
Fri, May 11, 2018 4:17 PM

Searching in this forum I've found the list-comprehension-demo and scad-utils

so I've tailored the extrusion.scad code to obtain a shape that is better
suited to my liking.

use <scad-utils/transformations.scad>
use <scad-utils/lists.scad>
use <scad-utils/shapes.scad>
use <skin.scad>

fn=32;

difference(){
skin([
transform(translation([0,0,0]),
rounded_rectangle_profile([115,15],fn=fn,r=3)),
transform(translation([0,0,5]),
rounded_rectangle_profile([115,15],fn=fn,r=3)),
transform(translation([15,20,15]),
rounded_rectangle_profile([80,80],fn=fn,r=3)),
transform(translation([15,20,20]),
rounded_rectangle_profile([80,80],fn=fn,r=3)),
]);

skin([
transform(translation([0,0,0]),
rounded_rectangle_profile([111,11],fn=fn,r=1)),
transform(translation([0,0,5]),
rounded_rectangle_profile([111,11],fn=fn,r=1)),
transform(translation([15,20,15]),
rounded_rectangle_profile([76,76],fn=fn,r=1)),
transform(translation([15,20,20]),
rounded_rectangle_profile([76,76],fn=fn,r=1)),
]);
}


But I have to work to attach some parametrized brackets to the structure.

BTW there is a mean to obtain a slice of the geometry created to visualize
the thickness of the walls? (In OpenSCAD), i think like a slice of the
geometry created and an animation to raise this slice (a sort of a
simulation of a 3d printing, but with the solid created in openscad)?

Many thanks to all and Regards

Carlo D.

--
Sent from: http://forum.openscad.org/

Searching in this forum I've found the list-comprehension-demo and scad-utils so I've tailored the extrusion.scad code to obtain a shape that is better suited to my liking. use <scad-utils/transformations.scad> use <scad-utils/lists.scad> use <scad-utils/shapes.scad> use <skin.scad> fn=32; difference(){ skin([ transform(translation([0,0,0]), rounded_rectangle_profile([115,15],fn=fn,r=3)), transform(translation([0,0,5]), rounded_rectangle_profile([115,15],fn=fn,r=3)), transform(translation([15,20,15]), rounded_rectangle_profile([80,80],fn=fn,r=3)), transform(translation([15,20,20]), rounded_rectangle_profile([80,80],fn=fn,r=3)), ]); skin([ transform(translation([0,0,0]), rounded_rectangle_profile([111,11],fn=fn,r=1)), transform(translation([0,0,5]), rounded_rectangle_profile([111,11],fn=fn,r=1)), transform(translation([15,20,15]), rounded_rectangle_profile([76,76],fn=fn,r=1)), transform(translation([15,20,20]), rounded_rectangle_profile([76,76],fn=fn,r=1)), ]); } ---- But I have to work to attach some parametrized brackets to the structure. BTW there is a mean to obtain a slice of the geometry created to visualize the thickness of the walls? (In OpenSCAD), i think like a slice of the geometry created and an animation to raise this slice (a sort of a simulation of a 3d printing, but with the solid created in openscad)? Many thanks to all and Regards Carlo D. -- Sent from: http://forum.openscad.org/