In the following code fragment, you'll find a Sketch-based BRep modeling sample.
Sketch sk1 = new Sketch(Plane.XZ);
SketchPoint origin1 = sk1.AddOrigin();
SketchLine[] poly = sk1.AddPolygon(
new Point2D(0, 0),
new Point2D(80, 0),
new Point2D(170, 100),
new Point2D(560, 100),
new Point2D(650, 0),
new Point2D(730, 0),
new Point2D(730, 625),
new Point2D(650, 625),
new Point2D(580, 540),
new Point2D(150, 540),
new Point2D(80, 625),
new Point2D(0, 625)
);
sk1.AddConstraintJoin(poly[0].StartPoint, origin1);
sk1.AddConstraintHorizontal(poly[0]);
sk1.AddConstraintCollinear(poly[0], poly[4]);
sk1.AddConstraintCollinear(poly[6], poly[10]);
sk1.AddConstraintHorizontal(poly[2]);
sk1.AddConstraintHorizontal(poly[8]);
sk1.AddConstraintVertical(poly[5]);
sk1.AddConstraintVertical(poly[11]);
sk1.AddConstraintLength(poly[0]);
sk1.AddConstraintLength(poly[11]);
sk1.AddConstraintLength(poly[4]);
sk1.AddConstraintEqualLength(poly[0], poly[10]);
sk1.AddConstraintEqualLength(poly[11], poly[5]);
sk1.AddConstraintEqualLength(poly[4], poly[6]);
sk1.AddConstraintDistance(poly[0], poly[2]);
sk1.AddConstraintDistance(poly[10], poly[8]);
sk1.AddConstraintDistance(poly[5], poly[11]);
sk1.AddConstraintVertical(poly[1].EndPoint, poly[8].EndPoint);
sk1.AddConstraintVertical(poly[2].EndPoint, poly[7].EndPoint);
sk1.AddConstraintDistance(poly[1].EndPoint, poly[11]);
sk1.AddConstraintLength(poly[2]);
SketchEntity sketch1 = new SketchEntity(sk1);
Brep ext1 = sketch1.ExtrudeAsBrep(new Interval(-420, 0))[0];
Sketch sk2 = new Sketch(Plane.XZ);
SketchPoint origin2 = sk2.AddOrigin();
SketchLine xAxis2 = sk2.AddAxisX(origin2);
SketchLine yAxis2 = sk2.AddAxisY(origin2);
SketchCurve[] rrect = sk2.AddRoundedRectangle(80, 160, 570, 320, 20);
sk2.AddConstraintDistance((SketchLine)rrect[0], xAxis2);
sk2.AddConstraintDistance((SketchLine)rrect[6], yAxis2);
SketchEntity sketch2 = new SketchEntity(sk2);
ext1.ExtrudeRemove(sketch2, new Interval(-500, 0));
Sketch sk3 = new Sketch(Plane.YZ);
SketchPoint origin3 = sk3.AddOrigin();
SketchLine xAxis3 = sk3.AddAxisX(origin3);
SketchLine yAxis3 = sk3.AddAxisY(origin3);
SketchCircle sc1 = sk3.AddCircle(1, 1, 80);
sk3.AddConstraintDistance(sc1.Center, xAxis3, 250);
sk3.AddConstraintDistance(sc1.Center, yAxis3, 210);
SketchEntity sketch3 = new SketchEntity(sk3);
ext1.ExtrudeRemove(sketch3, new Interval(+600, +800));
design1.Entities.Add(ext1, Color.SlateGray);
Comments
Please sign in to leave a comment.