Gym frame

Use the following code to model an object like the one in the picture:

 

model.DisplayMode = displayType.Shaded;
model.Shaded.EdgeColorMethod = edgeColorMethodType.EntityColor;
model.Shaded.EdgeThickness = 2;

model.Grid.Step = 10;

const double ellMajor = 10;
const double ellMinor = 6;

// wires layer
string trajectoryLayer = "Trajectory";
model.Layers.Add(trajectoryLayer, Color.DeepPink);

// edits default layer
model.Layers[0].Name = "Steel";
model.Layers[0].Color = Color.LightGray;

// first vertical straight pipe
Line l1 = new Line(120, 0, -20, 85.359, 0, 40);

model.Entities.Add(l1, trajectoryLayer);

Plane pl1 = new Plane(l1.StartPoint, Vector3D.Subtract(l1.EndPoint, l1.StartPoint));

Ellipse e1 = new Ellipse(pl1, l1.StartPoint, ellMinor, ellMajor);

Surface s1 = e1.ExtrudeAsSurface(l1)[0];

model.Entities.Add(s1, 0);

// first bend
Plane pl2 = new Plane(Point3D.Origin, Vector3D.AxisX, Vector3D.AxisZ);

Arc a1 = new Arc(pl2, new Point2D(68.0385, 30), 20, Math.PI / 6, Math.PI / 2);

model.Entities.Add(a1, trajectoryLayer);

Ellipse e2 = (Ellipse)e1.Clone();
e2.Reverse();
e2.Translate(Vector3D.Subtract(l1.EndPoint, l1.StartPoint));

Surface s2 = e2.RevolveAsSurface(0, Math.PI / 3, a1.Plane.AxisZ, new Point3D(68.0385, 0, 30))[0];

model.Entities.Add(s2);

// second straight pipe
Line l2 = new Line(68.0385, 0, 50, 32.2027, 0, 50);

model.Entities.Add(l2, trajectoryLayer);

Plane pl3 = new Plane(l2.StartPoint, Vector3D.AxisZ, Vector3D.AxisY);

Ellipse e3 = new Ellipse(pl3, l2.StartPoint, ellMinor, ellMajor);

Surface s3 = e3.ExtrudeAsSurface(l2)[0];

model.Entities.Add(s3);

// second bend
Arc a2 = new Arc(pl2, new Point2D(32.2027, 30), 20, Math.PI / 2, Utility.DegToRad(160));

model.Entities.Add(a2, trajectoryLayer);

Ellipse e4 = (Ellipse)e3.Clone();
e4.Reverse();
e4.Translate(Vector3D.Subtract(l2.EndPoint, l2.StartPoint));

Surface s4 = e4.RevolveAsSurface(0, Utility.DegToRad(70), a2.Plane.AxisZ, new Point3D(32.2027, 0, 30))[0];

model.Entities.Add(s4);

// last vertical straight pipe
Line l3 = new Line(13.4088, 0, 36.8404, 0, 0, 0);

model.Entities.Add(l3, trajectoryLayer);

Plane pl4 = new Plane(l3.StartPoint, Vector3D.Subtract(l3.EndPoint, l3.StartPoint));

Ellipse e5 = new Ellipse(pl4, l3.StartPoint, ellMinor, ellMajor);

Surface s5 = e5.ExtrudeAsSurface(l3)[0];

model.Entities.Add(s5);

// horizontal pipe
Plane pl5 = new Plane(Point3D.Origin, Vector3D.AxisX, Vector3D.AxisZ);

Circle c1 = new Circle(pl5, new Point3D(0, -35, 0), 7);
c1.Reverse();
Line l4 = new Line(0, -35, 0, 0, 35, 0);

model.Entities.Add(l4, trajectoryLayer);

Surface s6 = c1.ExtrudeAsSurface(l4)[0];

model.Entities.Add(s6);

// simultaneous trim
Surface.Trim(s5, s6, 0.01, true, false);

// planar closing surface
PlanarSurface s7 = Surface.CreatePlanar(new Plane(new Point3D(0,0,-7), Vector3D.AxisX, Vector3D.AxisY), new Point3D(80, -20), new Point3D(130, 20));
s7.ReverseU();
model.Entities.Add(s7);

// simultaneous trim
Surface.Trim(s1, s7, 0.01, false, true);

model.Entities.Regen();

// adds a layer
string rubberLayer = "Rubber";
model.Layers.Add(rubberLayer, Color.FromArgb(7, 7, 7));

// rubber cap
Line l5 = new Line(0, -25, -8, 0, -25, -7);
Line l6 = new Line(0, -35, -8, 0, -25, -8);
Arc a3 = new Arc(Plane.YZ, new Point3D(0, -35, -7), 1, Math.PI, 6 * Math.PI / 4);
Line l7 = new Line( 0, -36, 0, 0, -36, -7);

Entity[] profile = new Entity[] { l5, l6, a3, l7 };

model.Entities.AddRange(new Entity[] { l5, l6, a3, l7 }, trajectoryLayer);

foreach (ICurve curve in profile)
{
    Surface s = curve.RevolveAsSurface(0, Math.PI * 2, Vector3D.AxisY, Point3D.Origin)[0];
    model.Entities.Add(s, rubberLayer);
}

// Mirror (plane ZX)
Mirror m = new Mirror(Plane.ZX);

for (int i = model.Entities.Count - 1; i > model.Entities.Count - 8; i--)
{

    Entity dup = (Entity)model.Entities[i].Clone();
    dup.TransformBy(m);
    model.Entities.Add(dup, rubberLayer);
}

// rubber tip
Circle c2 = new Circle(new Point3D(112, 0, -8), 5);

PlanarSurface s8 = Surface.CreatePlanar(c2);
s8.ReverseU();
model.Entities.Add(s8, rubberLayer);

Surface s9 = c2.ExtrudeAsSurface(0, 0, 1)[0];

model.Entities.Add(s9, rubberLayer);

// turns off layer
model.Layers.TurnOff(trajectoryLayer); 
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.