
const string Dimensions = "m";
const string DashDot = "DashDot";
design1.Grid.Visible = false;
design1.Layers[0].LineWeight = 2;
design1.Layers.Add(new Layer(Dimensions, Color.CornflowerBlue) { LineWeight = 0.2f });
design1.LineTypes.Add(DashDot, new float[] { 7, -2, 2, -2 });
Circle c1 = new Circle(0, 0, 0, 14);
Circle c2 = new Circle(0, 0, 0, 20);
Circle c3 = new Circle(0, 27.5, 0, 3.5);
Circle c4 = new Circle(0, -27.5, 0, 3.5);
Circle cAux1 = new Circle(0, 27.5, 0, 7.5);
Line t1 = UtilityEx.GetLinesTangentToTwoCircles(cAux1, c2)[0];
Line t2 = UtilityEx.GetLinesTangentToTwoCircles(cAux1, c2)[1];
design1.Entities.AddRange(new Entity[]{c1, c2, c3, c4});
Arc a1 = new Arc(cAux1.Center, cAux1.Radius, Math.PI);
a1.TrimBy(t1.StartPoint, true);
a1.TrimBy(t2.StartPoint, false);
CompositeCurve cc1 = new CompositeCurve(t1, t2, a1);
CompositeCurve cc2 = (CompositeCurve)cc1.Clone();
cc2.Rotate(Math.PI, Vector3D.AxisX);
design1.Entities.Add(cc1);
design1.Entities.Add(cc2);
double h = Math.Sqrt(Math.Pow(20, 2) - Math.Pow(7.5, 2));
Circle cAux2 = new Circle(0, h, 0, 7.5);
Line l1 = UtilityEx.GetLinesTangentToTwoCircles(cAux1, cAux2)[0];
Line l2 = (Line)l1.Clone();
l2.Translate(new Vector3D(-7.5 * 2, 0, 0));
Arc a3 = new Arc(cAux1.Center, cAux1.Radius, Math.PI);
CompositeCurve cc3 = new CompositeCurve(l1, a3, l2);
design1.Entities.Add(cc3);
CompositeCurve cc4 = (CompositeCurve)cc3.Clone();
cc4.Rotate(Math.PI, Vector3D.AxisX);
design1.Entities.Add(cc4);
Arc a4 = new Arc(32.5 + 15, 0, 0, 9, -Math.PI / 2.0, Math.PI / 2.0);
Circle cAux3 = new Circle(Math.Sqrt(20 * 20 - 9 * 9), 0, 0, 9);
Circle cAux4 = new Circle(32.5 + 15, 0, 0, 9);
Line l3 = UtilityEx.GetLinesTangentToTwoCircles(cAux3, cAux4)[0];
Line l4 = UtilityEx.GetLinesTangentToTwoCircles(cAux3, cAux4)[1];
CompositeCurve cc5 = new CompositeCurve(a4, l3, l4);
design1.Entities.Add(cc5);
Circle cAux6 = new Circle(32.5 + 15, 0, 0, 5.5);
Circle cAux7 = new Circle(32.5, 0, 0, 5.5);
Line l5 = UtilityEx.GetLinesTangentToTwoCircles(cAux6, cAux7)[0];
Line l6 = UtilityEx.GetLinesTangentToTwoCircles(cAux6, cAux7)[1];
Arc a5 = new Arc(new Point3D(32.5 + 15, 0, 0), 5.5, -Math.PI / 2.0, Math.PI / 2.0);
Arc a6 = new Arc(new Point3D(32.5, 0, 0), 5.5, Math.PI / 2.0, 3 * Math.PI / 2.0);
CompositeCurve cc6 = new CompositeCurve(l5, l6, a5, a6);
design1.Entities.Add(cc6);
const double height = 2.5;
Line lDim1 = new Line(0, 40, 0, -40);
lDim1.LineTypeName = DashDot;
lDim1.LineTypeMethod = colorMethodType.byEntity;
Line lDim2 = new Line(58, 0, -25, 0);
lDim2.LineTypeName = DashDot;
lDim2.LineTypeMethod = colorMethodType.byEntity;
Line lDim3 = new Line(32.5, 12, 32.5, -12);
lDim3.LineTypeName = DashDot;
lDim3.LineTypeMethod = colorMethodType.byEntity;
Line lDim4 = (Line)lDim3.Clone();
lDim4.Translate(15, 0, 0);
Line lDim5 = new Line(-12, 27.5, 12, 27.5);
lDim5.LineTypeName = DashDot;
lDim5.LineTypeMethod = colorMethodType.byEntity;
Line lDim6 = (Line)lDim5.Clone();
lDim6.Translate(0, -55, 0);
LinearDim lDim7 = new LinearDim(Plane.XY, (Point3D)lDim1.EndPoint.Clone(), (Point3D)lDim3.EndPoint.Clone(), new Point3D(16.25, -46, 0), height);
LinearDim lDim8 = new LinearDim(Plane.XY, (Point3D)lDim3.EndPoint.Clone(), (Point3D)lDim4.EndPoint.Clone(), new Point3D(40, -46, 0), height);
Plane vertical = new Plane(Point3D.Origin, Vector3D.AxisY, Vector3D.AxisMinusX);
LinearDim lDim9 = new LinearDim(vertical, (Point3D)lDim5.StartPoint.Clone(), (Point3D)lDim6.StartPoint.Clone(), new Point3D(-35, 0, 0), height);
LinearDim lDim10 = new LinearDim(vertical, new Point3D(47.5, 9, 0), new Point3D(47.5, -9, 0), new Point3D(70, 0, 0), height);
LinearDim lDim11 = new LinearDim(vertical, new Point3D(15 + 32.5, 5.5, 0), new Point3D(15 + 32.5, -5.5, 0), new Point3D(63, 0, 0), height);
design1.Entities.AddRange(new Entity[]
{
lDim1,
lDim2,
lDim3,
lDim4,
lDim5,
lDim6,
lDim7,
lDim8,
lDim9,
lDim10,
lDim11
}, Dimensions);
DiametricDim dimC1 = new DiametricDim(c1, new Point3D(11 - 4, Math.Sqrt(14 * 14 - 11 * 11) - 4, 0), height);
design1.Entities.Add(dimC1, Dimensions);
DiametricDim dimC2 = new DiametricDim(c2, new Point3D(-17 - 2, Math.Sqrt(20 * 20 - 17 * 17) - 2, 0), height);
design1.Entities.Add(dimC2, Dimensions);
DiametricDim dimC3 = new DiametricDim(c3, new Point3D(1.75 + 9, 27.5 + Math.Sqrt(3.5 * 3.5 - 1.75 * 1.75) + 9, 0), height);
design1.Entities.Add(dimC3, Dimensions);
dimC.TextPrefix = "2-Ø";
Arc arcDim1 = new Arc(0, -27.5, 0, 7.5, 5 * Math.PI / 4.0, 2 * Math.PI);
RadialDim rDim1 = new RadialDim(arcDim1, new Point3D(-15, -15 - 27.5, 0), height)
{
CenterMarkSize = 0,
ArrowsLocation = elementPositionType.Outside,
TextPrefix = "2-R",
TrimLeader = true
};
design1.Entities.Add(rDim1, Dimensions);
double scale = 3;
design1.Entities.Translate(-15, 0);
design1.Entities.Scale(scale);
foreach (Entity en in design1.Entities)
{
if (en is Dimension)
{
((Dimension)en).LinearScale = 1 / scale;
}
}
design1.Entities.Regen();
DrawFrame();
Print();
void DrawFrame()
{
const string frameTitle = "CAD Practice Drawings 27";
const double halfWidth = 200, halfHeight = 287;
design1.Entities.AddRange(new Entity[] {
new LinearPath(-halfWidth, -halfHeight, 2 * halfWidth, 2 * halfHeight),
new Line(-halfWidth / 4, -halfHeight + 30, halfWidth, -halfHeight + 30),
new Line(-halfWidth / 4, -halfHeight + 30, -halfWidth / 4, -halfHeight),
new Text(25, -halfHeight + 25, 0, "Title", 4, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter),
new Text(25, -halfHeight + 10, 0, frameTitle, 8, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter),
new Text(115, -halfHeight + 25, 0, "Date", 4, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter),
new Text(115, -halfHeight + 15, 0, "Design", 4, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter),
new Text(115, -halfHeight + 5, 0, "Check", 4, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter),
new Text(180, -halfHeight + 25, 0, "Approve", 4, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter),
new Line(halfWidth - 30, halfHeight - 15, halfWidth, halfHeight - 15),
new Line(halfWidth - 30, halfHeight - 15, halfWidth - 30, halfHeight),
new Text(halfWidth - 15, halfHeight - 7.5, 0, "27", 8, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter),
new Line(-halfWidth + 110, halfHeight - 15, -halfWidth, halfHeight - 15),
new Line(-halfWidth +110, halfHeight - 15, -halfWidth+110, halfHeight),
new Text(-halfWidth +24, halfHeight - 6, 0, "STUDY CADCAM " , 4, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter),
new Text(-halfWidth +40, halfHeight - 11, 0, "http://www.studycadcam.com", 4, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter)
});
design1.Entities.AddRange(new Entity[] {
new Line(-halfWidth / 4, -halfHeight + 20, halfWidth, -halfHeight + 20),
new Line(100, -halfHeight + 30, 100, -halfHeight),
new Line(130, -halfHeight + 30, 130, -halfHeight),
new Line(160, -halfHeight + 30, 160, -halfHeight),
new Line(100, -halfHeight + 10, 160, -halfHeight + 10)
});
}
void Print()
{
PaperSize paperSize = new System.Drawing.Printing.PaperSize("A4", 826, 1169);
design1.PageSetup(true, false, 0, paperSize, false);
HiddenLinesViewSettingsEx hdlS = new HiddenLinesViewSettingsEx(viewType.Top, design1.Document);
hdlS.KeepEntityLineWeight = true;
const double printScaling = 0.5;
HiddenLinesViewOnPaperPreview hdl = new HiddenLinesViewOnPaperPreview(hdlS, new Size(800, 600), printScaling);
design1.StartWork(hdl);
}

Comments
Please sign in to leave a comment.