Bottle Opener

BottleOpener.png

const string Dim = "Dimension", DashDot = "DashDot";
Plane left = new Plane(Point3D.Origin, Vector3D.AxisY, -1 * Vector3D.AxisX); // plane.XY;

// adding different layers
model1.Layers.Add(new Layer(Dim, Color.CornflowerBlue));
model1.Layers.Add(new Layer("framelayer"));
model1.Layers.Add(new Layer("framelayertext"));
model1.Layers[0].LineWeight = 2;
model1.Layers[2].LineWeight = 2;
model1.LineTypes.Add(DashDot, new float[] { 10, -2, 2, -2 });

// adding the axis of symmetry
Line axisX = new Line(-30, 0, 90, 0);
axisX.LineTypeMethod = colorMethodType.byEntity;
axisX.LineTypeName = DashDot;
model1.Entities.Add(axisX, Dim);

// drawing segment and arcs
Line ln1 = new Line(76, 0, 76, 3);
model1.Entities.Add(ln1, Color.Black);

Arc a1 = new Arc(new Point3D(70, 3, 0), 6, 0, Math.PI/2);
model1.Entities.Add(a1, Color.Black);

Line ln2 = new Line(70, 9, 28, 9);
model1.Entities.Add(ln2, Color.Black);

Arc a2 = new Arc(new Point3D(12.52, 9,0), 1, Math.PI / 2, -Math.PI / 2);

Line ln3 = new Line(-2.5, 0, -2.5, 14);
model1.Entities.Add(ln3, Color.Black);
Line ln4 = new Line(-7.5, 0, -7.5, 14);
model1.Entities.Add(ln4, Color.Black);

Circle cr1 = new Circle(30, 28, 0, 19);
Arc a3 = new Arc(new Point3D(0, 14, 0), 7.5, Math.PI);
Arc a4 = new Arc(new Point3D(0, 14, 0), 2.5, Math.PI);

// finding the tangent to two circles
Line ln5 = UtilityEx.GetLinesTangentToTwoCircles(cr1, a3)[1]; 
model1.Entities.Add(ln5, Color.Black);
Line ln6 = UtilityEx.GetLinesTangentToTwoCircles(a2, a4)[0];
model1.Entities.Add(ln6, Color.Black);

// creating a Fillet
Arc a5; 
Curve.Fillet(ln2,ln5, 19, false, false, true, true, out a5);    
a5.Reverse();

double angle = Vector3D.AngleBetween(a5.Plane.AxisX, cr1.Plane.AxisX);

a5.Rotate(angle, a5.Plane.AxisZ, a5.Center);
a5.Domain = new Interval(a5.Domain.t0 - angle, a5.Domain.t1 - angle);

model1.Entities.Add(a5, Color.Black);    

// trimming the curves
Curve.Trim(a3, ln5, true, true);
model1.Entities.Add(a3, Color.Black);

Curve.Trim(a4, ln6, true, true);
model1.Entities.Add(a4, Color.Black);

Curve.Trim(a2, ln6, true, false);


// finding the arc center of the internal part

Point3D p1 = Curve.Intersection(new Circle(12.52, 8, 0, 63.5), new Line(0, 0, -65, 0))[0];

Arc a6 = new Arc(p1, 63.5, 0, Math.PI / 2);
Arc a7 = (Arc)a6.Offset(1, Vector3D.AxisZ);

Curve.Trim(a6, a2, false, false);
model1.Entities.Add(a6, Color.Black);


Point3D p2 = Curve.Intersection(a7, a2)[1];
a7.TrimBy(p2, false);
model1.Entities.Add(a7, Color.Black);
model1.Entities.Add(a2, Color.Black);

// mirroring
Mirror m = new Mirror(Plane.XZ);

ICurve a6mir = (Arc)a6.Clone();
((Entity)a6mir).TransformBy(m);
model1.Entities.Add((Entity)a6mir, Color.Black);

ICurve a7mir = (Arc)a7.Clone();
((Entity)a7mir).TransformBy(m);
model1.Entities.Add((Entity)a7mir, Color.Black);

ICurve ln1mir = (Line)ln1.Clone();
((Entity)ln1mir).TransformBy(m);
model1.Entities.Add((Entity)ln1mir, Color.Black);

ICurve a1mir = (Arc)a1.Clone();
((Entity)a1mir).TransformBy(m);
model1.Entities.Add((Entity)a1mir, Color.Black);

ICurve ln2mir = (Line)ln2.Clone();
((Entity)ln2mir).TransformBy(m);
model1.Entities.Add((Entity)ln2mir, Color.Black);

ICurve a2mir = (Arc)a2.Clone();
((Entity)a2mir).TransformBy(m);
model1.Entities.Add((Entity)a2mir, Color.Black);

ICurve ln5mir = (Line)ln5.Clone();
((Entity)ln5mir).TransformBy(m);
model1.Entities.Add((Entity)ln5mir, Color.Black);

ICurve ln6mir = (Line)ln6.Clone();
((Entity)ln6mir).TransformBy(m);
model1.Entities.Add((Entity)ln6mir, Color.Black);

ICurve a3mir = (Arc)a3.Clone();
((Entity)a3mir).TransformBy(m);
model1.Entities.Add((Entity)a3mir, Color.Black);

ICurve a4mir = (Arc)a4.Clone();
((Entity)a4mir).TransformBy(m);
model1.Entities.Add((Entity)a4mir, Color.Black);

ICurve ln3mir = (Line)ln3.Clone();
((Entity)ln3mir).TransformBy(m);
model1.Entities.Add((Entity)ln3mir, Color.Black);
ICurve ln4mir = (Line)ln4.Clone();
((Entity)ln4mir).TransformBy(m);
model1.Entities.Add((Entity)ln4mir, Color.Black);

ICurve a5mir = (Arc)a5.Clone();
((Entity)a5mir).TransformBy(m);
model1.Entities.Add((Entity)a5mir, Color.Black);

RadialDim rDim1 = new RadialDim(a1, new Point2D(7, 7), 1);
RadialDim rDim2 = new RadialDim(a5, new Point2D(-5, -15), 1);

RadialDim rDim3 = new RadialDim(a3, new Point2D(-10, 10), 1);
RadialDim rDim4 = new RadialDim(a4, new Point2D(-7, 12), 1);
RadialDim rDim5 = new RadialDim(a6, new Point2D(60, 5), 1)
{
    TrimLeader = true,
    ShowCenterMark = false
};
RadialDim rDim6 = new RadialDim(a7, new Point2D(68, 5), 1)
{
    ArrowsLocation = elementPositionType.Outside,
    TrimLeader = true,
    ShowCenterMark = false
};

// printing dimensions
model1.Entities.Add(new LinearDim(Plane.XY, new Point2D(30, 28), new Point2D(70, 3), new Point2D(50, 36), 1), Dim);
model1.Entities.Add(new LinearDim(Plane.XY, new Point2D(0, 14), new Point2D(30, 28), new Point2D(15, 36), 1), Dim);
model1.Entities.Add(new LinearDim(Plane.XY, new Point2D(-7.5, -14), new Point2D(76, -3), new Point2D(34.25, -30), 1), Dim);
model1.Entities.Add(new LinearDim(Plane.XY, new Point2D(0, -14), new Point2D(12.52, -9), new Point2D(6.26, -25), 1), Dim);

model1.Entities.Add(new LinearDim(left, new Point2D(-21.5, 0), new Point2D(21.5, 0), new Point2D(0, 20), 1), Dim);
model1.Entities.Add(new LinearDim(left, new Point2D(0, 10), new Point2D(9, -12.52), new Point2D(4.5, 10), 1), Dim);
model1.Entities.Add(new LinearDim(left, new Point2D(9, -12.52), new Point2D(14, 0), new Point2D(11.5, 10), 1), Dim);

model1.Entities.Add(rDim1, Dim);
model1.Entities.Add(rDim5, Dim);
model1.Entities.Add(rDim6, Dim);
model1.Entities.Add(rDim2, Dim);
model1.Entities.Add(rDim3, Dim);
model1.Entities.Add(rDim4, Dim);

DrawFrame();

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

Print();
void DrawFrame()
{
    const string framelayer = "framelayer", framelayertext = "framelayertext";

    // offset from the ln1 and half height
    const double offset = 39, halfheight = 50, width = 144;

    // drawing the ln1
    Line ln1 = new Line(0 - offset, halfheight, width - offset, halfheight);
    model1.Entities.Add(ln1, framelayer);
    ln1 = new Line(0 - offset, halfheight, 0 - offset, -halfheight);
    model1.Entities.Add(ln1, framelayer);
    ln1 = new Line(0 - offset, -halfheight, width - offset, -halfheight);
    model1.Entities.Add(ln1, framelayer);
    ln1 = new Line(width - offset, -halfheight, width - offset, halfheight);
    model1.Entities.Add(ln1, framelayer);

    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);
    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, -halfheight + 5);
    model1.Entities.Add(line, framelayertext);

    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, "Bottle Opener", 3.5, 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);
}
private void Print()
{
    model1.PageSetup(true, false, 0, new System.Drawing.Printing.PaperSize("A4", 826, 1169), true);

    // saves current view Camera
    model1.SaveView(out Camera cameraSaved);

    model1.Camera.ProjectionMode = devDept.Graphics.projectionType.Orthographic;
            
    // creates printing setting object and customize it
    HiddenLinesViewSettings hdlS = new HiddenLinesViewSettings(model1);
    hdlS.KeepEntityLineWeight = true;

    // creates paper preview
    HiddenLinesViewOnPaperPreview hdl = new HiddenLinesViewOnPaperPreview(hdlS, new Size(800,600), 2);
    model1.StartWork(hdl);

    // restores saved view
    model1.RestoreView(cameraSaved);
}
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.