Skip to content

Commit

Permalink
add pylele_nut
Browse files Browse the repository at this point in the history
  • Loading branch information
bat52 committed Aug 4, 2024
1 parent baac21d commit b287152
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
Empty file modified pylele_clean.sh
100644 → 100755
Empty file.
66 changes: 66 additions & 0 deletions pylele_nut.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env python3

"""
Pylele Nut
"""

import os
import math

from pylele_api import Shape
from pylele_base import LeleBase
from pylele_config import accumDiv, FIT_TOL, SEMI_RATIO, Implementation
from pylele_utils import radians

class LeleNut(LeleBase):
""" Pylele Nut Generator class """

def gen(self) -> Shape:
""" Generate Nut """

fitTol = FIT_TOL
fbTck = self.cfg.FRETBD_TCK
ntHt = self.cfg.NUT_HT
ntWth = self.cfg.nutWth + fbTck/4 + .5 # to be wider than fretbd
fWth = self.cfg.nutWth - 1 # to be narrower than fretbd
f0X = -fitTol if self.isCut else 0

f0Top = self.api.genRndRodY(ntWth, ntHt, 1/4)
f0TopCut = self.api.genBox(2*ntHt, 2*ntWth, fbTck).mv(0, 0, -fbTck/2)
f0Top = f0Top.cut(f0TopCut).mv(f0X, 0, fbTck)
f0Bot = self.api.genRndRodY(ntWth, ntHt, 1/4)
f0BotCut = self.api.genBox(2*ntHt, 2*ntWth, fbTck).mv(0, 0, fbTck/2)
f0Bot = f0Bot.cut(f0BotCut).scale(1, 1, fbTck/ntHt).mv(f0X, 0, fbTck)
nut = f0Top.join(f0Bot)

self.shape = nut

return nut

def nut_main(args = None):
""" Generate Nut """
solid = LeleNut(args=args)
solid.export_args() # from cli

solid.export_configuration()

solid.exportSTL()
return solid

def test_nut():
""" Test Nut """

component = 'nut'
tests = {
'cadquery': ['-i','cadquery'],
'blender' : ['-i','blender']
}

for test,args in tests.items():
print(f'# Test {component} {test}')
outdir = os.path.join('./test',component,test)
args += ['-o', outdir]
nut_main(args=args)

if __name__ == '__main__':
nut_main()
6 changes: 6 additions & 0 deletions pylele_test.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pylele_fretboard_joint import test_fretboard_joint
from pylele_top import test_top
from pylele_strings import test_strings
from pylele_nut import test_nut

# assemblies
from pylele_fretboard_assembly import test_fretboard_assembly
Expand Down Expand Up @@ -52,6 +53,11 @@ def test_strings(self):
""" Test Strings """
test_strings()

def test_nut(self):
""" Test Nut """
test_nut()


## Assemblies
def test_fretboard_assembly(self):
""" Test Fretboard Assembly """
Expand Down

0 comments on commit b287152

Please sign in to comment.