static CsgObject OnOffArm() { CsgObject total; CsgObject mainBar = new Box(wallWidth * 1.5, 37, 2.5); total = mainBar; CsgObject magnetAttractorHole = new Cylinder(magnetAttractorHoleRadius / 2, mainBar.ZSize + .1, Alignment.z); magnetAttractorHole = new SetCenter(magnetAttractorHole, mainBar.GetCenter() + new Vector3(0, -magnetAttractorHoleRadius, 0)); CsgObject magnetAttractorHole2 = new Cylinder(magnetAttractorHoleRadius / 2, mainBar.ZSize + .1, Alignment.z); magnetAttractorHole2 = new SetCenter(magnetAttractorHole2, mainBar.GetCenter() + new Vector3(0, magnetAttractorHoleRadius, 0)); CsgObject bothHoles = magnetAttractorHole + magnetAttractorHole2; bothHoles = new Align(bothHoles, Face.Front, mainBar, Face.Front, offsetY: magnetAttractorHoleRadius); total -= bothHoles; CsgObject sideSupportBar = new Box(3, mainBar.YSize, mainBar.ZSize * 2); sideSupportBar = new Align(sideSupportBar, Face.Left | Face.Bottom, mainBar, Face.Right | Face.Bottom, -.02); total += sideSupportBar; CsgObject pressSpot = new Box(total.XSize, 5, total.ZSize); pressSpot = new Align(pressSpot, Face.Left | Face.Back | Face.Bottom, total, Face.Left | Face.Back | Face.Bottom); total += pressSpot; return(total); }
public static CsgObject PutOnPlatformAndCenter(CsgObject part, Vector3 rotation = new Vector3()) { part = new Rotate(part, rotation); part = new SetCenter(part, new Vector3()); part = new Align(part, Face.Bottom, offsetZ: 0); return(part); }
static CsgObject DialGaugeMount() { // CSG object is a Constructive Solid Geometry Object (a basic part in our system for doing boolean operations). CsgObject dialGauge; // the csg object we will use as the master part. CsgObject frontBarRide = new Box(50, xCarriageBarWidth + 4, xCarriageBarWidth / 2 + 4); CsgObject barGroove = new Cylinder(xCarriageBarWidth / 2, frontBarRide.XSize + .2, Alignment.x); barGroove = new Translate(barGroove, 0, 0, -barGroove.ZSize / 2); frontBarRide -= barGroove; dialGauge = frontBarRide; CsgObject backBarRide = frontBarRide.NewMirrorAccrossY(); backBarRide = new Translate(backBarRide, 0, xCarriageSeparation, 0); dialGauge += backBarRide; CsgObject frontSideWall = new Box(frontBarRide.XSize, wallWidth, wallHeight); frontSideWall = new Align(frontSideWall, Face.Front | Face.Top, frontBarRide, Face.Back | Face.Top, offsetY: -.02); // offset it to ensure good stl geometry dialGauge += frontSideWall; CsgObject backSideWall = new Box(frontBarRide.XSize, wallWidth, wallHeight); backSideWall = new Align(backSideWall, Face.Back | Face.Top, backBarRide, Face.Front | Face.Top, offsetY: .02); // offset it to ensure good stl geometry dialGauge += backSideWall; // make the plate on the bottom double distanceAccrossBottom = backSideWall.GetAxisAlignedBoundingBox().minXYZ.y - frontSideWall.GetAxisAlignedBoundingBox().maxXYZ.y; CsgObject dialBase = new Box(frontBarRide.XSize, distanceAccrossBottom + .02, wallWidth); // make it bigger so it is manifold dialBase = new Align(dialBase, Face.Front | Face.Bottom, frontSideWall, Face.Back | Face.Bottom, offsetY: .01); dialGauge += dialBase; // an some side walls for strength CsgObject leftSideWall = new Box(wallWidth, dialBase.YSize, frontSideWall.ZSize, "#leftsidewall"); leftSideWall = new Align(leftSideWall, Face.Left | Face.Bottom | Face.Front, dialBase, Face.Left | Face.Bottom | Face.Front); dialGauge += leftSideWall; CsgObject rightSideWall = new Box(wallWidth, dialBase.YSize, frontSideWall.ZSize, "#rightsidewall"); rightSideWall = new Align(rightSideWall, Face.Right | Face.Bottom | Face.Front, dialBase, Face.Right | Face.Bottom | Face.Front); dialGauge += rightSideWall; CsgObject dialGaugeHole = new Cylinder(diameterOfDialGaugeBar / 2, dialBase.ZSize + .02, Alignment.z); dialGaugeHole = new SetCenter(dialGaugeHole, dialBase.GetCenter() + new Vector3(0, dialGaugeBarOffsetFromCenter, 0)); dialGauge -= dialGaugeHole; CsgObject bridgeSupport = new Box(dialBase.XSize, dialBase.YSize, .5, "#test"); bridgeSupport = new SetCenter(bridgeSupport, dialBase.GetCenter()); bridgeSupport = new Align(bridgeSupport, Face.Top, dialBase, Face.Top); dialGauge += bridgeSupport; return(dialGauge); }
static public CsgObject LinearNewBearing8UUZipTieRemove(Vector3 bearingCenter) { double zipTieSizeX = 6; CsgObject zipTieRemoveRing = new Cylinder(LinearBearing8UUDiameter / 2 + linearBearing8UUEnclosureExtraDiameter / 2 + zipTieSizeZ, zipTieSizeX); CsgObject ringRemove = new Cylinder(LinearBearing8UUDiameter / 2 + linearBearing8UUEnclosureExtraDiameter / 2, zipTieSizeX + .1); zipTieRemoveRing = new Difference(zipTieRemoveRing, ringRemove); zipTieRemoveRing = new SetCenter(zipTieRemoveRing, bearingCenter); return(zipTieRemoveRing); }
static public CsgObject LinearBearing8UUHolder(Alignment alignment, double extraAtEachEndZ = 4, double extraHeight = 0) { double holdDiameterReduction = -2.5; double totalXSize = LinearBearing8UUDiameter + linearBearing8UUEnclosureExtraDiameter; double totalYSize = LinearBearing8UUDiameter / 2 + linearBearing8UUEnclosureExtraDiameter / 2 + zipTieSizeZ + extraHeight; double totalHeight = LinearBearing8UUHeight + extraAtEachEndZ * 2; double extraOverBearing = 2; CsgObject enclosure = new Box(totalXSize, totalYSize + extraOverBearing, totalHeight, createCentered: false, name: "Enclosure"); CsgObject root = enclosure; Vector3 bearingCenter = enclosure.GetCenter() + new Vector3(0, totalYSize / 2 - extraOverBearing / 2, 0); CsgObject bearingRemove = new Cylinder(LinearBearing8UUDiameter / 2 + .25, LinearBearing8UUHeight + .5); bearingRemove = new SetCenter(bearingRemove, bearingCenter); root -= bearingRemove; CsgObject rodeRemove = new Cylinder(LinearBearing8UUDiameter / 2 + holdDiameterReduction / 2, totalHeight + .1); rodeRemove = new SetCenter(rodeRemove, bearingCenter); root = new Difference(root, rodeRemove); //root = new Difference(root, LinearNewBearing8UUZipTieRemove(bearingCenter)); #if false ObjectCSG groovGrip1 = new Cylinder(LinearBearing8UUDiameter / 2 + .5, .75); groovGrip1 = new SetCenter(groovGrip1, bearingCenter + new Vector3(0, 0, 17 / 2 - groovGrip1.ZSize / 2)); groovGrip1 = new Intersection(groovGrip1, enclosure); groovGrip1 -= new SetCenter(new Cylinder(LinearBearing8UUDiameter / 2 - .5, LinearBearing8UUHeight), bearingCenter); root += groovGrip1; ObjectCSG groovGrip2 = new Cylinder(LinearBearing8UUDiameter / 2 + .5, .75); groovGrip2 = new SetCenter(groovGrip2, bearingCenter - new Vector3(0, 0, 17 / 2 - groovGrip2.ZSize / 2)); groovGrip2 = new Intersection(groovGrip2, enclosure); groovGrip2 -= new SetCenter(new Cylinder(LinearBearing8UUDiameter / 2 - .5, LinearBearing8UUHeight), bearingCenter); root += groovGrip2; #endif switch (alignment) { case Alignment.x: root = new Rotate(root, x: MathHelper.Tau / 4, z: MathHelper.Tau / 4); break; case Alignment.y: root = new Rotate(root, x: MathHelper.Tau / 4); break; } return(root); }
static CsgObject StepArm() { CsgObject totalMount; // the csg object we will use as the master part. CsgObject pivotHole = new Cylinder(pivotHoleRadius / 2, pivotHeight + .1); CsgObject pivotMount = new Cylinder(pivotRingRadius / 2, pivotHeight); pivotMount = new Align(pivotMount, Face.Bottom, pivotHole, Face.Bottom, offsetZ: .02); totalMount = pivotMount; CsgObject holdArm = new Box(armLength, pivotRingRadius, wallWidth); holdArm = new Align(holdArm, Face.Left | Face.Front | Face.Bottom, pivotMount, Face.Left | Face.Front | Face.Bottom, offsetX: pivotRingRadius / 2); totalMount += holdArm; CsgObject bracingWall = new Box(wallWidth, wallWidth, pivotMount.ZSize - wallWidth); bracingWall = new SetCenter(bracingWall, holdArm.GetCenter()); bracingWall = new Align(bracingWall, Face.Right | Face.Top, pivotMount, Face.Right | Face.Top); totalMount += bracingWall; CsgObject bracingArm = new Box(armLength, wallWidth, wallWidth); bracingArm = new SetCenter(bracingArm, holdArm.GetCenter()); bracingArm = new Align(bracingArm, Face.Bottom | Face.Left, holdArm, Face.Top | Face.Left, offsetZ: -.1); totalMount += bracingArm; totalMount += Round.CreateFillet(bracingWall, Face.Right, bracingArm, Face.Top, 3); //totalMount += Round.CreateFillet(bracingArm, Face.Right, holdArm, Face.Top, wallWidth); double toothSelectorSize = 4; double diagonalSize = Math.Sqrt(toothSelectorSize * toothSelectorSize / 2); CsgObject toothSelectorBack = new Box(diagonalSize * 2, diagonalSize * 2, wallWidth * 2); toothSelectorBack = new Align(toothSelectorBack, Face.Right | Face.Front | Face.Bottom, totalMount, Face.Right | Face.Front | Face.Bottom); totalMount += toothSelectorBack; CsgObject toothSelector = new Box(toothSelectorSize, toothSelectorSize, wallWidth * 2); toothSelector = new Rotate(toothSelector, 0, 0, MathHelper.Tau / 8); toothSelector = new Align(toothSelector, Face.Right | Face.Front | Face.Bottom, totalMount, Face.Right | Face.Front | Face.Bottom, offsetY: -diagonalSize); totalMount += toothSelector; totalMount -= pivotHole; return(totalMount); }
public static CsgObject CreateFillet(CsgObject objectA, Face faceA, CsgObject objectB, Face faceB, double radius, double extraDimension = defaultExtraDimension) { int centralAxis = 0; // we start defaulted to x switch ((Edge)(faceA | faceB)) { case Edge.LeftTop: case Edge.LeftBottom: case Edge.RightTop: case Edge.RightBottom: centralAxis = 1; // y axis break; case Edge.LeftFront: case Edge.LeftBack: case Edge.RightFront: case Edge.RightBack: centralAxis = 2; // z axis break; } AxisAlignedBoundingBox boundsA = objectA.GetAxisAlignedBoundingBox(); AxisAlignedBoundingBox boundsB = objectB.GetAxisAlignedBoundingBox(); double maxMin = Math.Max(boundsA.minXYZ[centralAxis], boundsB.minXYZ[centralAxis]); double minMax = Math.Min(boundsA.maxXYZ[centralAxis], boundsB.maxXYZ[centralAxis]); if (maxMin >= minMax) { throw new ArgumentException("Your two objects must overlap to have a fillet be created."); } Vector3 size = new Vector3(radius, radius, radius); size[centralAxis] = minMax - maxMin; Round newFilletRound = new Round(size); Face faceToGetBevelFor = CsgObject.GetOposite(faceA) | CsgObject.GetOposite(faceB); newFilletRound.RoundEdge((Edge)faceToGetBevelFor, radius, extraDimension); CsgObject newFillet = new SetCenter(newFilletRound, objectA.GetCenter()); newFillet = new Align(newFillet, CsgObject.GetOposite(faceA), objectA, faceA); newFillet = new Align(newFillet, CsgObject.GetOposite(faceB), objectB, faceB); return(newFillet); }
private static Union DoItWithSubdivision() { //int howManyAxes = _rand.Next(3); Union u = new Union(); Array axes = Enum.GetValues(typeof(Axes)); Axes whichOne = (Axes)axes.GetValue(_rand.Next(axes.Length)); double[][] axisValues = new double[3][]; axisValues[0] = GimmeRandomDoubles(_rand.Next(15), _xMax); axisValues[1] = GimmeRandomDoubles(_rand.Next(15), _yMax); axisValues[2] = GimmeRandomDoubles(_rand.Next(15), _zMax); switch (whichOne) { case Axes.X: int xPoints = _rand.Next(50); axisValues[0] = Subdivide(_xMax, xPoints); break; case Axes.Y: int yPoints = _rand.Next(50); axisValues[1] = Subdivide(_yMax, yPoints); break; case Axes.Z: int zPoints = _rand.Next(50); axisValues[2] = Subdivide(_yMax, zPoints); break; default: break; } for (int i = 0; i < axisValues[0].Length; i++) { for (int j = 0; j < axisValues[1].Length; j++) { for (int k = 0; k < axisValues[2].Length; k++) { CsgObject newPrimitive = GimmeAPrimitive(); Vector3 translate = new Vector3(axisValues[0][i], axisValues[1][j], axisValues[2][k]); newPrimitive = new SetCenter(newPrimitive, translate); u = new Union(u, newPrimitive); } } } return(u); }
public void TopIsSolid() { int sides = 3; CsgObject keep = new Cylinder(20, 20, sides); var keepMesh = CsgToMesh.Convert(keep, true); CsgObject subtract = new Cylinder(10, 21, sides); subtract = new SetCenter(subtract, keep.GetCenter()); var subtractMesh = CsgToMesh.Convert(subtract, true); CsgObject result = keep - subtract; var resultMesh = CsgToMesh.Convert(result, true); Assert.AreEqual(0, keepMesh.GetNonManifoldEdges().Count, "All faces should be 2 manifold"); Assert.AreEqual(0, subtractMesh.GetNonManifoldEdges().Count, "All faces should be 2 manifold"); //Assert.AreEqual(0, resultMesh.GetNonManifoldEdges().Count, "All faces of this subtract should be 2 manifold"); }
public static CsgObject SimplePartFunction() { CsgObject total; CsgObject bar = new Box(20, 5.8, 12, "link"); bar = new SetCenter(bar, Vector3.Zero); total = bar; CsgObject leftHold = new Cylinder(11.7 / 2, 12, Alignment.z); leftHold = new SetCenter(leftHold, bar.GetCenter() + new Vector3(12, 0, 0)); CsgObject rightHold = leftHold.NewMirrorAccrossX(); total += leftHold; total += rightHold; return(total); }
CsgObject TrainConnector() { CsgObject total; CsgObject bar = new Box(20, 5.8, 12, createCentered: false, name: "link"); bar = new SetCenter(bar, Vector3.Zero); total = bar; CsgObject leftHold = new Cylinder(11.7 / 2, 12, Alignment.z); leftHold = new SetCenter(leftHold, bar.GetCenter() + new Vector3(12, 0, 0)); CsgObject rightHold = leftHold.NewMirrorAccrossX(); total += leftHold; total += rightHold; return(total); }
private static CsgObject GimmeAPrimitive(double size, Vector3 center) { CsgObject newPrimitive = null; //primitive type int type = _rand.Next(4); double height = GimmeABoundedDouble(size * 0.1, size * 2.0); switch (type) { case 0: //cube newPrimitive = new Box(size, size, size); break; case 1: //sphere newPrimitive = new Sphere(size); break; case 2: //cone newPrimitive = new Cylinder(size, 0, height); break; case 3: //cylinder newPrimitive = new Cylinder(size, height); break; case 4: //rectangular solid double depth = GimmeABoundedDouble(size * 0.1, size * 2.0); double width = GimmeABoundedDouble(size * 0.1, size * 2.0); newPrimitive = new Box(width, depth, size); break; default: newPrimitive = new Box(size, size, size); break; } newPrimitive = new SetCenter(newPrimitive, center); return(newPrimitive); }
static CsgObject SpoolBarHolderM90() { CsgObject total; CsgObject centerSupport = new Box(mendal90FrameWidth + wallWidth * 2, clipLengthY, wallWidth); total = centerSupport; CsgObject clipWallLeft = new Box(wallWidth, clipLengthY, clipReachZDown); clipWallLeft = new Align(clipWallLeft, Face.Left | Face.Top, centerSupport, Face.Left | Face.Top); CsgObject attachHole = new Cylinder(attacheHoleDiameter / 2, wallWidth + .2, Alignment.x); attachHole = new Align(attachHole, Face.Top, centerSupport, Face.Bottom, offsetZ: -attachHoleOffsetZ); attachHole = new SetCenter(attachHole, clipWallLeft.GetCenter(), onY: false, onZ: false); clipWallLeft -= attachHole; total += clipWallLeft; CsgObject clipWallRight = clipWallLeft.NewMirrorAccrossX(); total += clipWallRight; Box spoolHoldBox = new Box(wallWidth, rodDiameter * 3, clipReachZUp); //spoolHoldBox.BevelEdge(Face.Front | Face.Top, rodDiameter/2); //spoolHoldBox.BevelEdge(Face.Back | Face.Top, rodDiameter / 2); CsgObject spoolHold = spoolHoldBox; spoolHold -= new Align(new Cylinder(rodDiameter / 2, wallWidth + 2, Alignment.x), Face.Top, spoolHold, Face.Top); spoolHold -= new Align(new Box(wallWidth + 2, rodDiameter, rodDiameter / 2), Face.Top, spoolHold, Face.Top, offsetZ: .1); total += new Align(spoolHold, Face.Bottom, centerSupport, Face.Bottom); total += Round.CreateFillet(spoolHold, Face.Left, centerSupport, Face.Top, 2); total += Round.CreateFillet(spoolHold, Face.Right, centerSupport, Face.Top, 2); total -= Round.CreateBevel(centerSupport, Edge.LeftTop, 2); total -= Round.CreateBevel(centerSupport, Edge.RightTop, 2); return(total); }
static CsgObject Render() { // CSG object is a Constructive Solid Geometry Object (a basic part in our system for doing boolean operations). CsgObject totalMount; // the csg object we will use as the master part. CsgObject pivotHole = new Cylinder(pivotHoleRadius / 2, pivotHeight + .1); CsgObject pivotMount = new Cylinder(pivotRingRadius / 2, pivotHeight); pivotMount = new Align(pivotMount, Face.Bottom, pivotHole, Face.Bottom, offsetZ: .02); totalMount = pivotMount; CsgObject holdArm = new Box(armLength, wallWidth * 2, wallWidth); holdArm = new Align(holdArm, Face.Left | Face.Front | Face.Bottom, pivotMount, Face.Left | Face.Front | Face.Bottom, offsetX: pivotRingRadius / 2); totalMount += holdArm; CsgObject switchMount = new Box(switchHeight, switchWidth, wallWidth); switchMount -= new Translate(new Cylinder(switchHoleDiameter / 2, switchMount.ZSize + .1), new Vector3(0, switchHoleSeparation / 2, 0)); switchMount -= new Translate(new Cylinder(switchHoleDiameter / 2, switchMount.ZSize + .1), new Vector3(0, -switchHoleSeparation / 2, 0)); switchMount = new Align(switchMount, Face.Left | Face.Front | Face.Bottom, holdArm, Face.Right | Face.Front | Face.Bottom, offsetX: -.02, offsetY: -5); totalMount += switchMount; CsgObject magnetAttractor = new Box(wallWidth + magnetAttractorHoleRadius, magnetAttractorYSize, wallWidth * 3); // align it from the pivot point magnetAttractor = new Align(magnetAttractor, Face.Left | Face.Front | Face.Bottom, pivotMount, Face.Left | Face.Front | Face.Bottom, offsetX: magnetHoldOffset); totalMount += magnetAttractor; CsgObject bracingWall = new Box(wallWidth, wallWidth, pivotMount.ZSize - wallWidth); bracingWall = new SetCenter(bracingWall, holdArm.GetCenter()); bracingWall = new Align(bracingWall, Face.Right | Face.Top, pivotMount, Face.Right | Face.Top); totalMount += bracingWall; CsgObject bracingArm = new Box(armLength - wireClearence, wallWidth, wallWidth); bracingArm = new SetCenter(bracingArm, holdArm.GetCenter()); bracingArm = new Align(bracingArm, Face.Bottom | Face.Left, holdArm, Face.Top | Face.Left, offsetZ: -.1); totalMount += bracingArm; totalMount += Round.CreateFillet(bracingWall, Face.Right, bracingArm, Face.Top, 3); totalMount += Round.CreateFillet(bracingArm, Face.Right, holdArm, Face.Top, wallWidth); totalMount += Round.CreateFillet(holdArm, Face.Back, switchMount, Face.Left, wallWidth); totalMount += Round.CreateFillet(holdArm, Face.Front, switchMount, Face.Left, wallWidth); totalMount -= pivotHole; CsgObject magnetAttractorHole = new Cylinder(magnetAttractorHoleRadius / 2, magnetAttractor.YSize + .1, Alignment.y); magnetAttractorHole = new SetCenter(magnetAttractorHole, magnetAttractor.GetCenter() + new Vector3(0, 0, -magnetAttractorHoleRadius)); totalMount -= magnetAttractorHole; CsgObject magnetAttractorHole2 = new Cylinder(magnetAttractorHoleRadius / 2, magnetAttractor.YSize + .1, Alignment.y); magnetAttractorHole2 = new SetCenter(magnetAttractorHole2, magnetAttractor.GetCenter() + new Vector3(0, 0, magnetAttractorHoleRadius)); totalMount -= magnetAttractorHole2; return(totalMount); }
static CsgObject MountMount() { Vector3 magnetSize = new Vector3(10, 5, 2.5); CsgObject total; CsgObject baseBox = new Box(37, 26, wallWidth * 2); Round baseBevels = new Round(baseBox.Size); baseBevels.RoundEdge(Edge.LeftFront, 4); baseBevels.RoundEdge(Edge.LeftBack, 4); baseBox -= baseBevels; CsgObject fakeXCarriage = new Translate(baseBox, 0.5); total = fakeXCarriage; double pivotRingYOffset = -pivotHeight / 2 - wallWidth / 2 - .5; CsgObject pivotRingFront = new Cylinder(pivotRingRadius / 2, wallWidth, Alignment.y); CsgObject pivotFrontWall = new Box(pivotRingRadius, wallWidth, mountPivotHeight); pivotFrontWall = new Translate(pivotFrontWall, 0, 0, -mountPivotHeight / 2); CsgObject pivotSupportFront = pivotRingFront + pivotFrontWall; CsgObject pivotHole = new Cylinder(pivotHoleRadius / 2, pivotRingFront.YSize + .1, Alignment.y); pivotHole = new SetCenter(pivotHole, pivotRingFront.GetCenter()); pivotSupportFront -= pivotHole; pivotSupportFront = new Translate(pivotSupportFront, 0, pivotRingYOffset, mountPivotHeight); pivotSupportFront += Round.CreateFillet(pivotSupportFront, Face.Back, fakeXCarriage, Face.Top, 3); pivotSupportFront += Round.CreateFillet(pivotSupportFront, Face.Front, fakeXCarriage, Face.Top, 3); total += pivotSupportFront; CsgObject pivotSupportBack = pivotSupportFront.NewMirrorAccrossY(); total += pivotSupportBack; CsgObject backMagnetHolder = new Box(wallWidth * 2, magnetSize.x + wallWidth, backMagnetHeight); backMagnetHolder = new Align(backMagnetHolder, Face.Bottom | Face.Right, fakeXCarriage, Face.Top | Face.Right, 0, 0, -.1); CsgObject backMagnetHole = new Box(magnetSize.z, magnetSize.x, magnetSize.y); backMagnetHole = new SetCenter(backMagnetHole, backMagnetHolder.GetCenter()); backMagnetHole = new Align(backMagnetHole, Face.Left | Face.Top, backMagnetHolder, Face.Left | Face.Top, -.1, 0, -wallWidth / 2); total += Round.CreateFillet(backMagnetHolder, Face.Front, fakeXCarriage, Face.Top, 3); total += Round.CreateFillet(backMagnetHolder, Face.Back, fakeXCarriage, Face.Top, 3); total += Round.CreateFillet(backMagnetHolder, Face.Left, fakeXCarriage, Face.Top, 3); backMagnetHolder -= backMagnetHole; total += backMagnetHolder; CsgObject baseMagnetHolder = new Box(wallWidth * 2, magnetSize.x + wallWidth, baseMagnetHeight); baseMagnetHolder = new Align(baseMagnetHolder, Face.Bottom, fakeXCarriage, Face.Top, -14, 0, -.1); CsgObject baseMagnetHole = new Box(magnetSize.y, magnetSize.x, magnetSize.z); baseMagnetHole = new SetCenter(baseMagnetHole, baseMagnetHolder.GetCenter()); baseMagnetHole = new Align(baseMagnetHole, Face.Top, baseMagnetHolder, Face.Top, 0, 0, .1); baseMagnetHolder -= baseMagnetHole; total += baseMagnetHolder; return(total); }
public static CsgObject SimplePartFunction() { double pcbHoldLip = 2; double standYDepth = 8; double pcbYDepth = 2; CsgObject pcbTotal; CsgObject pcbBottom = new Box(23, pcbYDepth, 40); pcbTotal = pcbBottom; CsgObject pcbMid = new Box(30, pcbYDepth, 34.5); pcbMid = new Align(pcbMid, Face.Top, pcbBottom, Face.Top); pcbMid = new SetCenter(pcbMid, pcbBottom.GetCenter(), true, false, false); pcbTotal += pcbMid; CsgObject pcbTop = new Box(64.5, pcbYDepth, 21.5); pcbTop = new Align(pcbTop, Face.Top, pcbBottom, Face.Top); pcbTop = new SetCenter(pcbTop, pcbBottom.GetCenter(), true, false, false); pcbTotal += pcbTop; Box standBaseBox = new Box(pcbTop.XSize + 2 * (standYDepth - pcbHoldLip), 37, standYDepth); //standBaseBox.BevelFace(Face.Top, 3); //standBaseBox.BevelEdge(Face.Left | Face.Front, 3); //standBaseBox.BevelEdge(Face.Left | Face.Back, 3); //standBaseBox.BevelEdge(Face.Right | Face.Front, 3); //standBaseBox.BevelEdge(Face.Right | Face.Back, 3); CsgObject standBase = standBaseBox; CsgObject standTotal = standBase; Box standSideSupportLeftBox = new Box(standYDepth, standYDepth, pcbBottom.ZSize + standBase.ZSize - 10); //standSideSupportLeftBox.BevelEdge(Face.Left | Face.Front, 3); //standSideSupportLeftBox.BevelEdge(Face.Left | Face.Back, 3); //standSideSupportLeftBox.BevelEdge(Face.Left | Face.Top, 3); //standSideSupportLeftBox.BevelEdge(Face.Right | Face.Front, 1); //standSideSupportLeftBox.BevelEdge(Face.Right | Face.Back, 1); CsgObject standSideSupportLeft = standSideSupportLeftBox; standSideSupportLeft = new SetCenter(standSideSupportLeft, standBase.GetCenter(), false, true, false); standSideSupportLeft = new Align(standSideSupportLeft, Face.Bottom | Face.Left, standBase, Face.Bottom | Face.Left); standTotal += standSideSupportLeft; Box insideBevelLeftBox = new Box(standYDepth, standYDepth, standYDepth); insideBevelLeftBox.CutAlongDiagonal(Face.Left | Face.Bottom); CsgObject insideBevelLeft = insideBevelLeftBox; insideBevelLeft = new Align(insideBevelLeft, Face.Left | Face.Front, standSideSupportLeft, Face.Right | Face.Front, -1, 0, -.1); insideBevelLeft = new Align(insideBevelLeft, Face.Bottom, standBase, Face.Top); standTotal += insideBevelLeft; Box standSideSupportRightBox = new Box(standYDepth, standYDepth, pcbBottom.ZSize + standBase.ZSize - 10); //standSideSupportRightBox.BevelEdge(Face.Right | Face.Front, 3); //standSideSupportRightBox.BevelEdge(Face.Right | Face.Back, 3); //standSideSupportRightBox.BevelEdge(Face.Right | Face.Top, 3); //standSideSupportRightBox.BevelEdge(Face.Left | Face.Front, 1); //standSideSupportRightBox.BevelEdge(Face.Left | Face.Back, 1); CsgObject standSideSupportRight = standSideSupportRightBox; standSideSupportRight = new SetCenter(standSideSupportRight, standBase.GetCenter(), false, true, false); standSideSupportRight = new Align(standSideSupportRight, Face.Bottom | Face.Right, standBase, Face.Bottom | Face.Right); standTotal += standSideSupportRight; Box insideBevelRightBox = new Box(standYDepth, standYDepth, standYDepth); insideBevelRightBox.CutAlongDiagonal(Face.Right | Face.Bottom); CsgObject insideBevelRight = insideBevelRightBox; insideBevelRight = new Align(insideBevelRight, Face.Right | Face.Front, standSideSupportRight, Face.Left | Face.Front, 1, 0, -.1); insideBevelRight = new Align(insideBevelRight, Face.Bottom, standBase, Face.Top); standTotal += insideBevelRight; CsgObject ringCutOut = new Cylinder(11, 6, Alignment.y); ringCutOut = new SetCenter(ringCutOut, standBase.GetCenter()); ringCutOut = new Align(ringCutOut, Face.Bottom | Face.Back, standBase, Face.Top | Face.Front, 0, 5.9, -4); standTotal -= ringCutOut; pcbTotal = new SetCenter(pcbTotal, standBase.GetCenter(), true, true, false); pcbTotal = new Align(pcbTotal, Face.Bottom, standBase, Face.Top, offsetZ: -pcbHoldLip); standTotal -= pcbTotal; return(standTotal); }