Modeling Practice 160

CAD-3D-drawing-160.png

// Vertical diapason dimensions
double
    vHeight = 110,
    vHighHeight = 70,
    vSideWidth = 22,
    vPoleWidth = 18,
    vHoleWidth = 34;

// Horizontal diapason dimensions
double
    hHeight = 85,
    hHighHeight = 50,
    hSideWidth = 12,
    hPoleWidth = 18,
    hHoleWitdh = 18;

// Building one half of each diapason
devDept.Eyeshot.Entities.Region diapVerReg = devDept.Eyeshot.Entities.Region.CreatePolygon(Plane.XY, new Point2D[]{
    new Point2D(0,0),
    new Point2D(vPoleWidth / 2, 0),
    new Point2D(vPoleWidth / 2, - vHighHeight),
    new Point2D(vPoleWidth / 2 + vSideWidth, - vHighHeight),
    new Point2D(vPoleWidth / 2 + vSideWidth, - vHeight),
    new Point2D(0, - vHeight)
});

devDept.Eyeshot.Entities.Region diapHorReg = devDept.Eyeshot.Entities.Region.CreatePolygon(Plane.XY, new Point2D[]{
    new Point2D(0,0),
    new Point2D(hPoleWidth / 2, 0),
    new Point2D(hPoleWidth / 2, - hHighHeight),
    new Point2D(hPoleWidth / 2 + hSideWidth, - hHighHeight),
    new Point2D(hPoleWidth / 2 + hSideWidth, - hHeight),
    new Point2D(0, - hHeight)
});

// Positioning vertical diapason
diapVerReg.Rotate(Math.PI / 2, new Vector3D(1, 0, 0));

// Extruding
Brep diapVer = diapVerReg.ExtrudeAsBrep(new Interval(-25, 25)); // Extrude on both sides
diapVer.ExtrudeAdd(diapHorReg, new Interval(-18, 18));

// Build cylinders by extruding circles
devDept.Eyeshot.Entities.Region c1 = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.ZY, new Point2D(0,0), 25); // Main center circle
diapVer.ExtrudeAdd(c1, -hHoleWitdh / 2 - 15);

devDept.Eyeshot.Entities.Region c2 = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.ZY, new Point2D(0, -hHeight), 18); // Top aside circle
diapVer.ExtrudeAdd(c2, -23);

devDept.Eyeshot.Entities.Region c3 = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.ZY, new Point2D(-vHeight, -0), 28); // Bottom circle
diapVer.ExtrudeAdd(c3, -vHoleWidth / 2 - 18);

// Drill rectangular holes
devDept.Eyeshot.Entities.Region r1 = devDept.Eyeshot.Entities.Region.CreateRectangle(Plane.ZY, - 18, -hHeight + 18, 36, -50); // Top hole
diapVer.ExtrudeRemove(r1, - hHoleWitdh / 2);
            
devDept.Eyeshot.Entities.Region r2 = devDept.Eyeshot.Entities.Region.CreateRectangle(Plane.ZY, - vHighHeight - 12, -35, - 65, 70); // Bottom hole
diapVer.ExtrudeRemove(r2, - vHoleWidth / 2);

// Drill circular holes
devDept.Eyeshot.Entities.Region ch1 = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.ZY, new Point2D(0, 0), 12.5); // Main center circle hole
diapVer.ExtrudeRemove(ch1, - 100);

devDept.Eyeshot.Entities.Region ch2 = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.ZY, new Point2D(0, -hHeight), 7.5); // Top aside circle hole
diapVer.ExtrudeRemove(ch2, - 100);

devDept.Eyeshot.Entities.Region ch3 = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.ZY, new Point2D(-vHeight, 0), 16); // Top aside circle hole
ch3.Translate(new Vector3D(15, 0, 0));
diapVer.ExtrudeRemove(ch3, -50);

// Mirror
Mirror m = new Mirror(Plane.YZ);
Brep diapVerM = (Brep) diapVer.Clone();
diapVerM.TransformBy(m);
Brep fSol = Brep.Union(diapVerM, diapVer)[0]; // Final solid

// Set colors 
Color col1 = Color.DarkGray;
fSol.Faces[32].Color = col1;
fSol.Faces[30].Color = col1;
fSol.Faces[37].Color = col1;
fSol.Faces[17].Color = col1;
fSol.Faces[33].Color = col1;
fSol.Faces[21].Color = col1;
fSol.Faces[16].Color = col1;
fSol.Faces[14].Color = col1;
fSol.Faces[22].Color = col1;
fSol.Faces[2].Color = col1;

Color col2 = Color.WhiteSmoke;
fSol.Faces[29].Color = col2;
fSol.Faces[28].Color = col2;
fSol.Faces[36].Color = col2;
fSol.Faces[13].Color = col2;
fSol.Faces[20].Color = col2;
fSol.Faces[9].Color = col2;

// Add to entities
model1.Entities.Add(fSol, Color.FromArgb(193, 209, 13));

// Viewport setup
model1.ZoomFit();
model1.ActiveViewport.Grid.Visible = false; // Hide grid
model1.ActiveViewport.OriginSymbol.Visible = false; // Hide origin

Don't forget to add the following using statements:

using devDept.Eyeshot.Entities;
using devDept.Geometry;
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.