Modeling Practice Drawings 42

2022-05-30_10-03-17.png

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();

        headRegion.ContourList.Add(circle);
    }
}

var headBrep = headRegion.ExtrudeAsBrep(50);

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

        headBrep.ExtrudeRemove(tempCircle, 10);
    }
}

gElbow = (GBrep) headBrep.Clone();

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

var cyl = circReg.ExtrudeAsBrep(100);

cyl.ExtrudeAdd(circReg, 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));
cyl.ExtrudeAdd(circReg3, 100);

//adding the cylinder to the elbow
gElbow.Add(cyl);

//creating the last part of the elbow by cloning headBrep and rotating it according to the model
var tailBrep = (GBrep) headBrep.Clone();

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

gElbow.Add(tailBrep);

//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];

//adding fillets and chamfers
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);

design1.Entities.Add(new Brep(gElbow), Color.DimGray);

2022-06-06_13-45-08.png image.png

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.