Swing Arm

Swing Arm

swingarm.jpg

Circle c1 = new Circle(Plane.XY, new Point3D(0, 0, 0), 25.0);
Circle c2 = new Circle(Plane.XY, new Point3D(100, 0, 0), 12.0);
Circle c1_inner = new Circle(Plane.XY, c1.Center, 18.0);
Circle c2_inner = new Circle(Plane.XY, c2.Center, 6.0);
Circle c3_inner = new Circle(Plane.XY, new Point3D(c2.Center.X - c2.Radius - 8.0, c2.Center.Y, c2.Center.Z), 6.0);

Line[] tangents = UtilityEx.GetLinesTangentToTwoCircles(c1, c2);
Arc a1 = new Arc(Plane.XY, c1.Center, c1.Radius, tangents[0].StartPoint, tangents[1].StartPoint, false);
Arc a2 = new Arc(Plane.XY, c2.Center, c2.Radius, tangents[1].EndPoint, tangents[0].EndPoint, false);

CompositeCurve cc = new CompositeCurve(new ICurve[] { a1, tangents[0], a2, tangents[1] }, true);
Region reg1 = new Region(cc);

// Circle holes
reg1 = devDept.Eyeshot.Entities.Region.Difference(reg1, new Region(c1_inner))[0];
reg1 = devDept.Eyeshot.Entities.Region.Difference(reg1, new Region(c2_inner))[0];
devDept.Eyeshot.Entities.Region rRect = devDept.Eyeshot.Entities.Region.CreateRectangle(-5, 0, 10, 22);
rRect.Rotate(-Math.PI / 4, Vector3D.AxisZ, Point3D.Origin);
reg1 = devDept.Eyeshot.Entities.Region.Difference(reg1, rRect)[0];

// Central hole
Circle c3 = new Circle(Point3D.Origin, 26);
tangents = UtilityEx.GetLinesTangentToTwoCircles(c1_inner, c3_inner);
Curve.Fillet(tangents[0], tangents[1], c3_inner.Radius, true, false, true, true, out Arc f1_inner);
Arc a3 = new Arc(Plane.XY, c3.Center, c3.Radius, c3.IntersectWith(tangents[0])[0], c3.IntersectWith(tangents[1])[0], true);
Curve.Fillet(tangents[0], a3, 5, true, true, true, true, out Arc f2_inner);
Curve.Fillet(tangents[1], a3, 5, false, true, true, true, out Arc f3_inner);

CompositeCurve ccHole = new CompositeCurve(new ICurve[] { a3, f3_inner, tangents[1], f1_inner, tangents[0], f2_inner });
reg1 = devDept.Eyeshot.Entities.Region.Difference(reg1, new Region(ccHole))[0];

// Main profile
Brep mainBody = reg1.ExtrudeAsBrep(new Interval(-40.0, 40.0));

// Cutting shape
Line ln1 = new Line(Plane.XZ, -32.5, 2, -32.5, -7);
Line ln2 = new Line(Plane.XZ, -32.5, -7, 35, -7);
Line ln3 = new Line(Plane.XZ, 35, -7, 75, -28);
Line ln4 = new Line(Plane.XZ, 75, -28, 118, -28);
Line ln5 = new Line(Plane.XZ, 118, -28, 118, -20);
Line ln6 = new Line(Plane.XZ, 118, -20, 75, -20);

Line ln7 = (Line)ln3.Offset(8, Vector3D.AxisY);
ln7.Scale(ln7.MidPoint, 1.2);

Curve.Fillet(ln2, ln3, 20.0, false, false, true, true, out Arc f1);
Curve.Fillet(ln3, ln4, 20.0, false, false, true, true, out Arc f2);
Curve.Fillet(ln6, ln7, 10.0, true, false, true, true, out Arc f3);

Mirror mirror = new Mirror(Plane.XY);

ICurve[] curveArray = new ICurve[] {ln1, ln2, ln3, ln4, ln5, ln6, ln7, f1, f2, f3};
ICurve[] curveArrayCopy = new ICurve[curveArray.Length];

for (int i = 0; i < curveArray.Length; i++)
{
    curveArrayCopy[i] = (ICurve)((Entity)curveArray[i]).Clone();
    ((Entity)curveArrayCopy[i]).TransformBy(mirror);
}

Curve.Fillet(ln7, curveArrayCopy[6], 10, false, true, true, true, out Arc f4);

List<ICurve> contour = new List<ICurve>(curveArray.Take(7));
contour.AddRange(curveArrayCopy);
contour.AddRange(new ICurve[] { f1,f2,f3,f4 });

CompositeCurve ccCut = new CompositeCurve(contour);

Region regCut = devDept.Eyeshot.Entities.Region.Difference(devDept.Eyeshot.Entities.Region.CreateRectangle(Plane.XZ, -35, -50, 160, 100), new Region(ccCut))[0];

mainBody.ExtrudeRemove(regCut, new Interval(-100, 100));

model1.Entities.Add(mainBody, Color.Coral);
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.