

I created a curve using linear_extrude of a circle, with the twist parameter and the resulting extrusion twists around an invisible cylinder. What I am looking to do is have the extrusion twist around an elliptical cylinder. I could scale after the linear_extrude, and while that does make the hole elliptical, it also stretches the extrusions, which I do not want.
As you can see here, the left shape extrudes around a cylinder  on the right after using scale the hole becomes elliptical cylinder but the extrusions are stretched as well.
What is the best way to accomplish this?


a = 3;
b = 2;
scale([a,b,1]) linear_extrude(40, twist=360) translate([2*a,0]) scale([1/a,1/b]) circle(5);


That doesn't seem to work. Try changing a = 4 and b = 1:
a = 4;
b = 1;
scale([a,b,1]) linear_extrude(40, twist=360) translate([2*a,0]) scale([1/a,1/b]) circle(5);
The extrusion is not circular.


CONTENTS DELETED
The author has deleted this message.


From the beginning, you were asking for a translational sweeping. Here you have it:
translational_sweep(elliptical_path(40,10,40,360,$fa=5)) circle(5);
module translational_sweep(path) {
dz = h/(len(path)1);
for(i=[0:len(path)2]){
hull(){
translate(path[i])
linear_extrude(0.001) children();
translate(path[i+1])
linear_extrude(0.001) children();
}
}
}
function elliptical_path(a,b,h,ang) =
[ for(x=[0:$fa:ang]) [a*cos(x), b*sin(x), h*x/ang] ];


The module translational_sweep requires that the section be convex. The following version accepts closed paths and nonconvex sections. It does not use hull() and minkowski is needed just for horizontal segments in the path.
translational_sweep2(path(), closed=true) star();
module translational_sweep2(path, closed=false) {
p = closed ? concat( path, [ path[0] ]) : path;
for(i=[0:len(p)2]){
if( p[i+1][2]p[i][2] > 0 ) {
translate(p[i])
slice(p[i], p[i+1]) children();
}
else if( p[i+1][2]p[i][2] < 0 ) {
translate(p[i+1])
slice(p[i+1], p[i]) children();
}
else {
minkowski(){
linear_extrude(0.0001) children();
hull() {
translate(p[i]) cube(0.0001);
translate(p[i+1]) cube(0.0001);
}
}
}
}
}
function path() =
concat([ for(x=[0:5:180]) [40*cos(x), 40*sin(x), 100*x/360] ],
[ for(x=[180:5:0]) [40*cos(x), 40*sin(x), 100*x/360] ] ) ;
module star() {
scale([3,1]) rotate(45) square(5,center=true);
scale([1,3]) rotate(45) square(5,center=true); }
module slice(a,b) {
multmatrix(shear([(b[0]a[0])/(b[2]a[2]), (b[1]a[1])/(b[2]a[2])]))
linear_extrude(b[2]a[2]) children();
}
function shear(d=[0,0])=
[ [1,0,d[0],0], [0,1,d[1],0],[0,0,1,0],[0,0,0,1] ];

