Merge pull request #213 from EmperorArthur/fix_only_corners

Fix only corners
This commit is contained in:
Arthur Moore 2024-08-29 19:53:27 -04:00 committed by GitHub
commit 7eb86296d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 6 deletions

View file

@ -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]) {

View file

@ -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

View file

@ -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