Use the following code to model an object like the one in the picture:
design1.ActiveViewport.DisplayMode = displayType.Shaded;
design1.Shaded.EdgeColorMethod = edgeColorMethodType.EntityColor;
design1.Shaded.EdgeThickness = 2;
// The geometry is symmetric, so we create only half of it and then we apply a mirror transformation.
// Creation of the curves
List<ICurve> lstFirst = new List<ICurve>();
lstFirst.Add(new Line(new Point3D(0, 400), new Point3D(700, 400)));
lstFirst.Add(new Arc(new Point3D(700, 300), lstFirst.Last().EndPoint, new Point3D(800, 300)));
lstFirst.Add(new Line(lstFirst.Last().EndPoint, new Point3D(800, -300)));
lstFirst.Add(new Arc(new Point3D(700, -300), lstFirst.Last().EndPoint, new Point3D(700, -400)));
lstFirst.Add(new Line(lstFirst.Last().EndPoint, new Point3D(0, -400)));
CompositeCurve cpsFirst = new CompositeCurve(lstFirst);
List<ICurve> lstSecond = new List<ICurve>();
lstSecond.Add(new Arc(Plane.YX, new Point2D(50, 50), 50, Math.PI / 4, Math.PI / 2));
lstSecond.Add(new Line(lstSecond.Last().EndPoint, new Point3D(100, -50)));
lstSecond.Add(new Arc(new Point3D(50, -50), lstSecond.Last().EndPoint, new Point3D(50, -100)));
lstSecond.Add(new Line(lstSecond.Last().EndPoint, new Point3D(-50, -100)));
lstSecond.Add(new Arc(Plane.YX, new Point2D(-50, -50), 50, Math.PI, Math.PI + Math.PI / 4));
CompositeCurve cpsSecond = new CompositeCurve(lstSecond);
cpsSecond.Rotate(3.141592 / 4, new Vector3D(0, 0, 1));
cpsSecond.Translate(new Vector3D(0, -130, 0));
Point3D[] pts1 = cpsFirst.GetPointsByLengthPerSegment(6);
Point3D[] pts2 = cpsSecond.GetPointsByLengthPerSegment(5);
Curve cv1 = Curve.LocalApproximation(pts1, 0.01, out Vector3D[] tangents1);
Curve cv2 = Curve.LocalApproximation(pts2, 0.01, out Vector3D[] tangents2);
// Creation of the surfaces starting from the curves
double h1 = 100;
double h2 = 200;
double r1 = 20;
double r2 = 15;
List<Surface> result = new List<Surface>();
List<Surface> surf1 = new List<Surface>();
List<Surface> surf2 = new List<Surface>();
foreach (ICurve curve in cpsFirst.CurveList)
{
surf1.AddRange(curve.ExtrudeAsSurface(new Vector3D(0, 0, h1 + 100)));
}
cv1.Translate(new Vector3D(0, 0, h1));
Curve cv3 = (Curve)cv1.Offset(-1, new Vector3D(0, 0, 1), false)[0];
cv2.Translate(new Vector3D(0, 0, h2));
surf2.Add(Surface.Loft(new ICurve[] { cv3, cv2 })[0]);
Surface surfTop = devDept.Eyeshot.Entities.Region.CreateRectangle(10000, 10000, true).ConvertToSurface();
Surface[] fillet1;
Surface.Fillet(new Surface[] { surfTop }, surf1, r1, 0.001, false, true, true, true, false, false, out fillet1);
Surface[] fillet2;
Surface.Fillet(surf1, surf2, r2, 0.001, false, true, true, true, true, false, out fillet2);
result.AddRange(fillet1);
result.AddRange(surf1);
result.AddRange(fillet2);
result.AddRange(surf2);
// mirror transformation
int halfCount = result.Count;
Transformation mirror = new Mirror(Plane.YZ);
for (int i = 0; i < halfCount; i++)
{
Surface clone = (Surface)result[i].Clone();
clone.TransformBy(mirror);
result.Add(clone);
}
design1.Entities.AddRange(result, Color.Red);
Comments
Please sign in to leave a comment.