diff --git a/gridfinity-rebuilt-utility.scad b/gridfinity-rebuilt-utility.scad index 80f28e2..22a27a1 100644 --- a/gridfinity-rebuilt-utility.scad +++ b/gridfinity-rebuilt-utility.scad @@ -230,7 +230,7 @@ module gridfinityBase(gx, gy, l, dx, dy, hole_options=bundle_hole_options(), off if(only_corners) { difference(){ pattern_linear(gx/dbnx, gy/dbny, dbnx*l, dbny*l) - block_base(gx, gy, l, dbnx, dbny, 0, off); + block_base(gx, gy, l, dbnx, dbny, bundle_hole_options(), off); copy_mirror([0, 1, 0]) { copy_mirror([1, 0, 0]) { diff --git a/tests/openscad_runner.py b/tests/openscad_runner.py index c73987d..1d150bd 100644 --- a/tests/openscad_runner.py +++ b/tests/openscad_runner.py @@ -109,7 +109,7 @@ class OpenScadRunner: TOP_ANGLE_CAMERA = CameraArguments(Vec3(0,0,0),Vec3(45,0,45),150) common_arguments = [ - #'--hardwarnings', // Does not work when setting variables by using functions + #'--hardwarnings', # Does not work when setting variables by using functions '--enable=fast-csg', '--enable=predictible-output', '--imgsize=1280,720', @@ -127,9 +127,9 @@ class OpenScadRunner: self.camera_arguments = None self.parameters = None - def create_image(self, args: [str], image_file_name: str): + def create_image(self, args: [str], image_file_name: str) -> subprocess.CompletedProcess: """ - Run the code, to create an image. + Run the code and create an image. @Important The only verification is that no errors occured. There is no verification if the image was created, or the image contents. """ @@ -150,6 +150,18 @@ class OpenScadRunner: json.dump(params, file, sort_keys=True, indent=2, cls=DataClassJSONEncoder) file.close() command_arguments += ["-p", file.name, "-P", "python_generated"] - return subprocess.run([self.openscad_binary_path]+command_arguments, check=True) + return self._run(command_arguments) else: - return subprocess.run([self.openscad_binary_path]+command_arguments, check=True) + return self._run(command_arguments) + + def _run(self, args: [str]) -> subprocess.CompletedProcess: + """ + Run openscad with the passed in arguments. + """ + output = subprocess.run([self.openscad_binary_path]+args, capture_output=True) + error_strings = output.stderr.decode().strip().splitlines() + if any(line.startswith("ERROR:") for line in error_strings): + # OpenSCAD doesn't set an error return if it errors from bad SCAD code! + output.returncode = 11 + output.check_returncode() + return output diff --git a/tests/test_bins.py b/tests/test_bins.py index 1c922b0..8959eea 100644 --- a/tests/test_bins.py +++ b/tests/test_bins.py @@ -37,6 +37,14 @@ class TestBinHoles(unittest.TestCase): vars["screw_holes"] = False self.scad_runner.create_image([], Path('no_holes.png')) + def test_only_corner_holes(self): + vars = self.scad_runner.parameters + vars["refined_holes"] = True + vars["magnet_holes"] = False + vars["screw_holes"] = False + vars["only_corners"] = True + self.scad_runner.create_image([], Path('only_corner_holes.png')) + def test_refined_holes(self): vars = self.scad_runner.parameters vars["refined_holes"] = True