design1.Units = linearUnitsType.Inches;
Plane right = Plane.YZ;
Plane pln1 = (Plane)right.Clone();
pln1.Rotate(Utility.DegToRad(40), Vector3D.AxisY);
Plane pln2 = (Plane)right.Clone();
pln2.Rotate(Utility.DegToRad(25), Vector3D.AxisY);
Plane pln3 = pln2.Offset(-12.5);
Plane pln4 = (Plane)right.Clone();
pln4.Rotate(Utility.DegToRad(-30), Vector3D.AxisY);
Plane pln5 = pln1.Offset(25.4);
Plane pln6 = (Plane)right.Clone();
pln6.Rotate(Utility.DegToRad(-34), Vector3D.AxisY);
Plane pln7 = pln6.Offset(14);
Circle sketch3 = new Circle(right, new Point2D(0,99),19);
sketch3.Rotate(Utility.DegToRad(-90), sketch3.Plane.AxisZ, sketch3.Plane.Origin);
Circle sketch4 = new Circle(pln3, new Point2D(0,89),23);
sketch4.Rotate(Utility.DegToRad(-90), sketch4.Plane.AxisZ, sketch4.Plane.Origin);
Ellipse sketch5 = new Ellipse(pln4, new Point2D(0,152.5),51,25.5);
sketch5.Rotate(Utility.DegToRad(-90), sketch5.Plane.AxisZ, sketch5.Plane.Origin);
Circle sketch6 = new Circle(pln5, new Point2D(0, 94), 7.6);
sketch6.Rotate(Utility.DegToRad(-90), sketch6.Plane.AxisZ, sketch6.Plane.Origin);
Brep loft1 = Brep.Loft(new ICurve[] { sketch6, sketch4, sketch3, sketch5 }, 2);
devDept.Eyeshot.Entities.Region cr = devDept.Eyeshot.Entities.Region.CreateCircle(right, new Point2D(0, 63.5), 71);
devDept.Eyeshot.Entities.Region rr = devDept.Eyeshot.Entities.Region.CreateRectangle(right, -51, 63.5, 102, 127);
devDept.Eyeshot.Entities.Region sketch2 = devDept.Eyeshot.Entities.Region.Difference(rr, cr)[0];
loft1.ExtrudeRemove(sketch2, -127);
loft1.SplitBy(pln7, out Brep[] split1, out Brep[] split2);
Brep body = split2[0];
Brep cap = split1[0];
devDept.Eyeshot.Entities.Region rr1 = devDept.Eyeshot.Entities.Region.CreateRectangle(1.3, 1.3, true);
rr1.Translate(0, -25, 0);
rr1.Rotate(Utility.DegToRad(-30), Vector3D.AxisY, Point3D.Origin);
cap.ExtrudeRemovePattern(rr1, 200, Plane.XY, 25, 1, 2.5, 21);
body.Translate(20, 0, -104);
cap.Translate(20, 0, -104);
design1.Entities.Add(body, design1.Layers[0].Name, Color.DodgerBlue);
design1.Entities.Add(cap, design1.Layers[0].Name, Color.Gray);
Switch housing
Plane pl1 = Plane.XY;
pl1.Rotate(Math.PI / 8, Vector3D.AxisY);
Ellipse a1 = new Ellipse(pl1, 5, 5);
a1.Translate(14, 0, 13);
devDept.Eyeshot.Entities.Region r1 = new devDept.Eyeshot.Entities.Region(a1);
Brep foro1 = r1.ExtrudeAsBrep(-65 * Vector3D.AxisZ);
Ellipse a2 = new Ellipse(pl1, 22, 24);
a2.Translate(3, 0, 25);
devDept.Eyeshot.Entities.Region r2 = new devDept.Eyeshot.Entities.Region(a2);
devDept.Eyeshot.Entities.Region ra1 = new devDept.Eyeshot.Entities.Region(a1, a1.Plane);
devDept.Eyeshot.Entities.Region ra2 = new devDept.Eyeshot.Entities.Region(a2, a2.Plane);
Surface sa1 = ra1.ConvertToSurface();
Surface sa2 = ra2.ConvertToSurface();
// Brep to subtract
Brep ruled = Brep.Ruled(sa1, sa2, 0.01);
Brep.Face f2 = body.Faces[2];
Surface[] sf2 = f2.ConvertToSurface();
sf2[0].Offset(-1, 0.01, out Surface offset1);
// cut by surface
ruled.CutBy(offset1, true);
// subtraction
Brep bodySwitch = Brep.Difference(body, ruled)[0];
design1.Entities.Add(bodySwitch, Color.DodgerBlue);
Brand engraving
design1.TextStyles.Add(new TextStyle("MyStyle", "Arial", fontStyle.Regular));
devDept.Eyeshot.Entities.Text text = new devDept.Eyeshot.Entities.Text(Plane.XY, "PHILIPS", 3, devDept.Eyeshot.Entities.Text.alignmentType.BottomCenter, "MyStyle");
text.Rotate(Math.PI / 2, Vector3D.AxisZ);
text.Translate(-35, 0, 37);
devDept.Eyeshot.Entities.Region[] letters = text.ConvertToRegions(design1);
Brep.Face f = bodySwitch.Faces[0];
Surface sf = f.ConvertToSurface()[0];
sf.Offset(-.1, 0.01, out Surface offset2);
foreach (devDept.Eyeshot.Entities.Region reg in letters)
{
Brep extLetter = reg.ExtrudeAsBrep(-7.5);
extLetter.CutBy(offset2, true);
bodySwitch.Remove(extLetter);
}
design1.Entities.Regen();
Comments
Please sign in to leave a comment.