Files
phone-case-cq/cq_toplevel.py
2023-12-28 03:29:13 +00:00

49 lines
1.0 KiB
Python
Executable File

#!/usr/bin/env python3
"""
toplevel file used for interactive modeling.
- `cq-editor ./cq_toplevel.py`
- then press green play button to render
- edit files externally, and press render again to refresh the view
"""
import cadquery as cq
import argparse
import logging
import os
import sys
sys.path.append(os.path.join(os.getcwd(), "src"))
import case
import pinephone
import ldtek_battery
logger = logging.getLogger(__name__)
def model():
phone = pinephone.PinePhone()
battery = ldtek_battery.LdtekBattery()
return case.case(phone, battery=battery)
def main():
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
parser = argparse.ArgumentParser(description="toplevel cadquery interface")
parser.add_argument("--export-stl")
args = parser.parse_args()
model_ = model()
if args.export_stl:
logger.info("exporting stl to %s", args.export_stl)
cq.exporters.export(model_, args.export_stl)
if __name__ == "__main__":
main()
else:
result = model()