# Modeling Practice Drawings 42

``````GBrep gElbow;

//creating the first part of the elbow
var headRegion = GRegion.CreateRoundedRectangle(360, 360, 10);

for (int i = 0; i < 2; i++) {
for (int k = 0; k < 2; k++) {
Func<int, int> calcPos = (int pos) => (pos > 0) ? (pos * (360 - 50)) : (pos + 50);

var circle = new GCircle(calcPos(i), calcPos(k), 0, 15);
circle.Reverse();

}
}

if (c is GCircle circle) {
var tempCircle = new GRegion(new GCircle(circle.Center, 30));

}
}

//creating the cylinder
var circReg = GRegion.CreateCircle(180, 180, 145);
circReg.Translate(0, 0, 50);

var cyl = circReg.ExtrudeAsBrep(100);

var circReg2 = (GRegion) circReg.Clone();

circReg2.Translate(0, 0, 100);

cyl.RevolveAdd(circReg2, Math.PI / 2, Vector3D.AxisY, new Point3D(440, 0, 150));

var circReg3 = (GRegion) circReg2.Clone();

circReg3.Rotate(Math.PI / 2, Vector3D.AxisY, new Point3D(440, 0, 150));

//adding the cylinder to the elbow

//creating the last part of the elbow by cloning headBrep and rotating it according to the model

tailBrep.Rotate(Math.PI / 2, Vector3D.AxisY, new Point3D(590, 0, 0));
tailBrep.Rotate(Math.PI, Vector3D.AxisY, new Point3D(590, 180, 410));

//creating the cavity
var cavityRail = new GCompositeCurve(
new GLine(Plane.XZ, 180, 0, 180, 150),
new GArc(Plane.XZ, new Point2D(440, 150), 260, Math.PI, Math.PI / 2),
new GLine(Plane.XZ, 440, 410, 590, 410)
);

var cavity = GRegion.CreateCircle(180, 180, 105).SweepAsBrep(cavityRail, 0.01);

gElbow = GBrep.Difference(gElbow, cavity)[0];

gElbow.Fillet(gElbow.GetEdgeIndex(new Point3D(180 - 145, 180, 50)), 10);
gElbow.Fillet(gElbow.GetEdgeIndex(new Point3D(540, 180 - 145, 410)), 10);

gElbow.Chamfer(gElbow.GetEdgeIndex(new Point3D(590, 180 - 105, 410)), 10);
gElbow.Chamfer(gElbow.GetEdgeIndex(new Point3D(180, 180 - 105, 0)), 10);