I build shapes for turtle3d in turtle (2d)
Then I diffs some and preview shows empty.
I guess it not solid.
include <BOSL2/std.scad>
include <BOSL2/turtle3d.scad>
include <BOSL2/paths.scad>
module C1(angle,q, offset,ang){
//------------------------------------
yrot(angle)union(){
ushape=turtle(
["setdir",[0,-1],"ymove",3,"left","xmove",-18,"setdir",[-1,0],"arcleft",3,180,"xmove",18,"right","ymove",3]
);
ushape2=turtle(
["setdir",[0,-1],
"ymove",3,
"left",
"xmove",-11.2,
"setdir",[-1,0],
"arcleft",19,30,
"arcleft",0.53,120,
"arcleft",19,30,
"xmove",11.2,
"right","ymove",3]
);
echo (ushape2);
ushape3=resample_path(ushape2,20,closed = true);
ushape4= [[0, 0], [0, 3], [-11.2, 3], [-11.543, 2.9969], [-11.8859, 2.98761], [-12.2286, 2.97213], [-12.571, 2.95047], [-12.9129, 2.92263], [-13.2543, 2.88862], [-13.5949, 2.84845], [-13.9348, 2.80214], [-14.2739, 2.7497], [-14.6119, 2.69115], [-14.9488, 2.62651], [-15.2844, 2.55579], [-15.6188, 2.47903], [-15.9517, 2.39624], [-16.283, 2.30745], [-16.6127, 2.2127], [-16.9407, 2.11201], [-17.2667, 2.00541], [-17.5908, 1.89295], [-17.9128, 1.77465], [-18.2326, 1.65056], [-18.5501, 1.52071], [-18.8653, 1.38516], [-19.1779, 1.24393], [-19.4879, 1.09709], [-19.7952, 0.94467], [-20.0998, 0.786729], [-20.4014, 0.623315], [-20.7, 0.454483], [-20.894, 0.260489], [-20.965, -0.00451079], [-20.894, -0.269511], [-20.7, -0.463504], [-20.4014, -0.632337], [-20.0998, -0.79575], [-19.7952, -0.953692], [-19.4879, -1.10611], [-19.1779, -1.25295], [-18.8653, -1.39418], [-18.5501, -1.52973], [-18.2326, -1.65958], [-17.9128, -1.78367], [-17.5908, -1.90197], [-17.2667, -2.01443], [-16.9407, -2.12103], [-16.6127, -2.22172], [-16.283, -2.31647], [-15.9517, -2.40526], [-15.6188, -2.48805], [-15.2844, -2.56481], [-14.9488, -2.63553], [-14.6119, -2.70017], [-14.2739, -2.75873], [-13.9348, -2.81117], [-13.5949, -2.85748], [-13.2543, -2.89764], [-12.9129, -2.93165], [-12.571, -2.95949], [-12.2286, -2.98116], [-11.8859, -2.99664], [-11.543, -3.00592], [-11.2, -3.00902], [3.55271e-15, -3.00902], [3.55271e-15, -0.00902158]];
// fwd(20)stroke(ushape,width=.1,closed=true);
path1 = turtle3d([
["arc",40,"up", 23, "steps", 15, "grow",[1,1.5]],
["arc",60,"down", 20, "steps", 15,"grow",[1,1.1]],
["arc",60,"down", 20, "steps", 15,"shrink",[1,1.2]],
["arc",155,"up",17, "steps", 15,"shrink",[1,1.2]],
["move",45,"shrink",[1,1.1]]
],
state=move([0,0,0]),transforms=true);
//ushape1=square([9,7]);
ushape1=[[-18, -3],[-20,-1.5],[-20,1.5],[-18,3],[ 20, 3],[ 20, -3]];
// fwd(20)stroke(ushape1,width=.1,closed=true);
path2= turtle3d([
["arc",40,"up", 29, "steps", 15, "grow",[1,1.3]],
["move",6, "grow",[1,1.1]]
],
state=LEFT,transforms=true);
difference(){
union(){
xrot(90) cyl(d=8,h=13,$fn=6);
top_half(s=300)
union(){
down(12.5)left(20){
sweep(ushape4, path1,caps=true); //перед
sweep(ushape4, path2,caps=true); } //зад
right(125+1){cylinder(d=7.5,h=7);
%down(4.8) {cylinder(d=2.5,h=17);
cylinder(d=19.7,h=4.8);}}
left(17)cylinder(d=10,h=5);
yrot(5)down(10){left(36+12)scale([2.4,1,1])cylinder(d=12.8,h=21.7);
up(21.7)left(36+12)scale([2.4,1,0.5])sphere(d=12.8);}
up(7.8){hull()
{right(13.5)back(10)cylinder(d=7,h=6.2);
right(9)cube([9,0.1,6.2]);}
}
}
} //union
left(83)down(56)xrot(90)cyl(d=150,h=40);
right(125+1)cylinder(d=2.5,h=8);
right(9)fwd(20)cube([21.5,50,7.8]);
right(12)fwd(5)cube([9.5,3,11]);
xrot(90)cyl(d=2.5+0.3,h=22); //ось
up(7.8)right(13.5)back(10)cylinder(d=3,h=6.2);
left(17)down(0.2)cylinder(d=7,h=3);
} // diff
} //offset
} // C1
C1(0,1,0,0);
pics
Your model is ending up inside-out, and that's really messing up the
previewer.
If you look at it with View/Thrown Together, you can see that the main
body of the model is magenta... that's bad; it means that we're looking
at what is supposed to be the back side of the faces.
This problem derives from ushape4 being wound backwards. Reversing it,
e.g. via
ushape4 = reverse([....]);
solves most of your problems.
I don't know all of the rules for sweep, and in particular I don't know
how to know which way is "correct". In this particular case, you're
winding it counter-clockwise, and it needs to be clockwise, but I don't
know if that's different for other sweeps, e.g. a sweep in the opposite
direction.
Perhaps Adrian could chime in.
By the way, when you're asking for help with a model, it's good to
ensure that it is as small and simple as you can get it, and
well-formatted. That makes it a lot easier for a reviewer, and the
process may help you to find the problem on your own.
Here's a simplified version of your program that still demonstrates the
problem:
include <BOSL2/std.scad>
include <BOSL2/turtle3d.scad>
include <BOSL2/paths.scad>
ushape4= [[0, 0], [0, 3], [-11, 3], [-17, -2]];
path1 = turtle3d([[ "move", 10 ]],
state=move([0,0,0]),transforms=true
);
top_half() sweep(ushape4, path1,caps=true);
Yes! it works now. I am understanding more
Thank you!