CAD Practice Drawings 15

Result2D.png


// Layers definition: default layer for the model at index 0, dashed lines at 1, dimensions at 2
string Dim = "Dimension", DashDot = "DashDot";
model1.Layers.Add(new Layer(DashDot, Color.CornflowerBlue));
model1.Layers.Add(new Layer(Dim, Color.CornflowerBlue));

model1.Layers[0].Color = Color.Black;
model1.Layers[0].LineWeight = 2;

model1.LineTypes.Add(DashDot, new float[] { 5, -1, 1, -1 });
model1.Layers[1].LineTypeName = DashDot;

// ************* GEOMETRY *************
Line axisX = new Line(-60, 0, 20, 0);
Line topDashDotLine = new Line(0, 0, 0, 60 * Math.Cos(Utility.DegToRad(60)), 60 * Math.Sin(Utility.DegToRad(60)), 0);
Line bottomDashDotLine = new Line(0, 0, 0, 60 * Math.Cos(Utility.DegToRad(60)), 60 * -Math.Sin(Utility.DegToRad(60)), 0);
Arc dimCircle = new Arc(Point3D.Origin, 48, 0, Math.PI * 2);

model1.Entities.Add(axisX, DashDot);
model1.Entities.Add(topDashDotLine, DashDot);
model1.Entities.Add(bottomDashDotLine, DashDot);
model1.Entities.Add(dimCircle, DashDot);

Circle mainCircle = new Circle(Point3D.Origin, 9);

// Spoke class to model each spoke, the first is the top one, the other 2 are rotated to have the bottom and left spokes
Spoke spoke1 = new Spoke(dimCircle, topDashDotLine);
Spoke spoke2 = new Spoke(dimCircle, topDashDotLine);
Spoke spoke3 = new Spoke(dimCircle, topDashDotLine);
spoke2.Rotate(Utility.DegToRad(120), Vector3D.AxisZ, Point3D.Origin);
spoke3.Rotate(Utility.DegToRad(-120), Vector3D.AxisZ, Point3D.Origin);
spoke1.AddToModel(model1);
spoke2.AddToModel(model1);
spoke3.AddToModel(model1);

Arc arcFillet1, arcFillet2, arcFillet3;
Curve.Fillet(spoke1.leftLine, spoke2.rightLine, 18, false, true, true, true, out arcFillet1);
Curve.Fillet(spoke2.leftLine, spoke3.rightLine, 18, false, true, true, true, out arcFillet2);
Curve.Fillet(spoke3.leftLine, spoke1.rightLine, 18, false, true, true, true, out arcFillet3);

model1.Entities.Add(arcFillet1);
model1.Entities.Add(arcFillet2);
model1.Entities.Add(arcFillet3);
model1.Entities.Add(mainCircle);

// ************* DIMENSIONS *************
RadialDim rDimArcFillet = new RadialDim(arcFillet1, new Point2D(0, 0), 2)
{
    ShowCenterMark = false
};
DiametricDim diamMainCircle = new DiametricDim(mainCircle, new Point2D(-15, -5), 2)
{
    ShowCenterMark = false
};
RadialDim rDimCircle = new RadialDim(dimCircle, new Point2D(-30, 25), 2)
{
    ShowCenterMark = false
};

AngularDim angleDim = new AngularDim(Plane.XY, topDashDotLine, bottomDashDotLine, new Point3D(39.9, 0, 0), new Point3D(40, 0, 0), 2);
angleDim.TextSuffix = "°";
angleDim.ExtLineOffset = 0;
AngularDim angleLinesDim = new AngularDim(Plane.XY, spoke3.rightLine, spoke3.leftLine, new Point3D(1, 0, 0), new Point3D(15, -20, 0), 2);
angleLinesDim.TextSuffix = "°";

double midParameter = spoke1.leftLine.Domain.Mid;
Point3D leftMidPoint = spoke1.leftLine.MidPoint;
Point3D innerLeftMidPoint = spoke1.innerLeftLine.MidPoint;
double angleBetween = Vector3D.AngleBetween(Vector3D.AxisY, spoke1.leftLine.TangentAt(midParameter));

Plane pln = new Plane(spoke1.leftLine.PointAt(midParameter), Vector3D.AxisX, Vector3D.AxisY);
pln.Rotate(-angleBetween, Vector3D.AxisZ);
LinearDim ldim = new LinearDim(pln, leftMidPoint, innerLeftMidPoint, new Point3D(leftMidPoint.X - 10, innerLeftMidPoint.Y), 2);

midParameter = spoke1.rightLine.Domain.Mid;
Point3D rightMidPoint = spoke1.rightLine.MidPoint;
Point3D innerRightMidPoint = spoke1.innerRightLine.MidPoint;
angleBetween = Vector3D.AngleBetween(Vector3D.AxisY, spoke1.rightLine.TangentAt(midParameter));

pln = new Plane(spoke1.rightLine.PointAt(midParameter), Vector3D.AxisX, Vector3D.AxisY);
pln.Rotate(-angleBetween, Vector3D.AxisZ);
LinearDim ldim2 = new LinearDim(pln, rightMidPoint, innerRightMidPoint, new Point3D(rightMidPoint.X + 4, innerRightMidPoint.Y), 2);

spoke2.arcFillet2.Reverse();
RadialDim rDimArcFillet1 = new RadialDim(spoke2.arcFillet2, new Point2D(12, 7), 2)
{
    TrimLeader = true,
    ShowCenterMark = false
};

spoke2.arcFillet4.Reverse();
RadialDim rDimArcFillet2 = new RadialDim(spoke2.arcFillet4, new Point2D(20, 3), 2)
{
    TrimLeader = true,
    ShowCenterMark = false
};

RadialDim rDimTopArc = new RadialDim(spoke2.topArc, new Point2D(-8, 8), 2)
{
    TrimLeader = true,
    ShowCenterMark = false,
    ArrowsLocation = elementPositionType.Outside
};

RadialDim rDimTopCircle = new RadialDim(spoke2.topCircle, new Point2D(15, -5), 2)
{
    TrimLeader = true,
    ShowCenterMark = false
};

RadialDim rDimBottomArc = new RadialDim(spoke2.bottomArc, new Point2D(-5, 1), 2)
{
    TrimLeader = true,
    ShowCenterMark = false,
};

model1.Entities.Add(ldim, Dim);
model1.Entities.Add(ldim2, Dim);
model1.Entities.Add(angleDim, Dim);
model1.Entities.Add(angleLinesDim, Dim);
model1.Entities.Add(diamMainCircle, Dim);
model1.Entities.Add(rDimCircle, Dim);
model1.Entities.Add(rDimArcFillet, Dim);
model1.Entities.Add(rDimArcFillet1, Dim);
model1.Entities.Add(rDimArcFillet2, Dim);
model1.Entities.Add(rDimTopArc, Dim);
model1.Entities.Add(rDimTopCircle, Dim);
model1.Entities.Add(rDimBottomArc, Dim);

DrawFrame();

// other settings
model1.OriginSymbol.Visible = false;
model1.Grid.Visible = false;
model1.SetView(viewType.Top, true, false);

class Spoke
{
    public Circle topCircle;
    public Arc topArc;
    public Arc belowCircleArc;
    public Arc arcFillet1, arcFillet2, arcFillet3, arcFillet4;
    public Arc bottomArc;
    public Line innerRightLine, innerLeftLine;
    public Line rightLine;
    public Line leftLine;

    public Spoke(Circle dimCircle, Line dashDotLine)
    {
        this.bottomArc = new Arc(Point3D.Origin, 12, 0, Math.PI * 2);

        topCircle = new Circle(dimCircle.IntersectWith(dashDotLine)[0], 3);

        topArc = new Arc(topCircle.Center, 6, Utility.DegToRad(10), Utility.DegToRad(170));
        topArc.Rotate(Utility.DegToRad(-30), Vector3D.AxisZ, topCircle.Center);

        Arc arc = new Arc(topCircle.Center, 6, 0, 2 * Math.PI);

        List intersactionPoints = new List();

        rightLine = new Line(new Point3D(15.255, 0, 0), topArc.StartPoint);
        leftLine = new Line(new Point3D(15.255 * Math.Cos(Utility.DegToRad(120)), 15.255 * Math.Sin(Utility.DegToRad(120)), 0), topArc.EndPoint);

        innerRightLine = (Line)rightLine.Offset(-3, Vector3D.AxisZ);
        innerLeftLine = (Line)leftLine.Offset(3, Vector3D.AxisZ);

        intersactionPoints.AddRange(arc.IntersectWith(innerRightLine));
        intersactionPoints.AddRange(arc.IntersectWith(innerLeftLine));

        ICurve[] arcSplits;
        arc.SplitBy(intersactionPoints, out arcSplits);

        belowCircleArc = (Arc)arcSplits[1];
        Curve.Fillet(belowCircleArc, innerRightLine, 2.4, true, false, true, true, out arcFillet1);
        Curve.Fillet(innerLeftLine, belowCircleArc, 2.4, true, true, true, true, out arcFillet2);

        Curve.Fillet(innerRightLine, bottomArc, 2.4, false, true, true, true, out arcFillet3);
        Curve.Fillet(innerLeftLine, bottomArc, 2.4, true, true, true, true, out arcFillet4);
    }

    public void AddToModel(devDept.Eyeshot.Model model1)
    {
        model1.Entities.Add(arcFillet1);
        model1.Entities.Add(arcFillet2);
        model1.Entities.Add(arcFillet3);
        model1.Entities.Add(arcFillet4);
        model1.Entities.Add(rightLine);
        model1.Entities.Add(leftLine);
        model1.Entities.Add(innerRightLine);
        model1.Entities.Add(innerLeftLine);
        model1.Entities.Add(topCircle);
        model1.Entities.Add(topArc);
        model1.Entities.Add(belowCircleArc);
        model1.Entities.Add(bottomArc);
    }


    public void Rotate(double angleInRadians, Vector3D axis, Point3D center)
    {
        arcFillet1.Rotate(angleInRadians, axis, center);
        arcFillet2.Rotate(angleInRadians, axis, center);
        arcFillet3.Rotate(angleInRadians, axis, center);
        arcFillet4.Rotate(angleInRadians, axis, center);
        rightLine.Rotate(angleInRadians, axis, center);
        leftLine.Rotate(angleInRadians, axis, center);
        innerRightLine.Rotate(angleInRadians, axis, center);
        innerLeftLine.Rotate(angleInRadians, axis, center);
        topCircle.Rotate(angleInRadians, axis, center);
        topArc.Rotate(angleInRadians, axis, center);
        belowCircleArc.Rotate(angleInRadians, axis, center);
        bottomArc.Rotate(angleInRadians, axis, center);
    }
}

void DrawFrame()
{
    string framelayer = "framelayer", framelayertext = "framelayertext";
    model1.Layers.Add(new Layer(framelayer) { LineWeight = 2 });
    model1.Layers.Add(new Layer(framelayertext));

    double offset = 70, halfheight = 100, width = 140;

    // drawing the outer box
    DrawMainBox(framelayer, offset, halfheight, width);
// drawing boxes with info DrawInfoBox(framelayer, framelayertext, offset, halfheight, width);
// writing text in the info boxes DrawText("CAD Practice Drawings 15", framelayertext, offset, halfheight, width); // drawing top box with number in it DrawNumberBox(15, framelayer, framelayertext, offset, halfheight, width); } private void DrawMainBox(string framelayer, double offset, double halfheight, double width) { Line line = new Line(0 - offset, halfheight, width - offset, halfheight); model1.Entities.Add(line, framelayer); line = new Line(0 - offset, halfheight, 0 - offset, -halfheight); model1.Entities.Add(line, framelayer); line = new Line(0 - offset, -halfheight, width - offset, -halfheight); model1.Entities.Add(line, framelayer); line = new Line(width - offset, -halfheight, width - offset, halfheight); model1.Entities.Add(line, framelayer); } private void DrawNumberBox(int number, string framelayer, string framelayertext, double offset, double halfheight, double width) { Line line = new Line(width / 2, halfheight - 5, width / 3 + 15, halfheight - 5); model1.Entities.Add(line, framelayer); line = new Line(width / 3 + 15, halfheight - 5, width / 3 + 15, halfheight); model1.Entities.Add(line, framelayer); Text text = new Text(width / 3 + 19.5, halfheight - 2.5, 0, number.ToString(), 2, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter); model1.Entities.Add(text, framelayertext); } private void DrawInfoBox(string framelayer, string framelayertext, double offset, double halfheight, double width) { Line line = new Line(width / 3 - offset, -halfheight + 15, width - offset, -halfheight + 15); model1.Entities.Add(line, framelayer); line = new Line(width / 3 - offset, -halfheight + 15, width / 3 - offset, -halfheight); model1.Entities.Add(line, framelayer); // Using framelayertext to have thinner lines line = new Line(width / 3 - offset, -halfheight + 10, width - offset, -halfheight + 10); model1.Entities.Add(line, framelayertext); line = new Line(100 - offset, -halfheight + 15, 100 - offset, -halfheight); model1.Entities.Add(line, framelayertext); line = new Line(115 - offset, -halfheight + 15, 115 - offset, -halfheight); model1.Entities.Add(line, framelayertext); line = new Line(100 - offset, -halfheight + 5, width - offset - offset / 5, -halfheight + 5); model1.Entities.Add(line, framelayertext); line = new Line(width - offset - offset / 5, -halfheight + 15, width - offset - offset / 5, -halfheight); model1.Entities.Add(line, framelayertext); } private void DrawText(string title, string framelayertext, double offset, double halfheight, double width) { Text text = new Text(73 - offset, -halfheight + 12.5, 0, "Title", 2, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter); model1.Entities.Add(text, framelayertext); text = new Text(73 - offset, -halfheight + 5, 0, title, 3, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter); model1.Entities.Add(text, framelayertext); text = new Text(107 - offset, -halfheight + 12.5, 0, "Date", 2, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter); model1.Entities.Add(text, framelayertext); text = new Text(107 - offset, -halfheight + 7.5, 0, "Design", 2, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter); model1.Entities.Add(text, framelayertext); text = new Text(107 - offset, -halfheight + 2.5, 0, "Check", 2, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter); model1.Entities.Add(text, framelayertext); text = new Text(width - offset - offset / 5 + 7, -halfheight + 12.5, 0, "Approve", 2, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter); model1.Entities.Add(text, framelayertext); }
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.