From 55ec87b01702077e855c87e2309a3ee4e52afd40 Mon Sep 17 00:00:00 2001 From: Ryan Benasutti Date: Thu, 28 Dec 2017 14:19:38 -0500 Subject: [PATCH] Fix script file --- scripts/Cchannel.groovy | 21 +++++-- scripts/Cchannelscript.groovy | 108 ---------------------------------- 2 files changed, 16 insertions(+), 113 deletions(-) delete mode 100644 scripts/Cchannelscript.groovy diff --git a/scripts/Cchannel.groovy b/scripts/Cchannel.groovy index 351a6b8..85ecce4 100644 --- a/scripts/Cchannel.groovy +++ b/scripts/Cchannel.groovy @@ -1,13 +1,13 @@ import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; import eu.mihosoft.vrl.v3d.parametrics.*; -CSG getFlat() { +CSG getFlat(int hcl) { double thickness = 1.6002; //aluminum, steel is 1.1684 double holeWidth = 4.6609; double holeXInset = 4.1, holeYInset = 3.3; double pitch = 12.7; - int holeCountLength = 5, holeCountWidth = 1; + int holeCountLength = hcl, holeCountWidth = 1; CSG plate = new Cube(holeCountLength * pitch, holeCountWidth * pitch - thickness, thickness).toCSG(); plate = plate.movex(-plate.getMinX()).movey(-plate.getMinY()).movez(-plate.getMinZ()); @@ -41,12 +41,23 @@ CSG getFlat() { } CSG getCChannel() { - double thickness = 1.6002; //aluminum, steel is 1.1684 + String type = "vexCchannel" + if (args==null) { + args=["Steel 2x5"] + } + StringParameter size = new StringParameter(type + " Default", + args.get(0), + Vitamins.listVitaminSizes(type)) + + HashMap vexConfig = Vitamins.getConfiguration(type, size.getStrValue()) + + double thickness = vexConfig.thickness double holeWidth = 4.6609, holeThinGap = 1.6764; double holeXInset = 4.1, holeYInset = 3.3; double pitch = 12.7; - int holeCountLength = 5, holeCountWidth = 2; + int holeCountLength = (int) vexConfig.holeCountLength + int holeCountWidth = (int) vexConfig.holeCountWidth CSG plate = new Cube(holeCountLength * pitch, holeCountWidth * pitch - thickness, thickness).toCSG(); plate = plate.movex(-plate.getMinX()).movey(-plate.getMinY()).movez(-plate.getMinZ()); @@ -80,7 +91,7 @@ CSG getCChannel() { plate = plate.difference(holeSet); - CSG side = getFlat().rotx(-90).movez(thickness); + CSG side = getFlat(holeCountLength).rotx(-90).movez(thickness); plate = plate.union(side).union(side.movey(plate.getTotalY() + side.getTotalY())); //Center corner at (0, 0) diff --git a/scripts/Cchannelscript.groovy b/scripts/Cchannelscript.groovy deleted file mode 100644 index 85ecce4..0000000 --- a/scripts/Cchannelscript.groovy +++ /dev/null @@ -1,108 +0,0 @@ -import com.neuronrobotics.bowlerstudio.vitamins.Vitamins; -import eu.mihosoft.vrl.v3d.parametrics.*; - -CSG getFlat(int hcl) { - double thickness = 1.6002; //aluminum, steel is 1.1684 - double holeWidth = 4.6609; - double holeXInset = 4.1, holeYInset = 3.3; - double pitch = 12.7; - - int holeCountLength = hcl, holeCountWidth = 1; - - CSG plate = new Cube(holeCountLength * pitch, holeCountWidth * pitch - thickness, thickness).toCSG(); - plate = plate.movex(-plate.getMinX()).movey(-plate.getMinY()).movez(-plate.getMinZ()); - - //Build y holes - CSG hole = new Cube(holeWidth, holeWidth, thickness).toCSG(); - hole = hole.movex(-hole.getMinX()).movey(-hole.getMinY()).movez(-hole.getMinZ()); - - CSG yHoles = hole.clone(); - - //Lined up holes - for (int i = 1; i < holeCountWidth; i++) { - yHoles = yHoles.union(hole.movey(i * pitch)); - } - - //Holes are inset from the side - yHoles = yHoles.movey(plate.getMaxY() - yHoles.getMaxY()); - yHoles = yHoles.movex(holeXInset).movey(-holeYInset); - - //Build hole set - CSG holeSet = yHoles.clone(); - - for (int i = 1; i < holeCountLength; i++) { - holeSet = holeSet.union(yHoles.movex(i * pitch)); - } - - plate = plate.difference(holeSet); - - //Center corner at (0, 0) - plate = plate.movey(-plate.getMinY()); -} - -CSG getCChannel() { - String type = "vexCchannel" - if (args==null) { - args=["Steel 2x5"] - } - StringParameter size = new StringParameter(type + " Default", - args.get(0), - Vitamins.listVitaminSizes(type)) - - HashMap vexConfig = Vitamins.getConfiguration(type, size.getStrValue()) - - double thickness = vexConfig.thickness - double holeWidth = 4.6609, holeThinGap = 1.6764; - double holeXInset = 4.1, holeYInset = 3.3; - double pitch = 12.7; - - int holeCountLength = (int) vexConfig.holeCountLength - int holeCountWidth = (int) vexConfig.holeCountWidth - - CSG plate = new Cube(holeCountLength * pitch, holeCountWidth * pitch - thickness, thickness).toCSG(); - plate = plate.movex(-plate.getMinX()).movey(-plate.getMinY()).movez(-plate.getMinZ()); - - //Build y holes - CSG hole = new Cube(holeWidth, holeWidth, thickness).toCSG(); - hole = hole.movex(-hole.getMinX()).movey(-hole.getMinY()).movez(-hole.getMinZ()); - - CSG yHoles = hole.clone(); - - //Lined up holes - for (int i = 1; i < holeCountWidth; i++) { - yHoles = yHoles.union(hole.movey(i * pitch)); - } - - //2 wide has offset holes - if (holeCountWidth == 2) { - yHoles = yHoles.union(hole.movey(holeWidth + holeThinGap).movex(holeWidth + holeThinGap)); - } - - //Holes are inset from the side - yHoles = yHoles.movey(plate.getMaxY() - yHoles.getMaxY()); - yHoles = yHoles.movex(holeXInset).movey(-holeYInset); - - //Build hole set - CSG holeSet = yHoles.clone(); - - for (int i = 1; i < holeCountLength; i++) { - holeSet = holeSet.union(yHoles.movex(i * pitch)); - } - - plate = plate.difference(holeSet); - - CSG side = getFlat(holeCountLength).rotx(-90).movez(thickness); - plate = plate.union(side).union(side.movey(plate.getTotalY() + side.getTotalY())); - - //Center corner at (0, 0) - plate = plate.movey(-plate.getMinY()); - - CSG cornerFill = new Cube(plate.getTotalX(), thickness, thickness).toCSG(); - cornerFill = cornerFill.movex(-cornerFill.getMinX()).movey(-cornerFill.getMinY()).movez(-cornerFill.getMinZ()); - CSG otherCornerFill = cornerFill.movey(plate.getMaxY() - cornerFill.getMaxY()); - plate = plate.union(cornerFill).union(otherCornerFill); - - return plate; -} - -return getCChannel()