# Modeling Practice Drawings 152

``````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 l2bottom = (Arc) UtilityEx.GetCirclesTangentToTwoCircles(c1, c2, 60, true)[1];
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);

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));

//------------------------------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
// Adding its reference to the sheet
// Adding the sheet to the Sheets collection
// 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");

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[8].LineWeight = 0.2f;
drawings1.Layers[8].Color = Color.DarkBlue;
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);
Text t3 = new Text(0, 30, 0, "Back View", 8, devDept.Eyeshot.Entities.Text.alignmentType.MiddleCenter);

//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);

``````
``````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;
{
{
ArrowsLocation = elementPositionType.Outside,
CenterMarkSize = 0
}, "Dim");
}
}
}
}
``````