add config env vars for battery margin & shell thickness
This commit is contained in:
12
src/case.py
12
src/case.py
@@ -46,8 +46,9 @@ class CaseOps:
|
|||||||
battery_harness_shell_thickness = 1.2
|
battery_harness_shell_thickness = 1.2
|
||||||
battery_harness_margin_bottom = 22.3
|
battery_harness_margin_bottom = 22.3
|
||||||
battery_harness_margin_top = 0.0
|
battery_harness_margin_top = 0.0
|
||||||
|
battery_margin_leftright = 4.0 #< how much room to reserve on each of the left and right sides of the battery
|
||||||
# optionally, force a specific number of columns instead of radii
|
# optionally, force a specific number of columns instead of radii
|
||||||
n_columns = 0
|
n_columns = None
|
||||||
|
|
||||||
dark_gray = cq.Color(95/256, 87/256, 79/256)
|
dark_gray = cq.Color(95/256, 87/256, 79/256)
|
||||||
mid_gray = cq.Color(128/256, 118/256, 108/256)
|
mid_gray = cq.Color(128/256, 118/256, 108/256)
|
||||||
@@ -62,7 +63,12 @@ class CaseOps:
|
|||||||
|
|
||||||
def __init__(self, config: Config):
|
def __init__(self, config: Config):
|
||||||
self.battery_harness_height = max(self.battery_harness_height, config.min_feature_z)
|
self.battery_harness_height = max(self.battery_harness_height, config.min_feature_z)
|
||||||
self.n_columns = config.battery_harness_shell_columns
|
if config.battery_margin_leftright is not None:
|
||||||
|
self.battery_margin_leftright = config.battery_margin_leftright
|
||||||
|
if config.battery_harness_shell_columns is not None:
|
||||||
|
self.n_columns = config.battery_harness_shell_columns
|
||||||
|
if config.battery_harness_shell_thickness is not None:
|
||||||
|
self.battery_harness_shell_thickness = config.battery_harness_shell_thickness
|
||||||
|
|
||||||
def make_shell(self, body: cq.Workplane) -> cq.Workplane:
|
def make_shell(self, body: cq.Workplane) -> cq.Workplane:
|
||||||
p = self
|
p = self
|
||||||
@@ -286,6 +292,8 @@ class CaseOps:
|
|||||||
))
|
))
|
||||||
# shift to desired position
|
# shift to desired position
|
||||||
battery = battery.translate((0, p.battery_shift_y, 0))
|
battery = battery.translate((0, p.battery_shift_y, 0))
|
||||||
|
|
||||||
|
battery = thicken(battery.faces("<X or >X"), p.battery_margin_leftright, combine=True).union(battery)
|
||||||
return battery
|
return battery
|
||||||
|
|
||||||
# def battery_straps(phone, battery):
|
# def battery_straps(phone, battery):
|
||||||
|
@@ -12,7 +12,9 @@ class Config:
|
|||||||
min_feature_z: float = 0.0
|
min_feature_z: float = 0.0
|
||||||
|
|
||||||
battery: str = DEFAULT_BATTERY
|
battery: str = DEFAULT_BATTERY
|
||||||
battery_harness_shell_columns: int = 0
|
battery_harness_shell_columns: int | None = None
|
||||||
|
battery_harness_shell_thickness: float | None = None
|
||||||
|
battery_margin_leftright: float | None = None
|
||||||
|
|
||||||
# TODO: these should really be lifted out, as they don't impact the model
|
# TODO: these should really be lifted out, as they don't impact the model
|
||||||
render_phone: bool = False
|
render_phone: bool = False
|
||||||
@@ -40,6 +42,14 @@ class Config:
|
|||||||
if battery_harness_shell_columns is not None:
|
if battery_harness_shell_columns is not None:
|
||||||
self.battery_harness_shell_columns = int(battery_harness_shell_columns)
|
self.battery_harness_shell_columns = int(battery_harness_shell_columns)
|
||||||
|
|
||||||
|
battery_harness_shell_thickness = os.environ.get("CASE_BATTERY_HARNESS_SHELL_THICKNESS_MM")
|
||||||
|
if battery_harness_shell_thickness is not None:
|
||||||
|
self.battery_harness_shell_thickness = float(battery_harness_shell_thickness)
|
||||||
|
|
||||||
|
battery_margin_leftright = os.environ.get("CASE_BATTERY_MARGIN_LEFTRIGHT_MM")
|
||||||
|
if battery_margin_leftright is not None:
|
||||||
|
self.battery_margin_leftright = int(battery_margin_leftright)
|
||||||
|
|
||||||
min_feature_z = os.environ.get("CASE_MIN_FEATURE_Z_MM")
|
min_feature_z = os.environ.get("CASE_MIN_FEATURE_Z_MM")
|
||||||
if min_feature_z is not None:
|
if min_feature_z is not None:
|
||||||
self.min_feature_z = float(min_feature_z)
|
self.min_feature_z = float(min_feature_z)
|
||||||
|
Reference in New Issue
Block a user