Skip to content

Commit

Permalink
implemented is_flat and is_solid in LeleBodyType
Browse files Browse the repository at this point in the history
  • Loading branch information
bat52 committed Jan 20, 2025
1 parent 6cde988 commit a3364e3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/pylele/pylele2/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def gen(self) -> Shape:
bot <<= (0, 0, joinTol - midTck)
bot += self.gourd_flat_extrusion(thickness=-midTck)

elif self.cli.body_type in [LeleBodyType.FLAT, LeleBodyType.TRAVEL]:
elif self.cli.body_type.is_solid():

bot_below = self.gen_flat_body_bottom()

Expand Down
11 changes: 3 additions & 8 deletions src/pylele/pylele2/bottom_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,9 @@ def gen(self) -> Shape:
body -= LeleNeckJoint(cli=self.cli, isCut=True).mv(-jcTol, 0, jcTol)

## Neck Bend
if self.cli.body_type in [
LeleBodyType.FLAT,
LeleBodyType.HOLLOW,
LeleBodyType.TRAVEL
]:
if self.cli.implementation == Implementation.CADQUERY and (
self.cli.body_type == LeleBodyType.FLAT or
self.cli.body_type == LeleBodyType.HOLLOW):
if self.cli.body_type.is_flat():
if self.cli.implementation == Implementation.CADQUERY and \
self.cli.body_type.is_flat():
print('# WARNING: not generating neck bend, because does not work with cadquery and flat body')
else:
body += LeleNeckBend(cli=self.cli)
Expand Down
8 changes: 8 additions & 0 deletions src/pylele/pylele2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class LeleBodyType(StringEnum):
HOLLOW = 'hollow'
TRAVEL = 'travel'

def is_flat(self) -> bool:
""" Is Flat Body """
return self in [LeleBodyType.FLAT, LeleBodyType.HOLLOW, LeleBodyType.TRAVEL]

def is_solid(self) -> bool:
""" Is Flat Body """
return self in [LeleBodyType.FLAT, LeleBodyType.TRAVEL]

WORM_SLIT = ['-wah','-wsl','35']
WORM = ['-t','worm' ,'-e','90'] + WORM_SLIT
BIGWORM = ['-t','bigworm','-e','90','-fbt','35'] + WORM_SLIT
Expand Down
5 changes: 2 additions & 3 deletions src/pylele/pylele2/tail.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def gen(self) -> Shape:
assert tail_width > 0, f"tail_width too small! {tail_width}, should be larger than 0"

## flat middle section
if self.cli.body_type in [LeleBodyType.FLAT, LeleBodyType.HOLLOW, LeleBodyType.TRAVEL]:
if self.cli.body_type.is_flat():
midBotTck = self.cli.flat_body_thickness
else:
midBotTck = cfg.extMidBotTck + 2*cutAdj
Expand All @@ -63,11 +63,10 @@ def gen(self) -> Shape:
.mv(tailX -rimWth -tailLen, 0, -midBotTck/2)
tail = extTop + inrTop.mv(jcTol, 0, 0)

if self.cli.body_type in [LeleBodyType.FLAT, LeleBodyType.HOLLOW, LeleBodyType.TRAVEL]:
if self.cli.body_type.is_flat():
# flat bodies do not have rounded bottom
if self.cli.body_type in [LeleBodyType.TRAVEL]:
tail = tail.mv(5,0,0) # for whatever reason...
pass
else:
# rounded bottom
extBot = self.api.cylinder_x(10 if self.isCut else rimWth, endWth/2)\
Expand Down
4 changes: 2 additions & 2 deletions src/pylele/pylele2/top_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def gen(self) -> Shape:
if fretbd.has_parts():
self.add_parts(top.parts)

if not self.cli.body_type in [LeleBodyType.FLAT, LeleBodyType.TRAVEL]:
if not self.cli.body_type.is_solid():
# soundhole
sh = LeleSoundhole(cli=self.cli, isCut=True)
top -= sh
Expand All @@ -92,7 +92,7 @@ def gen(self) -> Shape:
if self.cli.body_type in [LeleBodyType.GOURD, LeleBodyType.TRAVEL]:
chm = LeleChamber(cli=self.cli,isCut=True)
# cut Brace from chamber
if not self.cli.body_type in [LeleBodyType.FLAT, LeleBodyType.TRAVEL]:
if not self.cli.body_type.is_solid():
chm -= LeleBrace(cli=self.cli)
top -= chm

Expand Down

0 comments on commit a3364e3

Please sign in to comment.