1+ import java.nio.file.Paths
2+
3+ import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine
14import com.neuronrobotics.bowlerstudio.vitamins.Vitamins
25
36import eu.mihosoft.vrl.v3d.CSG
47import eu.mihosoft.vrl.v3d.Cube
58import eu.mihosoft.vrl.v3d.Cylinder
9+ import eu.mihosoft.vrl.v3d.FileUtil
610import eu.mihosoft.vrl.v3d.RoundedCube
11+ import eu.mihosoft.vrl.v3d.Transform
712import eu.mihosoft.vrl.v3d.parametrics.LengthParameter
813
9- // code here
14+ double caseRounding = 4
1015
1116class BoardMaker {
1217 static double radius = 1
@@ -339,25 +344,25 @@ class BoardMaker{
339344 .difference(fullBoardMink)
340345 .difference(backBottomMink)
341346 CSG bottom = backBottom
342- bottom. setManufacturing({ toMfg ->
343- return toMfg
344- .toXMin()
345- .toYMin()
346- .toZMin()
347- })
348- topPlate. setManufacturing({ toMfg ->
349- return toMfg
350- .toXMin()
351- .toYMin()
352- .rotx(-180 )
353- .toZMin()
354- })
347+ // bottom.setManufacturing({ toMfg ->
348+ // return toMfg
349+ // .toXMin()
350+ // .toYMin()
351+ // .toZMin()
352+ // })
353+ // topPlate.setManufacturing({ toMfg ->
354+ // return toMfg
355+ // .toXMin()
356+ // .toYMin()
357+ // .rotx(-180)
358+ // .toZMin()
359+ // })
355360 bottom. setName(" CaseBottom" )
356361 topPlate. setName(" CaseTop" )
357362 def caseParts = [bottom,topPlate]
358363 return caseParts
359- board. addAll(caseParts)
360- return board
364+ // board.addAll(caseParts)
365+ // return board
361366 }
362367 def makeRoundedCyl (def rad ,def height , def corner ,def resolution ){
363368 def minHeight = height- corner* 2
@@ -378,7 +383,80 @@ class BoardMaker{
378383 return CSG . unionAll(cylParts). hull(). toZMin()
379384 }
380385}
381- return new BoardMaker (). makeCase()
386+ File dir = ScriptingEngine . getRepositoryCloneDirectory(" https://github.com/BancroftSchoolOpenSource/ArduinoClassRobot.git" )
387+
388+ File topSTL = new File (dir. getAbsolutePath()+ " /CaseTop.stl" )
389+ File botSTL = new File (dir. getAbsolutePath()+ " /CaseBottom.stl" )
390+
391+ if (! topSTL. exists()||! botSTL. exists()) {
392+ println " Producing Case STL part"
393+ def parts = new BoardMaker (). makeCase()
394+ for (CSG part :parts) {
395+ FileUtil . write(Paths . get(dir. getAbsolutePath()+ " /" + part. getName()+ " .stl" ),
396+ part. toStlString());
397+ }
398+ }else {
399+ println " Loading Cas parts from STL"
400+ }
401+
402+ CSG top = Vitamins . get(topSTL);
403+ CSG bot = Vitamins . get(botSTL);
404+ top. setName(" CaseTop" )
405+ bot. setName(" CaseBottom" )
406+ bot. setManufacturing({ toMfg ->
407+ return toMfg
408+ .toXMin()
409+ .toYMin()
410+ .toZMin()
411+ })
412+ top. setManufacturing({ toMfg ->
413+ return toMfg
414+ .toXMin()
415+ .toYMin()
416+ .rotx(-180 )
417+ .toZMin()
418+ })
419+ LengthParameter tailLength = new LengthParameter (" Cable Cut Out Length" ,30 ,[500 , 0.01 ])
420+ tailLength. setMM(100 )
421+ CSG motor = Vitamins . get(" hobbyServo" , " tproSG90" )
422+ CSG horn = Vitamins . get(" hobbyServoHorn" , " tproSG90_1" )
423+ .movez(motor. getMaxZ())
424+ Transform leftSide = new Transform ()
425+ Transform rightSide = new Transform ()
426+
427+ CSG asmOfDrive = motor. union(horn). rotz(180 )
428+ .movez(-8 )
429+ .movey(10 )
430+
431+ CSG leftDrive = asmOfDrive. transformed(leftSide)
432+ .roty(90 )
433+ .movex(bot. getMinX())
434+
435+ CSG rightDrive = asmOfDrive. transformed(rightSide)
436+ .roty(-90 )
437+ .movex(bot. getMaxX())
438+
439+ CSG bothDrive = leftDrive. union(rightDrive)
440+ .toZMax()
441+ .movez(bot. getMinZ())
442+ .movey(5 )
443+
444+ CSG servoBlock = new Cube (bot. getTotalX()- caseRounding* 2 ,bot. getTotalY()- caseRounding* 2 , bothDrive. getTotalZ())
445+ .toCSG()
446+ .toZMax()
447+ .movez(bot. getMinZ())
448+ .toYMax()
449+ .movey(bot. getMaxY()- caseRounding)
450+ .toXMax()
451+ .movex(bot. getMaxX()- caseRounding)
452+ CSG blockCordCut = servoBlock. toYMax()
453+ .movey(servoBlock. getMinY()+12 )
454+ .movez(-5 )
455+ bot= bot. union(servoBlock)
456+ .difference(bothDrive)
457+ .union(blockCordCut)
458+
459+ return [top,bot]
382460
383461
384462
0 commit comments