🌶️ CAD Practice Drawings 124

124.png

private const string
    DimLayer = "Dimension",
    ThinLayer = "ThinLayer",
    DashDot = "DashDot";
design1.Layers[0].LineWeight = 2;
design1.Layers.Add(new Layer(DimLayer, Color.CornflowerBlue));
design1.Layers.Add(new Layer(ThinLayer));
design1.LineTypes.Add(DashDot, new float[] { 30, -5, 5, -5 });
design1.SetView(viewType.Top);

int x = 0;
int y = 287 / 6 - 20;

DrawFrame();

Circle bco = new Circle(x, y, 0, 65);
Circle cit = new Circle(x, y + 100, 0, 17);
Circle cot = new Circle(x, y + 100, 0, 28);
Circle cib = new Circle(x - 54, y - 90, 0, 8);
Circle cob = new Circle(x - 54, y - 90, 0, 18);

Arc r28_1 = (Arc)UtilityEx.GetCirclesTangentToTwoCircles(cob, bco, 28, true)[1];

double x_i1 = x + Math.Cos(Utility.DegToRad(-45)) * (36);
double y_i1 = y + Math.Sin(Utility.DegToRad(-45)) * (36);
double x_i2 = x + Math.Cos(Utility.DegToRad(-135)) * (36);
double y_i2 = y + Math.Sin(Utility.DegToRad(-135)) * (36);

Arc acr = new Arc(new Point3D(x_i1, y_i1, 0), 16, Math.PI);
Arc acl = new Arc(new Point3D(x_i2, y_i2, 0), 16, Math.PI);
acr.Rotate(Utility.DegToRad(135), acr.Plane.AxisZ, acr.Center);
acl.Rotate(-Utility.DegToRad(135), acl.Plane.AxisZ, acl.Center);

Line li = UtilityEx.GetLinesTangentToTwoCircles(bco, cot)[0];
Line lr = UtilityEx.GetLinesTangentToTwoCircles(bco, cot)[1];
Line lib = UtilityEx.GetLinesTangentToTwoCircles(bco, cob)[1];

Arc abcol = new Arc(bco.Center, bco.Radius, 2 * Math.PI);
Arc abcor = new Arc(bco.Center, bco.Radius, 2 * Math.PI);
abcol.TrimBy(li.StartPoint, true);
abcor.TrimBy(lr.StartPoint, false);

Arc acot = new Arc(cot.Center, cot.Radius, 2 * Math.PI);
Arc aic = new Arc(new Point3D(x, y, 0), 20, Utility.DegToRad(270));
Arc aoc = new Arc(new Point3D(x, y, 0), 52, Utility.DegToRad(270));
aic.Rotate(-Utility.DegToRad(45), aic.Plane.AxisZ, aic.Center);
aoc.Rotate(-Utility.DegToRad(45), aoc.Plane.AxisZ, aoc.Center);

acot.TrimBy(li.EndPoint, false);
acot.TrimBy(lr.EndPoint, true);

//dimensions and axes
Circle ccd = new Circle(x, y, 0, 36);
ccd.LineTypeName = DashDot;
ccd.LineTypeMethod = colorMethodType.byEntity;
design1.Entities.Add(ccd, DimLayer);

Line axisX = new Line(-79, y, 90, y);
axisX.LineTypeMethod = colorMethodType.byEntity;
axisX.LineTypeName = DashDot;
design1.Entities.Add(axisX, DimLayer);

Line axisY = new Line(x, y + 153, x, y - 115);
axisY.LineTypeMethod = colorMethodType.byEntity;
axisY.LineTypeName = DashDot;
design1.Entities.Add(axisY, DimLayer);

Line dt = new Line(x - 43, y + 100, x + 90, y + 100);
dt.LineTypeMethod = colorMethodType.byEntity;
dt.LineTypeName = DashDot;
design1.Entities.Add(dt, DimLayer);

Line dbx = new Line(x - 82, y - 90, x - 26, y - 90);
dbx.LineTypeMethod = colorMethodType.byEntity;
dbx.LineTypeName = DashDot;
design1.Entities.Add(dbx, DimLayer);

Line dby = new Line(x - 54, y - 118, x - 54, y - 62);
dby.LineTypeMethod = colorMethodType.byEntity;
dby.LineTypeName = DashDot;
design1.Entities.Add(dby, DimLayer);

Line a45r = new Line(x, y, x + Math.Cos(Utility.DegToRad(-45)) * (85), y + Math.Sin(Utility.DegToRad(-45)) * (85));
a45r.LineTypeMethod = colorMethodType.byEntity;
a45r.LineTypeName = DashDot;
design1.Entities.Add(a45r, DimLayer);

Line a45l = new Line(x, y, x + Math.Cos(Utility.DegToRad(-135)) * (60), y + Math.Sin(Utility.DegToRad(-135)) * (60));
a45l.LineTypeMethod = colorMethodType.byEntity;
a45l.LineTypeName = DashDot;
design1.Entities.Add(a45l, DimLayer);

Plane pln = new Plane(Point3D.Origin, Vector3D.AxisY, Vector3D.AxisMinusX);

design1.Entities.Add(new LinearDim(pln, new Point3D(x + 70, y), new Point3D(x + 70, y + 100), new Point3D(x + 85, y + 50), 5), DimLayer);
design1.Entities.Add(new LinearDim(pln, new Point3D(x - 70, y), new Point3D(x - 70, y - 90), new Point3D(x - 95, y - 45), 5), DimLayer);
design1.Entities.Add(new LinearDim(Plane.XY, new Point2D(cib.Center.X, y), new Point2D(x, y), new Point2D((cib.Center.X + x) / 2, y - 133), 5), DimLayer);

r28_1 = SyncArcWithXY(r28_1);

RadialDim rdim1 = new RadialDim(r28_1, new Point2D(Math.Cos(Utility.DegToRad(135)) * 13, Math.Sin(Utility.DegToRad(135)) * 13), 5);
design1.Entities.Add(rdim1, DimLayer);

RadialDim rdim2 = new RadialDim(abcol, new Point2D(Math.Cos(Utility.DegToRad(-145)) * 95, Math.Sin(Utility.DegToRad(-145)) * 95), 5)
{
    ArrowsLocation = elementPositionType.Outside,
    TrimLeader = true
};
design1.Entities.Add(rdim2, DimLayer);

RadialDim rdim3 = new RadialDim(acot, new Point2D(Math.Cos(Utility.DegToRad(135)) * 45, Math.Sin(Utility.DegToRad(135)) * 45), 5)
{
    ArrowsLocation = elementPositionType.Outside,
    TrimLeader = true
};
design1.Entities.Add(rdim3, DimLayer);

acl = SyncArcWithXY(acl);
RadialDim rdim4 = new RadialDim(acl, new Point2D(Math.Cos(Utility.DegToRad(-70)) * 20, Math.Sin(Utility.DegToRad(-70)) * 20), 5)
{
    ArrowsLocation = elementPositionType.Outside,
    TrimLeader = true
};
design1.Entities.Add(rdim4, DimLayer);

DiametricDim topdim = new DiametricDim(cit, new Point2D(Math.Cos(Utility.DegToRad(45)) * 40, Math.Sin(Utility.DegToRad(45)) * 40), 5);
design1.Entities.Add(topdim, DimLayer);

DiametricDim centerodim = new DiametricDim(ccd, new Point2D(Math.Cos(Utility.DegToRad(155)) * 90, Math.Sin(Utility.DegToRad(155)) * 90), 5);
design1.Entities.Add(centerodim, DimLayer);

DiametricDim bottomdim = new DiametricDim(cib, new Point2D(Math.Cos(Utility.DegToRad(225)) * 30, Math.Sin(Utility.DegToRad(225)) * 30), 5);
design1.Entities.Add(bottomdim, DimLayer);

DiametricDim bodttomodim = new DiametricDim(cob, new Point2D(Math.Cos(Utility.DegToRad(-45)) * 30, Math.Sin(Utility.DegToRad(-45)) * 30), 5);
design1.Entities.Add(bodttomodim, DimLayer);

AngularDim angDim = new AngularDim(Plane.XY, new Point3D(x, y), new Point3D(x + Math.Cos(Utility.DegToRad(-90)) * (85), y + Math.Sin(Utility.DegToRad(-90)) * (85)), new Point3D(x + Math.Cos(Utility.DegToRad(-45)) * (85), y + Math.Sin(Utility.DegToRad(-45)) * (85)), new Point3D(x + Math.Cos(Utility.DegToRad(-67.5)) * (85), y + Math.Sin(Utility.DegToRad(-67.5)) * (85)), 5);
design1.Entities.Add(angDim, DimLayer);

design1.Entities.AddRange(new Entity[] {
li,
lr,
lib,
aic,
aoc,
abcol,
abcor,
cit,
acot,
cib,
cob,
acr,
acl,
r28_1});

Print();
void DrawFrame()
{
    string frameID = "124";
    string frameTitle = "CAD Practice Drawing " + frameID;
    int halfWidth = 200;
    int 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, frameID, 8, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter)

    });

    // Add thin lines
    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)

    }, ThinLayer);
}
private Arc SyncArcWithXY(Arc a)
{
    Arc copy = a;

    if (a.Plane.AxisZ.Z == -1)
    {
        copy = (Arc)a.Clone();
        copy.Reverse();
    }
    Point3D c = new Point3D(copy.Center.X, copy.Center.Y, copy.Center.Z);
    Point2D start = new Point2D(copy.StartPoint.X, copy.StartPoint.Y);
    Point2D end = new Point2D(copy.EndPoint.X, copy.EndPoint.Y);
    double angS = new Vector2D((Point2D)c, start).Angle;//Angle between startPoint vector and X axis
    double angE = new Vector2D((Point2D)c, end).Angle;//Angle between endpoint vector and Y axis
    if (angS > angE)
    {
        copy.Reverse();
        start = new Point2D(copy.StartPoint.X, copy.StartPoint.Y);
        end = new Point2D(copy.EndPoint.X, copy.EndPoint.Y);
        angS = new Vector2D((Point2D)c, start).Angle;
        angE = new Vector2D((Point2D)c, end).Angle;
    }

    Arc res = new Arc(c, copy.Radius, angS, angE);

    return res;
}
private void Print()
{
    design1.PageSetup(true, false, 0, new System.Drawing.Printing.PaperSize("A4", 826, 1169), false);

    //Save current view Camera
    design1.SaveView(out Camera cameraSaved);

    design1.ActiveViewport.Camera.ProjectionMode = devDept.Eyeshot.projectionType.Orthographic;

    //Creates printing setting object and customize it
    HiddenLinesViewSettingsEx hdlS = new HiddenLinesViewSettingsEx(design1, hiddenLinesViewType.Viewport);
    hdlS.KeepEntityLineWeight = true;

    //Creates paper preview
    HiddenLinesViewOnPaperPreview hdl = new HiddenLinesViewOnPaperPreview(hdlS, new Size(800, 600), 0.5);
    design1.StartWork(hdl);

    //Restore saved view
    design1.RestoreView(cameraSaved);
}
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.

Articles in this section

See more