

Circle c1 = new Circle(new Point3D(0, 0), 30);
Circle c2 = new Circle(new Point3D(105, 0), 21);
devDept.Eyeshot.Entities.Region creg1 = new devDept.Eyeshot.Entities.Region(c1, Plane.XY);
devDept.Eyeshot.Entities.Region creg2 = new devDept.Eyeshot.Entities.Region(c2, Plane.XY);
Arc l1top = (Arc) UtilityEx.GetCirclesTangentToTwoCircles(c1, c2,115,true)[3];
Arc l1bottom = new Arc(l1top.Center, l1top.Radius - 8, l1top.AngleInRadians);
l1bottom.Rotate(Utility.DegToRad(45), Vector3D.AxisZ, l1top.Center);
Arc l2bottom = (Arc) UtilityEx.GetCirclesTangentToTwoCircles(c1, c2, 60, true)[1];
Arc l2top = new Arc(l2bottom.Center, l2bottom.Radius + 8, l2bottom.AngleInRadians);
l2top.Rotate(Utility.DegToRad(60), Vector3D.AxisZ, l2bottom.Center);
Arc racctop1 = (Arc) UtilityEx.GetCirclesTangentToTwoCircles(l1bottom, c1, 8, true)[2];
Arc racctop2 = (Arc)UtilityEx.GetCirclesTangentToTwoCircles(l1bottom, c2, 8, true)[2];
l1bottom.TrimBy(racctop1.StartPoint, false);
l1bottom.TrimBy(racctop2.StartPoint, true);
Arc raccbottom1 = (Arc)UtilityEx.GetCirclesTangentToTwoCircles(l2top, c1, 8, true)[0];
Arc raccbottom2 = (Arc)UtilityEx.GetCirclesTangentToTwoCircles(l2top, c2, 8, true)[0];
l2top.TrimBy(raccbottom1.StartPoint,false);
l2top.TrimBy(raccbottom2.StartPoint, true);
Brep ext1 = creg1.ExtrudeAsBrep(20);
model1.Backface.ColorMethod = backfaceColorMethodType.SingleColor;
Arc raccraccleft = (Arc)UtilityEx.GetCirclesTangentToTwoCircles(racctop1,raccbottom1,30,true)[0];
Arc raccraccright = (Arc)UtilityEx.GetCirclesTangentToTwoCircles(racctop2, raccbottom2, 21, true)[0];
CompositeCurve cc1 = new CompositeCurve(
l1top,
new Line(l1top.StartPoint,c1.Center),
new Line(c1.Center, l2bottom.StartPoint),
l2bottom,
new Line(l2bottom.EndPoint, c2.Center),
new Line(c2.Center, l1top.EndPoint));
devDept.Eyeshot.Entities.Region cr1 = new devDept.Eyeshot.Entities.Region(cc1, Plane.XY);
ext1.ExtrudeAdd(cr1, new Interval(5, 15));
ext1.ExtrudeAdd(creg2,20);
devDept.Eyeshot.Entities.Region ec1 = devDept.Eyeshot.Entities.Region.CreateCircle(105, 0, 10);
ext1.ExtrudeRemove(ec1, new Interval(-20, 20));
Circle c3 = new Circle(new Point3D(0,0),15);
Line l1 = new Line(-4, 16.5, 4, 16.5);
Line l2 = new Line(-4, 0, -4, 16.5);
Line l3 = new Line(4, 0, 4, 16.5);
Point3D p2 = Curve.Intersection(c3,l2)[0];
Point3D p3 = Curve.Intersection(c3, l3)[0];
l2.StartPoint = p2;
l3.StartPoint = p3;
Arc a3 = new Arc(Plane.XY, new Point3D(0, 0), p2, p3);
CompositeCurve cc2 = new CompositeCurve(
l1,
l2,
l3,
a3);
devDept.Eyeshot.Entities.Region cr2 = new devDept.Eyeshot.Entities.Region(cc2, Plane.XY);
ext1.ExtrudeRemove(cr2, new Interval(-20, 20));
CompositeCurve cc3 = new CompositeCurve(
l1bottom,
racctop2,
raccraccright,
raccbottom2,
l2top,
raccbottom1,
raccraccleft,
racctop1);
devDept.Eyeshot.Entities.Region cr3 = new devDept.Eyeshot.Entities.Region(cc3, Plane.XY);
ext1.ExtrudeRemove(cr3, new Interval(-20, 20));
model1.Entities.Add(ext1, model1.Layers[0].Name, Color.OliveDrab);
//------------------------------DRAWINGS ENVIRONMENT------------------------------------------------
// Creating a new sheet
Sheet sheet1 = new Sheet(linearUnitsType.Millimeters, 220, 297, "Sheet 1");
// Getting the title block for A3 Iso standard format
BlockReference br = sheet1.BuildA4ISO(out Block a4Block, "A4_ISO");
// Initializing title block's attributes
br.Attributes["Title"] = new AttributeReference("My First Sheet");
br.Attributes["Format"] = new AttributeReference("A4");
br.Attributes["DwgNo"] = new AttributeReference("Root");
br.Attributes["Scale"] = new AttributeReference("SCALE: 1:2");
br.Attributes["Sheet"] = new AttributeReference("SHEET 1 OF 1");
// Adding the block related to the title block to the Blocks collection
drawings1.Blocks.Add(a4Block);
// Adding its reference to the sheet
sheet1.Entities.Add(br);
// Adding the sheet to the Sheets collection
drawings1.Sheets.Add(sheet1);
// Setitng the sheet as the active one
drawings1.ActiveSheet = sheet1;
// Refreshing the control
drawings1.Invalidate();
Point2D p1 = new Point2D(107.5, 87);
Point2D p4 = new Point2D(125, 232);
Point2D p5 = new Point2D(107.5, 160);
VectorView vectorViewT = new VectorView(p5.X, p5.Y, viewType.Top, .5, "Top Vector View")
{
HiddenSegments = true
};
VectorView vectorViewR = new VectorView(p1.X, p1.Y, viewType.Rear, .5, "Back Vector View")
{
HiddenSegments = true
};
RasterView rasterView = new RasterView(p4.X, p4.Y, viewType.Trimetric, .5, "Trimetric Raster View");
//Adding view's placeholders
sheet1.AddViewPlaceHolder(vectorViewT, model1, drawings1, "Top Vector View");
sheet1.AddViewPlaceHolder(vectorViewR, model1, drawings1, "Bottom Vector View");
sheet1.AddViewPlaceHolder(rasterView, model1, drawings1, "Trimetric Raster View");
//Setting up the layers
const string Dim = "Dim";
const string Text = "Text";
drawings1.Layers.Add(Dim);
drawings1.Layers[8].LineWeight = 0.2f;
drawings1.Layers[8].Color = Color.DarkBlue;
drawings1.Layers.Add(Text);
drawings1.Layers[9].LineWeight = 0.5f;
drawings1.Layers[9].Color = Color.Black;
//Text
Text t2 = new Text(0, 75, 0, "Top View", 8, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter);
drawings1.Blocks[2].Entities.Add(t2, Text);
Text t3 = new Text(0, 30, 0, "Back View", 8, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter);
drawings1.Blocks[3].Entities.Add(t3, Text);
//Adding Top View Dimensions to the scene
Point2D p0T = new Point3D(-10, -40);
Point2D p1T = new Point3D(10, -40);
drawings1.Blocks[3].Entities.Add(new LinearDim(new Plane(Point3D.Origin, Vector3D.AxisY, Vector3D.AxisMinusX), p0T, p1T, new Point3D(0, -100), 6), Dim);
drawings1.Blocks[2].Entities.Add(new LinearDim(Plane.XY, new Point3D(-52.5 + 4.5, -5.5), new Point3D(52.5 + 4.5, -5.5), new Point3D(0, -70), 6), Dim);
drawings1.Rebuild(model1);
AddRadiusesData(2);
private void AddRadiusesData(int block)
{
Random rnd = new Random();
Dictionary<int, int> radd = new Dictionary<int, int>();
for (int i = 0; i < drawings1.Blocks[block].Entities.Count; i++)
{
if (drawings1.Blocks[block].Entities[i] is Arc arc)
{
double startAngle = arc.Domain.Low;
double endAngle = arc.Domain.High;
double Finalangle = (startAngle + endAngle) / 2 + rnd.NextDouble() * arc.Radius / 100 * 5;
if (Finalangle < startAngle) Finalangle = startAngle;
else if (Finalangle > endAngle) Finalangle = endAngle;
if (!radd.ContainsKey(Convert.ToInt32(arc.Radius)))
{
radd[Convert.ToInt32(arc.Radius)] = Convert.ToInt32(arc.Radius);
drawings1.Blocks[block].Entities.Add(new RadialDim(arc, new Point3D(arc.Center.X + Math.Cos(Finalangle) * arc.Radius * 1.2, arc.Center.Y + Math.Sin(Finalangle) * arc.Radius * 1.2), 6)
{
ArrowsLocation = elementPositionType.Outside,
TrimLeader = true,
CenterMarkSize = 0
}, "Dim");
}
}
}
}

Comments
Please sign in to leave a comment.