Exercise part for tangents #99
Replies: 2 comments
-
A more complicated example of a part that requires tangent constraints is the exercise part of SolidWorks ModelMania 2010 that is often referenced in CAD tutorials. I created my own version as shown below: Here is the code used to create this part. // CascadeStudio Code to create a forked lever
// inspired by ModelMania shape 2010 and
// exercise created by JokoEngineering
let radius_1 = 30;
let radius_2 = 10;
let distance = 120;
let wall_thickness = 5;
let lever_height = 50;
let fillet_cutout = 5;
let fillet_outer = 1;
let fillet_arms = 5;
let depth = 55;
let chamfer = 1;
let t1 = 8;
let t2 = 10;
let t3 = 2;
let sep = 30;
function Lever(radius1, radius2, distance, leverheight, wall_thickness)
{
let sinus_angle = (radius1 - radius2) / distance
let angle = Math.asin(sinus_angle);
// points of outer contour of the lever
let p1 = [radius1 * Math.sin(angle), radius1 * Math.cos(angle)];
let p2 = [distance + radius2 * Math.sin(angle), radius2 * Math.cos(angle)];
let p3 = [distance + radius2, 0];
let p4 = [distance + radius2 * Math.sin(angle), - radius2 * Math.cos(angle)];
let p5 = [radius1 * Math.sin(angle), - radius1 * Math.cos(angle)];
let p6 = [- radius1, 0 ];
let sketchLever = new Sketch(p1).
LineTo(p2).
ArcTo(p3,p4).
LineTo(p5).
ArcTo(p6,p1).
End(false).Face(true);
let leverbody = Extrude(sketchLever,[0,0,leverheight]);
let big_hole = Cylinder((radius1-wall_thickness), 2* (leverheight + 10), true);
let small_hole = Translate([distance, 0,0 ], Cylinder((radius2-wall_thickness), 2* (leverheight + 10), true));
let lever = Difference(leverbody,[big_hole, small_hole]);
return lever
}
function Cutout(radius1, radius2, distance, leverheight, wall_thickness,depth)
{
// points of outer contour of the lever
let sinus_angle = (radius1 - radius2) / distance
let angle = Math.asin(sinus_angle);
distance = distance + 2*wall_thickness;
let c1 = [radius1 * Math.sin(angle), radius1 * Math.cos(angle)];
let c2 = [distance + radius2 * Math.sin(angle), radius2 * Math.cos(angle)];
let c3 = [distance - radius2 , 0];
let c4 = [distance + radius2 * Math.sin(angle), - radius2 * Math.cos(angle)];
let c5 = [radius1 * Math.sin(angle), - radius1 * Math.cos(angle)];
let c6 = [radius1, 0 ];
let cutout = new Sketch(c1).
LineTo(c2).
ArcTo(c3,c4).
LineTo(c5).
ArcTo(c6,c1).
End(false).Face(true);
cutoutBody = Extrude(cutout,[0,0,leverheight+4*wall_thickness]);
cutoutBody = Translate([-wall_thickness,0,leverheight-wall_thickness-depth],cutoutBody);
cutoutBody = Offset(cutoutBody,-wall_thickness);
return cutoutBody;
}
function RoundAll(shape,fillet)
{
let shrunk_version = Offset(shape,-fillet)
let grown_version = Offset(shrunk_version, fillet)
return grown_version
}
function SideView(radius1,radius2,distance,sep,t1,t2,t3)
{
// sketch upper half
let p1 = [-radius1-t3,sep/2];
let p2 = [-radius1-t3,sep/2+t1];
let p3 = [radius1+t3,sep/2+t1];
let p4 = [distance-radius2-t3,t2/2];
let p5 = [distance+radius2+t3,t2/2];
let p6 = [distance+radius2+t3,t2/2-t1];
let p7 = [distance-radius2-t3,t2/2-t1];
let p8 = [radius1+t3,sep/2];
let p9 = [-radius1-t3,sep/2];
let halfUpper = new Sketch(p1)
.LineTo(p2)
.LineTo(p3)
.LineTo(p4)
.LineTo(p5)
.LineTo(p6)
.LineTo(p7)
.LineTo(p8)
.LineTo(p9)
.End(false)
.Face(true);
return halfUpper
}
// Rollback stack
let lever = Lever(radius_1,radius_2,distance,lever_height,wall_thickness);
let cutoutShape = Cutout(radius_1, radius_2, distance, lever_height, wall_thickness,depth);
cutoutShape1 = RoundAll(cutoutShape,fillet_cutout)
lever = Difference(lever,[cutoutShape1]);
let sideviewUpper = SideView(radius_1,radius_2,distance,sep,t1,t2,t3);
sideviewUpper = Translate([0,0,-radius_1],Extrude(sideviewUpper,[0,0,radius_1*2]));
sideviewLower = Rotate([1,0,0],180,sideviewUpper,true);
let sideviewComplete = Union([sideviewUpper,sideviewLower],false,0.1,false);
sideviewComplete = FilletEdges(sideviewComplete,fillet_cutout,[22]);
sideviewComplete = Rotate([1,0,0],90,sideviewComplete);
sideviewComplete = Translate([0,0,sep/2+t1],sideviewComplete);
let fork = Intersection([lever,sideviewComplete]);
fork = FilletEdges(fork,fillet_arms,[69,71,45,48,36,40,19,15,31,25,55],false);
fork = FilletEdges(fork,fillet_arms,[83],false);
fork = FilletEdges(fork,fillet_outer,[19,12,23],false);
fork = ChamferEdges(fork,chamfer,[35,209,219,224],false); The dimensions are shown in the following sketch. Note that the numbering used for the points in the side view was changed, as I had difficulty calculating the coordinates of point 12 as shown in the sketch. I therefore changed my approach and modelled one half of the shape, mirrored it and then joined them with a boolean Union. This also had its drawbacks, as the Union function required a lot of tweaking to make it work. Also it should be noted that it is not possible to tweak all variables without breaking the model. The fillets have a large impact on the number of edges that are created. Therefore the numbering of the edges can change with large changes of the fillet radius. |
Beta Was this translation helpful? Give feedback.
-
Here is an adapted version of the model of the forked lever. I changed the following features:
// CascadeStudio Code to create a forked lever
// inspired by ModelMania shape 2010 and
// exercise created by JokoEngineering
let t1 = 8;
let t2 = 10;
let t3 = 5;
let sep = 40 ;
let radius_1 = 30;
let radius_2 = 12;
let distance = 120;
let wall_thickness = 5;
let lever_height = sep + (4*t1);
let fillet_cutout = 5;
let fillet_outer = 1;
let fillet_arms = 30;
let depth = lever_height + fillet_cutout;
let chamfer = 1;
let angle = Math.atan((sep/2+t1-t2/2)/(distance - radius_1 - radius_2 - 2*t3))*180/Math.PI;
function Polar(currentPoint,distance,angleDegToX)
{
let newPoint = [];
angleRad = angleDegToX * Math.PI/180;
newPoint[0] = currentPoint[0] + distance * Math.cos(angleRad);
newPoint[1] = currentPoint[1] + distance * Math.sin(angleRad);
return newPoint
}
function PolarX(currentPoint,xdistance,angleDegToX)
{
let newPoint = [];
let angleRad = angleDegToX * Math.PI/180;
newPoint[0] = currentPoint[0] + xdistance;
newPoint[1] = currentPoint[1] + xdistance * Math.tan(angleRad);
return newPoint
}
function PolarY(currentPoint,ydistance,angleDegToX)
{
let newPoint = [];
let angleRad = angleDegToX * Math.PI/180;
newPoint[0] = currentPoint[0] + ydistance/Math.tan(angleRad);
newPoint[1] = currentPoint[1] + ydistance;
return newPoint
}
function Lever(radius1, radius2, distance, leverheight, wall_thickness)
{
let sinus_angle = (radius1 - radius2) / distance
let angle = Math.asin(sinus_angle);
// points of outer contour of the lever
let p1 = [radius1 * Math.sin(angle), radius1 * Math.cos(angle)];
let p2 = [distance + radius2 * Math.sin(angle), radius2 * Math.cos(angle)];
let p3 = [distance + radius2, 0];
let p4 = [distance + radius2 * Math.sin(angle), - radius2 * Math.cos(angle)];
let p5 = [radius1 * Math.sin(angle), - radius1 * Math.cos(angle)];
let p6 = [- radius1, 0 ];
let sketchLever = new Sketch(p1).
LineTo(p2).
ArcTo(p3,p4).
LineTo(p5).
ArcTo(p6,p1).
End(false).Face(true);
let leverbody = Extrude(sketchLever,[0,0,leverheight]);
let big_hole = Cylinder((radius1-wall_thickness), 2* (leverheight + 10), true);
let small_hole = Translate([distance, 0,0 ], Cylinder((radius2-wall_thickness), 2* (leverheight + 10), true));
let lever = Difference(leverbody,[big_hole, small_hole]);
return lever
}
function Cutout(radius1, radius2, distance, leverheight, wall_thickness,depth)
{
// points of outer contour of the lever
let sinus_angle = (radius1 - radius2) / distance
let angle = Math.asin(sinus_angle);
distance = distance + 2*wall_thickness;
let c1 = [radius1 * Math.sin(angle), radius1 * Math.cos(angle)];
let c2 = [distance + radius2 * Math.sin(angle), radius2 * Math.cos(angle)];
let c3 = [distance - radius2 , 0];
let c4 = [distance + radius2 * Math.sin(angle), - radius2 * Math.cos(angle)];
let c5 = [radius1 * Math.sin(angle), - radius1 * Math.cos(angle)];
let c6 = [radius1, 0 ];
let cutout = new Sketch(c1).
LineTo(c2).
ArcTo(c3,c4).
LineTo(c5).
ArcTo(c6,c1).
End(false).Face(true);
let cutoutBody = Extrude(cutout,[0,0,leverheight+4*wall_thickness]);
cutoutBody = Translate([-wall_thickness,0,leverheight-wall_thickness-depth],cutoutBody);
cutoutBody = Offset(cutoutBody,-wall_thickness);
return cutoutBody;
}
function RoundAll(shape,fillet)
{
let shrunk_version = Offset(shape,-fillet)
let grown_version = Offset(shrunk_version, fillet)
return grown_version
}
function SideView(radius1,radius2,distance,sep,t1,t2,t3)
{
// sketch upper half
let p1 = [-radius1-t3,sep/2];
let p2 = [-radius1-t3,sep/2+t1];
let p3 = [radius1+t3,sep/2+t1];
let p4 = [distance-radius2-t3,t2/2];
let p5 = [distance+radius2+t3,t2/2];
let p6 = [distance+radius2+t3,-t2/2];
let p7 = [distance-radius2-t3,-t2/2];
let p8 = [radius1+t3,-sep/2-t1];
let p9 = [-radius1-t3,-sep/2-t1];
let p10 = [-radius1-t3,-sep/2];
let p11 = [radius1+t3,-sep/2];
let p12 = PolarY(p11,sep/2,angle);
let p13 = [radius1+t3,sep/2];
let p14 = [-radius1-t3,sep/2];
let halfUpper = new Sketch(p1)
.LineTo(p2)
.LineTo(p3).Fillet(fillet_arms)
.LineTo(p4).Fillet(fillet_arms)
.LineTo(p5)
.LineTo(p6)
.LineTo(p7).Fillet(fillet_arms)
.LineTo(p8).Fillet(fillet_arms)
.LineTo(p9)
.LineTo(p10)
.LineTo(p11).Fillet(fillet_arms)
.LineTo(p12).Fillet(fillet_cutout)
.LineTo(p13).Fillet(fillet_arms)
.LineTo(p14)
.End(false)
.Face(true);
return halfUpper
}
// Rollback stack
let lever = Lever(radius_1,radius_2,distance,lever_height,wall_thickness);
let cutoutShape = Cutout(radius_1, radius_2, distance, lever_height, wall_thickness,depth);
let cutoutShape1 = RoundAll(cutoutShape,fillet_cutout)
lever = Difference(lever,[cutoutShape1]);
let sideview = SideView(radius_1,radius_2,distance,sep,t1,t2,t3);
sideview = Translate([0,0,-radius_1],Extrude(sideview,[0,0,radius_1*2]));
sideview = Rotate([1,0,0],90,sideview);
sideview = Translate([0,0,sep/2+t1],sideview);
let fork = Intersection([lever,sideview]);
fork = FilletEdges(fork,fillet_outer,[105,100,97],false);
fork = ChamferEdges(fork,chamfer,[132,150,143,100,123,93],false); |
Beta Was this translation helpful? Give feedback.
-
I prepared another part as an exercise to model tangent lines in sketches:
Beta Was this translation helpful? Give feedback.
All reactions