//Main circle extrusion
devDept.Eyeshot.Entities.Region cr1 = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.XY, 0, 0, 22.5);
//Main circle extrude remove
devDept.Eyeshot.Entities.Region cr2 = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.XY, 0, 0, 10);
//Main circle extrude remove rectangle
devDept.Eyeshot.Entities.Region rt1 = devDept.Eyeshot.Entities.Region.CreateRectangle(Plane.XY, -7, -25, 14, 50);
//Left external circle diameter 30
devDept.Eyeshot.Entities.Region cr3 = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.XY, -60, 0, 15);
//Left external circle extrude remove diameter 12
devDept.Eyeshot.Entities.Region cr4 = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.XY, -60, 0, 6);
//Left external circle rectangular slot
devDept.Eyeshot.Entities.Region rt2 = devDept.Eyeshot.Entities.Region.CreateRectangle(Plane.XY, -50, -15, -50, 30);
//Lower left rectangle
devDept.Eyeshot.Entities.Region rt3 = devDept.Eyeshot.Entities.Region.CreateRectangle(Plane.XY, -60, -15, 60, 30);
//Upper left L shape rectangle
devDept.Eyeshot.Entities.Region rt4 = devDept.Eyeshot.Entities.Region.CreateRectangle(Plane.XY, -60, -15, 18, 30);
//Upper slot of radius 6 to extrude remove on right curved triangle
devDept.Eyeshot.Entities.Region slot = devDept.Eyeshot.Entities.Region.CreateSlot(40, 0, 15, 6);
//Upper, outer slot of radius 9
devDept.Eyeshot.Entities.Region slotExt = devDept.Eyeshot.Entities.Region.CreateSlot(40, 0, 15, 9);
//Left trapezoid
devDept.Eyeshot.Entities.Region tr1 = devDept.Eyeshot.Entities.Region.CreatePolygon(Plane.XZ, new Point2D[]
{
new Point2D(-21.5, 15),
new Point2D(-21.5, 80),
new Point2D(-22.5, 80),
new Point2D(-42, 35),
new Point2D(-42, 15)
});
//Right triangle
devDept.Eyeshot.Entities.Region tr2 = devDept.Eyeshot.Entities.Region.CreatePolygon(Plane.XZ, new Point2D[]
{
new Point2D(21.5, 15),
new Point2D(21.5, 80),
new Point2D(22.5, 80),
new Point2D(55, 15),
});
//Inner circle of diameter 36 inside the main circle
devDept.Eyeshot.Entities.Region innerCr = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.XY, 0, 0, 18);
innerCr.Translate(0, 0, 20);
//45 deg rotated Plane to draw lateral hole of diameter 10 in the main circle
Plane YZR = Plane.YZ;
YZR.Rotate(devDept.Geometry.Utility.DegToRad(-45), Vector3D.AxisZ);
devDept.Eyeshot.Entities.Region crSmall = devDept.Eyeshot.Entities.Region.CreateCircle(YZR, 0, 40, 5);
//Lower slot of radius 6 to extrude remove on right curved triangle
devDept.Eyeshot.Entities.Region slot2 = (Region)slot.Clone();
//Lower, outer slot of radius 9
devDept.Eyeshot.Entities.Region slot2Ext = (Region)slotExt.Clone();
//Slots rotations and translations
slot.Rotate(devDept.Geometry.Utility.DegToRad(45), Vector3D.AxisZ, Point3D.Origin);
slot2.Rotate(devDept.Geometry.Utility.DegToRad(-45), Vector3D.AxisZ, Point3D.Origin);
slotExt.Rotate(devDept.Geometry.Utility.DegToRad(45), Vector3D.AxisZ, Point3D.Origin);
slot2Ext.Rotate(devDept.Geometry.Utility.DegToRad(-45), Vector3D.AxisZ, Point3D.Origin);
slotExt.Translate(0, 0, 10);
slot2Ext.Translate(0, 0, 10);
//Lines and arcs to create right curved triangle
Line a = new Line(40, 40, 40, -40);
Line b = new Line(40, -40, 0, 0);
Line c = new Line(0, 0, 40, 40);
Arc ba;
Arc ca;
Curve.Fillet(c, a, 1, false, false, true, true, out ca);
Curve.Fillet(b, a, 1, true, true, true, true, out ba);
//Right curved triangle
CompositeCurve compc1 = new CompositeCurve(
a,
b,
c,
ca,
ba);
rt1.Translate(0, 0, 70);
rt2.Translate(0, 0, 15);
rt4.Translate(0, 0, 15);
compc1.Translate(0, 0, 15);
ICurve[] compc1Off = compc1.Offset(15, false);
devDept.Eyeshot.Entities.Region abReg = new Region(compc1Off);
Brep ext1 = cr1.ExtrudeAsBrep(80);
Interval inter = new Interval(-5, 5);
//Add operations
ext1.ExtrudeAdd(rt3, 15);
ext1.ExtrudeAdd(cr3, 35);
ext1.ExtrudeAdd(rt4, 20);
ext1.ExtrudeAdd(tr1, inter);
ext1.ExtrudeAdd(tr2, inter);
ext1.ExtrudeAdd(abReg, 15);
//Remove operations
ext1.ExtrudeRemove(cr2, 80);
ext1.ExtrudeRemove(cr4, 35);
ext1.ExtrudeRemove(rt1, 10);
ext1.ExtrudeRemove(rt2, 10);
ext1.ExtrudeRemove(slot, 20);
ext1.ExtrudeRemove(slotExt, 5);
ext1.ExtrudeRemove(slot2, 20);
ext1.ExtrudeRemove(slot2Ext, 5);
ext1.ExtrudeRemove(innerCr, 40);
ext1.ExtrudeRemove(crSmall, 30);
//Semi transparent mode for the Brep to see every face index
//design1.Entities.Add(ext1, System.Drawing.Color.FromArgb(120, System.Drawing.Color.RoyalBlue));
//PrintFaceIndex(ext1);
int[] whiteFaces = {7, 9, 10, 15, 16, 22, 23, 24, 25, 26, 27, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 56, 58, 59, 60, 61};
//Set all specified faces in whiteFaces to color white
foreach (var item in whiteFaces)
ext1.Faces[item].Color = System.Drawing.Color.White;
design1.Entities.Add(ext1, System.Drawing.Color.RoyalBlue);
Utility method to enumerate the Brep faces:
protected void PrintFaceIndex(Brep ext)
{
for (int i = 0; i < ext.Faces.Length; i++)
{
var face = ext.Faces[i];
Surface surface = face.Parametric[0];
Point3D ptParametric = surface.Trimming.ContourList[0].GetIndividualCurves()[0].StartPoint;
Vector3D tan3D = ((TrimCurve)surface.Trimming.ContourList[0].GetIndividualCurves()[0]).Edge.StartTangent;
Point3D pt = surface.PointAt(ptParametric.X, ptParametric.Y);
Vector3D vc = surface.NormalAt(ptParametric.X, ptParametric.Y);
Plane pln = new Plane(pt, tan3D, Vector3D.Cross(vc, tan3D));
Text tx = new Text(pln, new Point2D(1, 1), i.ToString(), 2);
design1.Entities.Add(tx);
}
}
Comments
Please sign in to leave a comment.