codeCAD/smartphonestand.ipynb
2026-02-27 02:05:50 +01:00

150 lines
3.9 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "bad426fe-bce7-427b-938b-ccf52358420d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting auto display for cadquery Workplane and Shape\n"
]
}
],
"source": [
"import timeit\n",
"tic = timeit.default_timer()\n",
"\n",
"import cadquery as cq\n",
"from build123d import *\n",
"\n",
"from jupyter_cadquery import (\n",
" versions,\n",
" show, PartGroup, Part, \n",
" get_viewer, close_viewer, get_viewers, close_viewers, open_viewer, set_defaults, get_defaults, open_viewer,\n",
" get_pick,\n",
")\n",
"from jupyter_cadquery.ocp_utils import webcol_to_cq\n",
"\n",
"from jupyter_cadquery.replay import replay, enable_replay, disable_replay\n",
"close_viewers()\n",
"set_defaults(\n",
" cad_width=640, \n",
" height=480, \n",
" viewer=\"smartphonestand\"\n",
")\n",
"cv = open_viewer(\"smartphonestand\",\n",
" anchor=\"right\", \n",
" glass=True, \n",
" theme=\"dark\",\n",
" tools=True) # sets default viewer\n",
"\n",
"\n",
"#cv.grid = [not g for g in cv.widget.grid]\n",
"\n",
"#cv.axes = not cv.axes\n",
"#cv.axes0 = not cv.axes0\n",
"#cv.transparent = not cv.transparent\n",
"#cv.black_edges = not cv.black_edges\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "897c1e60-a09b-4143-99c6-52f5e42bf60e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<cad_viewer_widget.widget.CadViewer at 0x71b3d4c51fc0>"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with BuildPart() as part_builder:\n",
" with BuildSketch() as profile_sketch:\n",
" with BuildLine() as line_builder:\n",
" line = Polyline((100, -30),(-30, -30),(0, -10),\\\n",
" (-30,10),(-20,20), (0,0), (70,70), close=False)\n",
" line1 = fillet(radius=6,objects=line.vertices())\n",
" w = offset(amount=3) \n",
" \n",
" make_face()\n",
" extrude(amount=70)\n",
" f = part_builder.faces().sort_by(Axis.Y)[-11]\n",
" with BuildSketch() as bump_sk:\n",
" with Locations((-15,18)):\n",
" Circle(3)\n",
" extrude(amount=70)\n",
" with BuildSketch(f) as cutout_sketch:\n",
" with Locations((-7,0)):\n",
" RectangleRounded(35, 15, 2)\n",
" #SlotCenterToCenter(10,9, rotation=90)\n",
" #Circle(6)\n",
" extrude(amount=35, both=True, mode=Mode.SUBTRACT)\n",
" \n",
"show(part_builder,reset_camera=False)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "ca8fe07f-818b-458d-989c-e93d248a8bec",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"export_step(part_builder.part, \"phonestand1.step\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1b70ab33-cade-49e7-afc6-579769e9aee7",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}