Skip to content

Instantly share code, notes, and snippets.

@nezuppo
Last active April 1, 2021 09:12
Show Gist options
  • Save nezuppo/32ebe2c519c954f3ce64e784cd44027e to your computer and use it in GitHub Desktop.
Save nezuppo/32ebe2c519c954f3ce64e784cd44027e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from montyscad import monty_symbols as ms
from decimal import Decimal
def circle_slits(radius, slits_num, width, sleleton_width=Decimal('0.0001')):
interval = radius * 2 / (slits_num + 1)
symbol = ms.Union()
for i in range(slits_num):
symbol.append(
ms.Translate([0, interval * (i + 1)])(
ms.Square([radius * 2, sleleton_width], center=True)
)
)
symbol = ms.Translate([0, -radius])(
symbol
)
symbol = ms.Intersection()(
symbol,
ms.Circle(radius)
)
symbol = ms.Offset(width)(
symbol
)
return symbol
def _example():
import os.path
from montyscad import Scad
scad = Scad()
scad.append('$fn=120;')
scad += [
circle_slits(Decimal('15.0'), 9, Decimal('0.75'))
]
basename = os.path.basename(__file__)
basename_root = os.path.splitext(basename)[0]
scad.write(f'./__{basename_root}.scad')
if __name__ == '__main__':
_example()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment