discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Cylindrical Skew?

SP
Sanjeev Prabhakar
Sun, Mar 3, 2024 5:11 PM

python code is here:

od=150
id=75
n=16
t=3
sl_ang=50
sl_h=(od/2-id/2)*tan(d2r(sl_ang))
a=c2t3(circle(od/2,s=n+1))
b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(od/2,s=n+1)))
h=l_len(a[:2])/2

sol_1=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]
a=flip(c2t3(circle(od/2,s=n+1)))
b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(od/2,s=n+1))))
h=l_len(a[:2])/2
sol_2=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]

a=c2t3(circle(id/2,s=n+1))
b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(id/2,s=n+1)))

h=l_len(a[:2])/2

sol_3=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]

a=flip(c2t3(circle(id/2,s=n+1)))
b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(id/2,s=n+1))))

h=l_len(a[:2])/2

sol_4=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]

a=[seg(p)[:-1] for p in cpo(sol_1)]
b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_3))]

sol_5=array([a,b]).transpose(1,2,0,3,4).tolist()

a=[seg(p)[:-1] for p in cpo(sol_2)]
b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_4))]

sol_6=array([a,b]).transpose(1,2,0,3,4).tolist()

with open('trial.scad','w+') as f:
f.write(f'''
include<dependencies2.scad>

for(p={sol_5})for(p1=p)
    let(
    a=slice_sol(p1,10)
    )
    for(i=[1:len(a)-1])
hull(){{
p_line3d(a[i-1],{t/2},1);
p_line3d(a[i],{t/2},1);
}}

    for(p={sol_6})for(p1=p)

    let(
    a=slice_sol(p1,10)
    )
    for(i=[1:len(a)-1])
hull(){{
p_line3d(a[i-1],{t/2},1);
p_line3d(a[i],{t/2},1);
}}

''')

Apart from above you would need file dependencies2.scad, a library I have
written , which is a much smaller version of dependencies.scad
Also attached revised trial.scad

On Sun, 3 Mar 2024 at 22:36, azdle azdle@azdle.net wrote:

Yeah! That looks like pretty much exactly what I'm going for.

Any chance you can share the scad file and the python too?

On Sun, Mar 3 2024 at 10:14:47 PM +0530, Sanjeev Prabhakar
sprabhakar2006@gmail.com wrote:

I do all the calculations in python and render results in openSCAD
and use native features of openSCAD like intersection, difference etc
to draw shapes.
and it is perfectly parametric in python
Is this the shape?

python code is here: od=150 id=75 n=16 t=3 sl_ang=50 sl_h=(od/2-id/2)*tan(d2r(sl_ang)) a=c2t3(circle(od/2,s=n+1)) b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(od/2,s=n+1))) h=l_len(a[:2])/2 sol_1=[translate([0,0,i*h],a) if i%2==0 else translate([0,0,i*h],b) for i in range(5)] a=flip(c2t3(circle(od/2,s=n+1))) b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(od/2,s=n+1)))) h=l_len(a[:2])/2 sol_2=[translate([0,0,i*h],a) if i%2==0 else translate([0,0,i*h],b) for i in range(5)] a=c2t3(circle(id/2,s=n+1)) b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(id/2,s=n+1))) # h=l_len(a[:2])/2 sol_3=[translate([0,0,i*h],a) if i%2==0 else translate([0,0,i*h],b) for i in range(5)] a=flip(c2t3(circle(id/2,s=n+1))) b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(id/2,s=n+1)))) # h=l_len(a[:2])/2 sol_4=[translate([0,0,i*h],a) if i%2==0 else translate([0,0,i*h],b) for i in range(5)] a=[seg(p)[:-1] for p in cpo(sol_1)] b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_3))] sol_5=array([a,b]).transpose(1,2,0,3,4).tolist() a=[seg(p)[:-1] for p in cpo(sol_2)] b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_4))] sol_6=array([a,b]).transpose(1,2,0,3,4).tolist() with open('trial.scad','w+') as f: f.write(f''' include<dependencies2.scad> for(p={sol_5})for(p1=p) let( a=slice_sol(p1,10) ) for(i=[1:len(a)-1]) hull(){{ p_line3d(a[i-1],{t/2},1); p_line3d(a[i],{t/2},1); }} for(p={sol_6})for(p1=p) let( a=slice_sol(p1,10) ) for(i=[1:len(a)-1]) hull(){{ p_line3d(a[i-1],{t/2},1); p_line3d(a[i],{t/2},1); }} ''') Apart from above you would need file dependencies2.scad, a library I have written , which is a much smaller version of dependencies.scad Also attached revised trial.scad On Sun, 3 Mar 2024 at 22:36, azdle <azdle@azdle.net> wrote: > Yeah! That looks like pretty much exactly what I'm going for. > > Any chance you can share the scad file and the python too? > > On Sun, Mar 3 2024 at 10:14:47 PM +0530, Sanjeev Prabhakar > <sprabhakar2006@gmail.com> wrote: > > I do all the calculations in python and render results in openSCAD > > and use native features of openSCAD like intersection, difference etc > > to draw shapes. > > and it is perfectly parametric in python > > Is this the shape? > > > > > > >
A
azdle
Sun, Mar 3, 2024 5:12 PM

Wonderful, thanks!

On Sun, Mar 3 2024 at 10:41:33 PM +0530, Sanjeev Prabhakar
sprabhakar2006@gmail.com wrote:

python code is here:

od=150
id=75
n=16
t=3
sl_ang=50
sl_h=(od/2-id/2)*tan(d2r(sl_ang))
a=c2t3(circle(od/2,s=n+1))
b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(od/2,s=n+1)))
h=l_len(a[:2])/2

sol_1=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]
a=flip(c2t3(circle(od/2,s=n+1)))
b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(od/2,s=n+1))))
h=l_len(a[:2])/2
sol_2=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]

a=c2t3(circle(id/2,s=n+1))
b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(id/2,s=n+1)))

h=l_len(a[:2])/2

sol_3=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]

a=flip(c2t3(circle(id/2,s=n+1)))
b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(id/2,s=n+1))))

h=l_len(a[:2])/2

sol_4=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]

a=[seg(p)[:-1] for p in cpo(sol_1)]
b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_3))]

sol_5=array([a,b]).transpose(1,2,0,3,4).tolist()

a=[seg(p)[:-1] for p in cpo(sol_2)]
b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_4))]

sol_6=array([a,b]).transpose(1,2,0,3,4).tolist()

with open('trial.scad','w+') as f:
f.write(f'''
include<dependencies2.scad>

 for(p={sol_5})for(p1=p)
     let(
     a=slice_sol(p1,10)
     )
     for(i=[1:len(a)-1])
 hull(){{
 p_line3d(a[i-1],{t/2},1);
 p_line3d(a[i],{t/2},1);
 }}

     for(p={sol_6})for(p1=p)

     let(
     a=slice_sol(p1,10)
     )
     for(i=[1:len(a)-1])
 hull(){{
 p_line3d(a[i-1],{t/2},1);
 p_line3d(a[i],{t/2},1);
 }}

 ''')

Apart from above you would need file dependencies2.scad, a library I
have written , which is a much smaller version of dependencies.scad
Also attached revised trial.scad

On Sun, 3 Mar 2024 at 22:36, azdle azdle@azdle.net wrote:

Yeah! That looks like pretty much exactly what I'm going for.

Any chance you can share the scad file and the python too?

On Sun, Mar 3 2024 at 10:14:47 PM +0530, Sanjeev Prabhakar
sprabhakar2006@gmail.com wrote:

I do all the calculations in python and render results in openSCAD
and use native features of openSCAD like intersection, difference

etc

to draw shapes.
and it is perfectly parametric in python
Is this the shape?

Wonderful, thanks! On Sun, Mar 3 2024 at 10:41:33 PM +0530, Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > python code is here: > > od=150 > id=75 > n=16 > t=3 > sl_ang=50 > sl_h=(od/2-id/2)*tan(d2r(sl_ang)) > a=c2t3(circle(od/2,s=n+1)) > b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(od/2,s=n+1))) > h=l_len(a[:2])/2 > > sol_1=[translate([0,0,i*h],a) if i%2==0 > else translate([0,0,i*h],b) > for i in range(5)] > a=flip(c2t3(circle(od/2,s=n+1))) > b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(od/2,s=n+1)))) > h=l_len(a[:2])/2 > sol_2=[translate([0,0,i*h],a) if i%2==0 > else translate([0,0,i*h],b) > for i in range(5)] > > a=c2t3(circle(id/2,s=n+1)) > b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(id/2,s=n+1))) > # h=l_len(a[:2])/2 > > sol_3=[translate([0,0,i*h],a) if i%2==0 > else translate([0,0,i*h],b) > for i in range(5)] > > a=flip(c2t3(circle(id/2,s=n+1))) > b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(id/2,s=n+1)))) > # h=l_len(a[:2])/2 > sol_4=[translate([0,0,i*h],a) if i%2==0 > else translate([0,0,i*h],b) > for i in range(5)] > > a=[seg(p)[:-1] for p in cpo(sol_1)] > b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_3))] > > sol_5=array([a,b]).transpose(1,2,0,3,4).tolist() > > a=[seg(p)[:-1] for p in cpo(sol_2)] > b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_4))] > > sol_6=array([a,b]).transpose(1,2,0,3,4).tolist() > > with open('trial.scad','w+') as f: > f.write(f''' > include<dependencies2.scad> > > for(p={sol_5})for(p1=p) > let( > a=slice_sol(p1,10) > ) > for(i=[1:len(a)-1]) > hull(){{ > p_line3d(a[i-1],{t/2},1); > p_line3d(a[i],{t/2},1); > }} > > for(p={sol_6})for(p1=p) > > let( > a=slice_sol(p1,10) > ) > for(i=[1:len(a)-1]) > hull(){{ > p_line3d(a[i-1],{t/2},1); > p_line3d(a[i],{t/2},1); > }} > > ''') > > Apart from above you would need file dependencies2.scad, a library I > have written , which is a much smaller version of dependencies.scad > Also attached revised trial.scad > > On Sun, 3 Mar 2024 at 22:36, azdle <azdle@azdle.net> wrote: >> Yeah! That looks like pretty much exactly what I'm going for. >> >> Any chance you can share the scad file and the python too? >> >> On Sun, Mar 3 2024 at 10:14:47 PM +0530, Sanjeev Prabhakar >> <sprabhakar2006@gmail.com> wrote: >> > I do all the calculations in python and render results in openSCAD >> > and use native features of openSCAD like intersection, difference >> etc >> > to draw shapes. >> > and it is perfectly parametric in python >> > Is this the shape? >> > >> > >> >>
SP
Sanjeev Prabhakar
Sun, Mar 3, 2024 5:15 PM

sorry i missed
you would also need to import another python library written by me:
openscad1.py

it is available here:
https://github.com/sprabhakar2006/openSCAD/blob/main/openscad1.py

it is a little complicated initially

On Sun, 3 Mar 2024 at 22:41, Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

python code is here:

od=150
id=75
n=16
t=3
sl_ang=50
sl_h=(od/2-id/2)*tan(d2r(sl_ang))
a=c2t3(circle(od/2,s=n+1))
b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(od/2,s=n+1)))
h=l_len(a[:2])/2

sol_1=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]
a=flip(c2t3(circle(od/2,s=n+1)))
b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(od/2,s=n+1))))
h=l_len(a[:2])/2
sol_2=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]

a=c2t3(circle(id/2,s=n+1))
b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(id/2,s=n+1)))

h=l_len(a[:2])/2

sol_3=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]

a=flip(c2t3(circle(id/2,s=n+1)))
b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(id/2,s=n+1))))

h=l_len(a[:2])/2

sol_4=[translate([0,0,ih],a) if i%2==0
else translate([0,0,i
h],b)
for i in range(5)]

a=[seg(p)[:-1] for p in cpo(sol_1)]
b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_3))]

sol_5=array([a,b]).transpose(1,2,0,3,4).tolist()

a=[seg(p)[:-1] for p in cpo(sol_2)]
b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_4))]

sol_6=array([a,b]).transpose(1,2,0,3,4).tolist()

with open('trial.scad','w+') as f:
f.write(f'''
include<dependencies2.scad>

 for(p={sol_5})for(p1=p)
     let(
     a=slice_sol(p1,10)
     )
     for(i=[1:len(a)-1])
 hull(){{
 p_line3d(a[i-1],{t/2},1);
 p_line3d(a[i],{t/2},1);
 }}

     for(p={sol_6})for(p1=p)

     let(
     a=slice_sol(p1,10)
     )
     for(i=[1:len(a)-1])
 hull(){{
 p_line3d(a[i-1],{t/2},1);
 p_line3d(a[i],{t/2},1);
 }}

 ''')

Apart from above you would need file dependencies2.scad, a library I have
written , which is a much smaller version of dependencies.scad
Also attached revised trial.scad

On Sun, 3 Mar 2024 at 22:36, azdle azdle@azdle.net wrote:

Yeah! That looks like pretty much exactly what I'm going for.

Any chance you can share the scad file and the python too?

On Sun, Mar 3 2024 at 10:14:47 PM +0530, Sanjeev Prabhakar
sprabhakar2006@gmail.com wrote:

I do all the calculations in python and render results in openSCAD
and use native features of openSCAD like intersection, difference etc
to draw shapes.
and it is perfectly parametric in python
Is this the shape?

sorry i missed you would also need to import another python library written by me: openscad1.py it is available here: https://github.com/sprabhakar2006/openSCAD/blob/main/openscad1.py it is a little complicated initially On Sun, 3 Mar 2024 at 22:41, Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > python code is here: > > od=150 > id=75 > n=16 > t=3 > sl_ang=50 > sl_h=(od/2-id/2)*tan(d2r(sl_ang)) > a=c2t3(circle(od/2,s=n+1)) > b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(od/2,s=n+1))) > h=l_len(a[:2])/2 > > sol_1=[translate([0,0,i*h],a) if i%2==0 > else translate([0,0,i*h],b) > for i in range(5)] > a=flip(c2t3(circle(od/2,s=n+1))) > b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(od/2,s=n+1)))) > h=l_len(a[:2])/2 > sol_2=[translate([0,0,i*h],a) if i%2==0 > else translate([0,0,i*h],b) > for i in range(5)] > > a=c2t3(circle(id/2,s=n+1)) > b=q_rot([f'z{360/len(a)/2}'],c2t3(circle(id/2,s=n+1))) > # h=l_len(a[:2])/2 > > sol_3=[translate([0,0,i*h],a) if i%2==0 > else translate([0,0,i*h],b) > for i in range(5)] > > a=flip(c2t3(circle(id/2,s=n+1))) > b=flip(q_rot([f'z{-360/len(a)/2}'],c2t3(circle(id/2,s=n+1)))) > # h=l_len(a[:2])/2 > sol_4=[translate([0,0,i*h],a) if i%2==0 > else translate([0,0,i*h],b) > for i in range(5)] > > a=[seg(p)[:-1] for p in cpo(sol_1)] > b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_3))] > > sol_5=array([a,b]).transpose(1,2,0,3,4).tolist() > > a=[seg(p)[:-1] for p in cpo(sol_2)] > b=[seg(p)[:-1] for p in translate([0,0,sl_h],cpo(sol_4))] > > sol_6=array([a,b]).transpose(1,2,0,3,4).tolist() > > with open('trial.scad','w+') as f: > f.write(f''' > include<dependencies2.scad> > > for(p={sol_5})for(p1=p) > let( > a=slice_sol(p1,10) > ) > for(i=[1:len(a)-1]) > hull(){{ > p_line3d(a[i-1],{t/2},1); > p_line3d(a[i],{t/2},1); > }} > > for(p={sol_6})for(p1=p) > > let( > a=slice_sol(p1,10) > ) > for(i=[1:len(a)-1]) > hull(){{ > p_line3d(a[i-1],{t/2},1); > p_line3d(a[i],{t/2},1); > }} > > ''') > > Apart from above you would need file dependencies2.scad, a library I have > written , which is a much smaller version of dependencies.scad > Also attached revised trial.scad > > On Sun, 3 Mar 2024 at 22:36, azdle <azdle@azdle.net> wrote: > >> Yeah! That looks like pretty much exactly what I'm going for. >> >> Any chance you can share the scad file and the python too? >> >> On Sun, Mar 3 2024 at 10:14:47 PM +0530, Sanjeev Prabhakar >> <sprabhakar2006@gmail.com> wrote: >> > I do all the calculations in python and render results in openSCAD >> > and use native features of openSCAD like intersection, difference etc >> > to draw shapes. >> > and it is perfectly parametric in python >> > Is this the shape? >> > >> > >> >> >>
JB
Jordan Brown
Sun, Mar 3, 2024 8:07 PM

Is the final thing supposed to be cylindrical?

If so, maybe make it oversized and then intersect to make it curved.

Is the final thing supposed to be cylindrical? If so, maybe make it oversized and then intersect to make it curved.
RD
Revar Desmera
Mon, Mar 4, 2024 2:55 AM

Here's my take on this in library-free OpenSCAD:

wall = 3;
cells_around = 16;
cells_down = 3;
down_ang = 50;
body_od = 150;
body_id = 75;

circ = body_od * PI;
cell_side = circ / cells_around / sqrt(2);
cell_l = (cells_down + 1) * cell_side;
cell_h = circ/cells_around;

module xflip_copy() {children(); mirror([1,0,0]) children();}
module zxskew(a) {multmatrix([[1,0,0,0],[0,1,0,0],[tan(a),0,1,0],[0,0,0,1]]) children();}

for (zi = [0:1:cells_down-2]) translate([0,0,cell_hzi]) {
xflip_copy() {
for (ri = [0:1:cells_around-1]) rotate(360
ri/cells_around) {
difference() {
zxskew(-down_ang) {
linear_extrude(height=cell_h, center=true, twist=-360/cells_around, convexity=4) {
rotate(-180/cells_around) {
translate([body_od/4,0,0]) {
square([body_od/2,wall], center=true);
}
}
}
}
cylinder(d=body_id, h=10*cell_h, center=true);
}
}
}
}

  • Revar
Here's my take on this in library-free OpenSCAD: wall = 3; cells_around = 16; cells_down = 3; down_ang = 50; body_od = 150; body_id = 75; circ = body_od * PI; cell_side = circ / cells_around / sqrt(2); cell_l = (cells_down + 1) * cell_side; cell_h = circ/cells_around; module xflip_copy() {children(); mirror([1,0,0]) children();} module zxskew(a) {multmatrix([[1,0,0,0],[0,1,0,0],[tan(a),0,1,0],[0,0,0,1]]) children();} for (zi = [0:1:cells_down-2]) translate([0,0,cell_h*zi]) { xflip_copy() { for (ri = [0:1:cells_around-1]) rotate(360*ri/cells_around) { difference() { zxskew(-down_ang) { linear_extrude(height=cell_h, center=true, twist=-360/cells_around, convexity=4) { rotate(-180/cells_around) { translate([body_od/4,0,0]) { square([body_od/2,wall], center=true); } } } } cylinder(d=body_id, h=10*cell_h, center=true); } } } }  - Revar