add an option to also render the phone inside the case
This commit is contained in:
@@ -2,7 +2,7 @@ this is a 3d-printable case designed for the PinePhone, but implemented with an
|
||||
generalizing beyond just that model and supporting future phones/preferences alongside
|
||||
this first model.
|
||||
|
||||
note that this is WIP and NOT a case i'd be comfortable using daily.
|
||||
status: case is usable, but the print is rough and requires a good deal of manual cleaning due to aggressive fillets/overhangs.
|
||||
|
||||
## Prerequisites
|
||||
- run `nix develop` to enter a dev environment.
|
||||
@@ -16,7 +16,8 @@ note that this is WIP and NOT a case i'd be comfortable using daily.
|
||||
- `./cq_toplevel.py --export-stl model.stl`
|
||||
|
||||
## Development
|
||||
- `cq-editor ./cq_toplevel.py` to load an interactive GUI
|
||||
- `./cq_toplevel.py --editor` or `cq-editor ./cq_toplevel.py` to load an interactive GUI
|
||||
- press the green play button to render the model
|
||||
- call with `--render-phone` to see how the phone would fit inside the case
|
||||
|
||||
- CadQuery docs may be found here: <https://cadquery.readthedocs.io/en/latest/quickstart.html>
|
||||
|
@@ -11,6 +11,7 @@ import cadquery as cq
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.join(os.getcwd(), "src"))
|
||||
@@ -22,24 +23,33 @@ import ldtek_battery
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def model():
|
||||
render_phone = os.environ.get("CASE_RENDER_PHONE", "") not in ("", "0")
|
||||
phone = pinephone.PinePhone()
|
||||
battery = ldtek_battery.LdtekBattery()
|
||||
return case.case(phone, battery=battery)
|
||||
return case.case(phone, battery=battery, render_phone=render_phone)
|
||||
|
||||
def main():
|
||||
logging.basicConfig()
|
||||
logging.getLogger().setLevel(logging.INFO)
|
||||
|
||||
parser = argparse.ArgumentParser(description="toplevel cadquery interface")
|
||||
parser.add_argument("--render-phone", action="store_true", help="include the phone model itself in the stl; useful to confirm fit visually before printing")
|
||||
parser.add_argument("--export-stl")
|
||||
parser.add_argument("--editor", action="store_true", help="view in cq-editor")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.render_phone:
|
||||
os.environ["CASE_RENDER_PHONE"] = "1"
|
||||
|
||||
model_ = model()
|
||||
|
||||
if args.export_stl:
|
||||
logger.info("exporting stl to %s", args.export_stl)
|
||||
cq.exporters.export(model_, args.export_stl)
|
||||
if args.editor:
|
||||
logger.info("launching cq-editor")
|
||||
subprocess.check_call(["cq-editor", __file__])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@@ -335,7 +335,7 @@ def orient_for_printing(case):
|
||||
"""
|
||||
return case.rotate((0, 0, 0), (1000, 0, 0), angleDegrees=180)
|
||||
|
||||
def case(phone, battery=None):
|
||||
def case(phone, battery=None, render_phone: bool=False):
|
||||
body = phone.solids(tag="body")
|
||||
power = phone.solids(tag="power")
|
||||
volume = phone.solids(tag="volume")
|
||||
@@ -367,5 +367,9 @@ def case(phone, battery=None):
|
||||
case = case.add(battery_harness(phone, battery))
|
||||
|
||||
# TODO: compress the case along the Z axis, to give a snugger fit (0.8mm is a good compression)
|
||||
|
||||
if render_phone:
|
||||
case = case.union(phone)
|
||||
|
||||
case = orient_for_printing(case)
|
||||
return case
|
||||
|
Reference in New Issue
Block a user