Skip to content

Commit

Permalink
Proper dimensions and transform, simplified version and wip code
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeicor committed Dec 2, 2023
1 parent fc6dfc7 commit 981f263
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
11 changes: 0 additions & 11 deletions .vscode/settings.json

This file was deleted.

Binary file added boot-simplified.stl
Binary file not shown.
Binary file modified boot.ply
Binary file not shown.
42 changes: 25 additions & 17 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from build123d import *
# %%
from contextlib import suppress
with suppress(ImportError): import ocp_vscode # Optional, for visualizing the model in VSCode instead of CQ-editor or exporting to STL
from os import getenv
from build123d import *

with suppress(ImportError):
# Optional, for visualizing the model in VSCode instead of CQ-editor or exporting to STL
import ocp_vscode

# %%
# ================== PARAMETERS ==================
# 3D printing basics
tol = 0.1 * MM # Tolerance (tighter than usual)
Expand All @@ -15,28 +20,31 @@

# ================== MODELLING ==================

boot = Compound.make_compound([import_stl('boot.stl')])
obj = boot
# Slow import...
boot = Mesher().read("boot.stl" if getenv("final_boot") else "boot-simplified.stl")

# %%

# obj = boot - Box(1 * MM, 1 * MM, 1 * MM, mode=Mode.SUBTRACT)

if "ocp_vscode" in locals():
ocp_vscode.reset_show()
ocp_vscode.show_all()

# %%
# ================== SHOWING/EXPORTING ==================

export = True
try:
if 'ocp_vscode' in locals():
import socket
tmp_socket = socket.socket()
tmp_socket.connect(('localhost', ocp_vscode.get_port()))
tmp_socket.close()
if "show_object" in locals():
show_object(obj, "boot-protector") # type: ignore
export = False
elif "ocp_vscode" in locals():
ocp_vscode.reset_show()
ocp_vscode.show_all()
export = False # If the connection fails, export to STL instead
elif 'show_object' in locals():
show_object(obj, 'boot-protector') # type: ignore
export = False
except Exception as ex:
print("Cannot show model, exporting to STL instead (%s)" % ex)

if export:
if hasattr(obj, 'part'):
obj.part.export_stl('boot-protector.stl')
else:
export_stl(obj, 'boot-protector.stl')
obj.part.export_stl("boot-protector.stl")

0 comments on commit 981f263

Please sign in to comment.