
string path = ""; // step files folder path
loadComponentsFiles(path);
addAxle();
addSpacer1();
addSpacer2();
addSpacer3();
addSupport();
addPulley();
//Displaying blocks
BlockReference br1 = new BlockReference("Axle");
BlockReference br2 = new BlockReference(134, 0, 0, "Pulley", 1, 1, 1, Math.PI / 2);
BlockReference br3 = new BlockReference(24, 0, -30, "Support", Math.PI / 2);
BlockReference br4 = new BlockReference(144, 0, -30, "Support", Math.PI / 2);
BlockReference br5 = new BlockReference(19, 0, 0, "washer", -Math.PI / 2);
BlockReference br6 = new BlockReference(154, 0, 0, "washer", Math.PI / 2);
br5.Rotate(-Math.PI / 2, Vector3D.AxisY, new Point3D(19, 0, 0));
br6.Rotate(-Math.PI / 2, Vector3D.AxisY, new Point3D(154, 0, 0));
BlockReference br7 = new BlockReference(2, 0, 0, "nut", 0);
BlockReference br8 = new BlockReference(154, 0, 0, "nut", 0);
design1.Entities.Add(br1);
design1.Entities.Add(br2);
design1.Entities.Add(br3);
design1.Entities.Add(br4);
design1.Entities.Add(br5);
design1.Entities.Add(br6);
design1.Entities.Add(br7);
design1.Entities.Add(br8);
design1.Units = linearUnitsType.Millimeters;
private void loadComponentsFiles(string path)
{
ReadSTEP rs = new ReadSTEP(path + "6007N.stp");
rs.DoWork();
var rootBlock = rs.Blocks[rs.Blocks.RootBlockName];
rootBlock.Name = "Bearing";
for (int i = 0; i < rs.Blocks.Count; i++)
{
rs.Blocks[i].Entities[0].Color = Color.FloralWhite;
rs.Blocks[i].Entities[0].ColorMethod = colorMethodType.byEntity;
rs.Blocks[i].Units = linearUnitsType.Millimeters;
}
rs.FillBlocks(design1, false, null, false);
rs = new ReadSTEP(path + "uni_1751_24-5.stp");
rs.DoWork();
Block b2 = new Block("Washer", linearUnitsType.Millimeters);
b2.Entities.Add(rs.Blocks[0].Entities[0]);
design1.Blocks.Add(b2);
rs = new ReadSTEP(path + "UNI7662.stp");
rs.DoWork();
Block b3 = new Block("Grease", linearUnitsType.Millimeters);
b3.Entities.Add(rs.Blocks[0].Entities[0]);
design1.Blocks.Add(b3);
rs = new ReadSTEP(path + "6460324.stp");
rs.DoWork();
Block b4 = new Block("Nut", linearUnitsType.Millimeters);
b4.Entities.Add(rs.Blocks[0].Entities[0]);
design1.Blocks.Add(b4);
rs = new ReadSTEP(path + "TRA500400-4N01140x55.stp");
rs.DoWork();
rootBlock = rs.Blocks[rs.Blocks.RootBlockName];
rootBlock.Name = "Seal1";
for (int i = 0; i < rs.Blocks.Count; i++)
{
rs.Blocks[i].Units = linearUnitsType.Millimeters;
}
rs.FillBlocks(design1, false, null, false);
rs = new ReadSTEP(path + "TRAMGA013-4N01140x62.stp");
rs.DoWork();
rootBlock = rs.Blocks[rs.Blocks.RootBlockName];
rootBlock.Name = "Seal2";
for (int i = 0; i < rs.Blocks.Count; i++)
{
rs.Blocks[i].Units = linearUnitsType.Millimeters;
}
rs.FillBlocks(design1, false, null, false);
}
private void addPulley()
{
double h = 17 * Math.Tan(Utility.DegToRad(17)), h2 = h = 24 * Math.Tan(Utility.DegToRad(17));
Line l1 = new Line(107, 100, 75, 100);
Line l2 = new Line(77, 100, 77, 70);
Line l3 = new Line(77, 74, 40, 74);
Line l4 = new Line(40, 100, 40, 70);
Line l5 = new Line(40, 100, 27.5, 100);
l2.Rotate(Utility.DegToRad(-5), Vector3D.AxisZ, new Point3D(77, 100));
l4.Rotate(Utility.DegToRad(5), Vector3D.AxisZ, new Point3D(40, 100));
Arc a1, a2, a3, a4;
Curve.Fillet(l1, l2, 3, false, false, true, true, out a1);
Curve.Fillet(l2, l3, 10, false, false, true, true, out a2);
Curve.Fillet(l3, l4, 10, true, false, true, true, out a3);
Curve.Fillet(l4, l5, 3, false, true, true, true, out a4);
CompositeCurve cc1 = new CompositeCurve(
new Arc(new Point3D(32, 1), 1, Math.PI, Math.PI * 3 / 2),
new Line(32, 0, 73, 0),
new Line(73, 0, 73, 4.5),
new Line(73, 4.5, 56, 4.5 + h),
new Line(56, 4.5 + h, 56, 21.5 - h),
new Line(56, 21.5 - h, 73, 21.5),
new Line(73, 21.5, 73, 24.5),
new Line(73, 24.5, 56, 24.5 + h),
new Line(56, 24.5 + h, 56, 41.5 - h),
new Line(56, 41.5 - h, 73, 41.5),
new Line(73, 41.5, 73, 44.5),
new Line(73, 44.5, 56, 44.5 + h),
new Line(56, 44.5 + h, 56, 61.5 - h),
new Line(56, 61.5 - h, 73, 61.5),
new Line(73, 61.5, 73, 63),
new Arc(new Point3D(76, 63), 3, Math.PI / 2, Math.PI),
new Line(76, 66, 107, 66),
new Line(107, 66, 107, 72),
new Line(107, 72, 83, 72 + h2),
new Line(83, 72 + h2, 83, 94 - h2),
new Line(83, 94 - h2, 107, 94),
new Line(107, 94, 107, 100),
l1, a1, l2, a2, l3, a3, l4, a4, l5,
new Line(27.5, 100, 27.5, 85),
new Line(27.5, 85, 30, 85),
new Arc(new Point3D(30, 84), 1, Math.PI / 2),
new Line(31, 84, 31, 65),
new Line(31, 65, 31.25, 65),
new Line(31.25, 65, 31.25, 35),
new Line(31.25, 35, 31, 35),
new Line(31, 35, 31, 15),
new Line(31, 15, 32.5, 15),
new Line(32.5, 15, 32.5, 12.85),
new Line(32.5, 12.85, 31, 12.85),
new Line(31, 12.85, 31, 1)
);
devDept.Eyeshot.Entities.Region reg1 = new devDept.Eyeshot.Entities.Region(cc1);
Block b1 = new Block("Pulley", linearUnitsType.Millimeters);
b1.Entities.Add(reg1.RevolveAsBrep(Math.PI * 2, Vector3D.AxisY, Point3D.Origin));
b1.Entities[0].Color = Color.LightGray;
b1.Entities[0].ColorMethod = colorMethodType.byEntity;
design1.Blocks.Add(b1);
}
private void addSpacer1()
{
devDept.Eyeshot.Entities.Region reg1 =
new devDept.Eyeshot.Entities.Region(new Circle(Plane.XY, 31), new Circle(Plane.XY, 27));
Block b1 = new Block("Spacer1", linearUnitsType.Millimeters);
b1.Entities.Add(reg1.ExtrudeAsBrep(42));
b1.Entities[0].Color = Color.White;
b1.Entities[0].ColorMethod = colorMethodType.byEntity;
design1.Blocks.Add(b1);
}
private void addSpacer2()
{
devDept.Eyeshot.Entities.Region reg1 =
new devDept.Eyeshot.Entities.Region(new Circle(Plane.XY, 20), new Circle(Plane.XY, 17.5));
Block b1 = new Block("Spacer2", linearUnitsType.Millimeters);
b1.Entities.Add(reg1.ExtrudeAsBrep(20));
b1.Entities[0].Color = Color.White;
b1.Entities[0].ColorMethod = colorMethodType.byEntity;
design1.Blocks.Add(b1);
}
private void addSpacer3()
{
devDept.Eyeshot.Entities.Region reg1 = new devDept.Eyeshot.Entities.Region(new CompositeCurve(
new Line(20.5, 0, -21, 20.5, 0, 21),
new Line(20.5, 0, 21, 17.5, 0, 21),
new Line(17.5, 0, 21, 17.5, 0, 6),
new Arc(Plane.XZ, new Point3D(17.5, 0, 5), 1, Math.PI / 2),
new Line(18.5, 0, 5, 18.5, 0, -5),
new Arc(Plane.XZ, new Point3D(17.5, 0, -5), 1, Math.PI * 3 / 2, Math.PI * 2),
new Line(17.5, 0, -6, 17.5, 0, -21),
new Line(17.5, 0, -21, 20.5, 0, -21)
));
Brep rev1 = reg1.RevolveAsBrep(Math.PI * 2, Vector3D.AxisZ, Point3D.Origin);
devDept.Eyeshot.Entities.Region reg2 = devDept.Eyeshot.Entities.Region.CreateCircle(Plane.XZ, 2.25);
reg2.Translate(0, -22, 0);
rev1.ExtrudeRemove(reg2, -50);
reg2.Rotate(Math.PI / 2, Vector3D.AxisZ, Point3D.Origin);
rev1.ExtrudeRemove(reg2, -50);
rev1.Color = Color.White;
rev1.ColorMethod = colorMethodType.byEntity;
Block b1 = new Block("Spacer3", linearUnitsType.Millimeters);
b1.Entities.Add(rev1);
design1.Blocks.Add(b1);
}
private void addSupport()
{
Mirror m = new Mirror(Plane.YZ);
Arc a1 = new Arc(Plane.XZ, new Point2D(0, 30), 30, Utility.DegToRad(270), Utility.DegToRad(360));
Arc a2;
Line l1 = UtilityEx.GetLinesTangentToCircleFromPoint(a1, new Point3D(80, 0, 110))[1];
Line l2 = new Line(80, 0, 110, 80, 0, 160);
Curve.Trim(a1, l1, false, false);
Curve.Fillet(l1, l2, 30, false, true, true, true, out a2);
CompositeCurve cc1 = new CompositeCurve(
a1, l1, a2, l2,
new Line(80, 0, 160, 50, 0, 160),
new Line(50, 0, 160, 50, 0, 125),
new Arc(Plane.XZ, new Point2D(40, 125), 10, Math.PI * 3 / 2, Math.PI * 2),
new Line(40, 0, 115, 0, 0, 115),
new Line(0, 0, 115, 0, 0, 0)
);
devDept.Eyeshot.Entities.Region reg1 = new devDept.Eyeshot.Entities.Region(cc1);
devDept.Eyeshot.Entities.Region reg2 = (devDept.Eyeshot.Entities.Region)reg1.Clone();
reg2.TransformBy(m);
reg1 = devDept.Eyeshot.Entities.Region.Union(reg1, reg2)[0];
reg1 = devDept.Eyeshot.Entities.Region.Difference(reg1,
devDept.Eyeshot.Entities.Region.CreateCircle(Plane.XZ, new Point2D(0, 30), 14))[0];
reg1.Translate(0, 5, 0);
Brep ext1 = reg1.ExtrudeAsBrep(10);
CompositeCurve cc2 = new CompositeCurve(
new Line(-11, -30, 11, -30),
new Arc(Plane.XY, new Point2D(11, -26), 4, Math.PI * 3 / 2, Math.PI * 2),
new Line(15, -26, 15, 26),
new Arc(Plane.XY, new Point2D(11, 26), 4, 0, Math.PI / 2),
new Line(11, 30, -11, 30),
new Arc(Plane.XY, new Point2D(-11, 26), 4, Math.PI / 2, Math.PI),
new Line(-15, 26, -15, -26),
new Arc(Plane.XY, new Point2D(-11, -26), 4, Math.PI, Math.PI * 3 / 2)
);
devDept.Eyeshot.Entities.Region reg3 = new devDept.Eyeshot.Entities.Region(cc2,
new Circle(Plane.XY, new Point2D(0, 20), 4.5), new Circle(Plane.XY, new Point2D(0, -20), 4.5));
reg3.Translate(-65, 0, 150);
ext1.ExtrudeAdd(reg3, 10);
reg3.Translate(130, 0, 0);
ext1.ExtrudeAdd(reg3, 10);
ext1.Color = Color.LightBlue;
ext1.ColorMethod = colorMethodType.byEntity;
Block b1 = new Block("Support", linearUnitsType.Millimeters);
b1.Entities.Add(ext1);
design1.Blocks.Add(b1);
}
private void addShaft()
{
devDept.Eyeshot.Entities.Region reg1 = devDept.Eyeshot.Entities.Region.CreatePolygon(
new Point2D(167, 0),
new Point2D(167, 9),
new Point2D(164, 12),
new Point2D(146.5, 12),
new Point2D(146.5, 14),
new Point2D(138.5, 14),
new Point2D(138.5, 17.5),
new Point2D(99, 17.5),
new Point2D(99, 17),
new Point2D(69, 17),
new Point2D(69, 17.5),
new Point2D(49, 17.5),
new Point2D(49, 20),
new Point2D(29, 20),
new Point2D(29, 14),
new Point2D(21, 14),
new Point2D(21, 12),
new Point2D(1.5, 12),
new Point2D(0, 10.5),
new Point2D(0, 5),
new Point2D(11, 5),
new Point2D(11, 4),
new Point2D(90, 4),
new Point2D(90 + 8 * Math.Tan(Utility.DegToRad(15)), 0)
);
Brep rev1 = reg1.RevolveAsBrep(Math.PI * 2, Vector3D.AxisX, Point3D.Origin);
devDept.Eyeshot.Entities.Region reg2 =
devDept.Eyeshot.Entities.Region.CreateCircle(Plane.XY, new Point2D(84, 0), 2.5);
reg2.Translate(0, 0, 20);
rev1.ExtrudeRemove(reg2, -60);
Block b1 = new Block("Shaft", linearUnitsType.Millimeters);
rev1.Color = Color.Gray;
rev1.ColorMethod = colorMethodType.byEntity;
b1.Entities.Add(rev1);
design1.Blocks.Add(b1);
}
private void addAxle()
{
addShaft();
BlockReference br1 = new BlockReference("Shaft");
BlockReference br2 = new BlockReference(105, 0, 0, "Spacer1", 0);
br2.Rotate(-Math.PI / 2, Vector3D.AxisY, new Point3D(105, 0, 0));
BlockReference br3 = new BlockReference(139, 0, 0, "Spacer2", 0);
br3.Rotate(-Math.PI / 2, Vector3D.AxisY, new Point3D(139, 0, 0));
BlockReference br4 = new BlockReference(84, 0, 0, "Spacer3", 0);
br4.Rotate(-Math.PI / 2, Vector3D.AxisY, new Point3D(84, 0, 0));
BlockReference br5 = new BlockReference(49, 0, 0, "Bearing", 0);
BlockReference br6 = new BlockReference(105, 0, 0, "Bearing", 0);
BlockReference br7 = new BlockReference(7, 0, 0, "Grease", Math.PI / 2);
BlockReference br8 = new BlockReference(34, 0, 0, "Seal1", 0);
BlockReference br9 = new BlockReference(134, 0, 0, "Seal2", Math.PI);
Block b1 = new Block("Axle", linearUnitsType.Millimeters);
b1.Entities.Add(br1);
b1.Entities.Add(br2);
b1.Entities.Add(br3);
b1.Entities.Add(br4);
b1.Entities.Add(br5);
b1.Entities.Add(br6);
b1.Entities.Add(br7);
b1.Entities.Add(br8);
b1.Entities.Add(br9);
design1.Blocks.Add(b1);
}
Comments
Please sign in to leave a comment.