Angled Hollow Square Tube ?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Angled Hollow Square Tube ?

daver18qc
This post has NOT been accepted by the mailing list yet.
Hi everyone !

I am quite a beginner at OpenSCAD but have some knowledge of programming.
I already created many things that i printed with my 3d printer using OpenSCAD.

I am trying to create a hollow square tube on an angle.

So what i tried is this :

--------------CODE------------------
$fn = 100;

module hollow_square(){
        rotate([0,90,0])
        difference(){
                cube([12,12,2], center=true);
                cube([10,10,4], center=true);
        }
}


hull(){
        hollow_square();
        translate([100,0,20]) hollow_square();
}
-----------END-CODE---------------

Problem is, the HULL closes the ends of my hollow cubes and thus gives me a solid angled rectangle instead...

Is there a way to tell HULL to respect the hole i created in the cubes ??

Thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Angled Hollow Square Tube ?

MichaelAtOz
Administrator

Hi Daver,
daver18qc wrote
Hi everyone !

I am quite a beginner at OpenSCAD but have some knowledge of programming.
I already created many things that i printed with my 3d printer using OpenSCAD.

I am trying to create a hollow square tube on an angle.

So what i tried is this :

--------------CODE------------------
$fn = 100;

module hollow_square(){
        rotate([0,90,0])
        difference(){
                cube([12,12,2], center=true);
                cube([10,10,4], center=true);
        }
}


hull(){
        hollow_square();
        translate([100,0,20]) hollow_square();
}
-----------END-CODE---------------

Problem is, the HULL closes the ends of my hollow cubes and thus gives me a solid angled rectangle instead...

Is there a way to tell HULL to respect the hole i created in the cubes ??

Thanks!
> Is there a way to tell HULL to respect the hole

Well that is hull()'s reason for living, so unwind the difference;

$fn = 100;
size=12;
thick=1;

module square(size,diff=false)
        rotate([0,90,0])
                cube([size,size,(diff) ? 0.2 : 0.01], center=true);

module square_bar(start,end,size,diff=false) {
        hull() {
                translate(start)
                        square(size,diff);
                translate(end)
                        square(size,diff);
        }
}

module square_tube(start,end,size,thick) {
        difference() {
                square_bar(start,end,size);
                square_bar(start,end,size-2*thick,diff=true);
        }
}

square_tube([0,0,0],[100,0,20],size,thick);


All the 'diff's are to cleanup the z-fighting on the ends.
Admin - PM me if you need anything,
or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Angled Hollow Square Tube ?

daver18qc
Oh thanks !
Not sure i understand all of that code yet but i'm gonna study it !
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Angled Hollow Square Tube ?

MichaelAtOz
Administrator
Note that I did it that way presuming you wanted the 'vertical' cuts on the ends.
Admin - PM me if you need anything,
or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Angled Hollow Square Tube ?

MichaelAtOz
Administrator
In reply to this post by daver18qc
For plain old square tube, this is more standard;

module square_tube2(size,thick,long) {
cut_size=size-2*thick;
translate([0,0,long/2]) // move to z=0
        difference() {
                cube([size,size,long],center=true);
                        cube([cut_size,cut_size,long+0.5],center=true);
        }
}

square_tube2(size,thick,100);
Admin - PM me if you need anything,
or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Loading...