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

309 lines
8.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "476d2190-282f-4bb3-a9c0-d9e352235d18",
"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=\"syncgrips_v2\"\n",
")\n",
"cv = open_viewer(\"zementmischer\",\n",
" anchor=\"right\", \n",
" glass=True, \n",
" theme=\"dark\",\n",
" tools=True) # sets default viewer\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "27291ccc-aebc-4828-b447-19603567caa8",
"metadata": {},
"outputs": [],
"source": [
"with BuildPart() as bearing:\n",
" with BuildSketch() as sk:\n",
" Circle(11)\n",
" Circle(4, mode=Mode.SUBTRACT)\n",
" extrude(amount=7)\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "016a58c2-a252-4d58-9617-4626b02e56c5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"100% ⋮————————————————————————————————————————————————————————————⋮ (2/2) 0.32s\n"
]
},
{
"data": {
"text/plain": [
"<cad_viewer_widget.widget.CadViewer at 0x7394290d26e0>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with BuildPart() as holder:\n",
" with BuildSketch(Plane.XY.offset(0)) as slim_sk:\n",
" Polygon((-5,0),(5,0),(0,5), \\\n",
" align=Align.CENTER)\n",
" with BuildSketch(Plane.XY.offset(120)) as slim_sk:\n",
" Polygon((-10,0),(10,0),(0,10), \\\n",
" align=Align.CENTER)\n",
" #mirror(about=Plane.YZ)\n",
" #extrude(amount=-30)\n",
" #sweep()\n",
" loft()\n",
" \n",
"show(holder,bearing, reset_camera=False)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "46db8226-8b74-4c63-bc48-83cc40ae79da",
"metadata": {},
"outputs": [],
"source": [
"d = 10.2\n",
"d1 = 11.3\n",
"l = 38.7\n",
"l1 = 39.7\n",
"l2 = 63\n",
"b = 0.5\n",
"h = 1.8\n",
"h1 = 0.8\n",
"with BuildPart() as camcap:\n",
" with BuildSketch() as sk:\n",
" SlotCenterToCenter(l2-d1+2*b,d1+2*b)\n",
" extrude(amount=h+b)\n",
" f = camcap.faces().sort_by(Axis.Z)[0]\n",
" with BuildSketch(f) as sk1:\n",
" with Locations((-(l2-l1)/2-b,0)):\n",
" SlotCenterToCenter(l-d+b,d)\n",
" extrude(amount=-h, mode=Mode.SUBTRACT)\n",
" with BuildSketch(f) as sk2:\n",
" with Locations((-(l2-l1)/2-b,0)):\n",
" SlotCenterToCenter(l1-d1+b,d1)\n",
" extrude(amount=-h1, mode=Mode.SUBTRACT)\n",
" with BuildSketch(f) as sk3:\n",
" with Locations((-(l2)/2+49.7,0)):\n",
" Circle(9.5/2)\n",
" extrude(amount=-h1, mode=Mode.SUBTRACT)\n",
" fillet(camcap.edges().sort_by(Axis.Z)[-1], radius=0.5)\n",
"camcap"
]
},
{
"cell_type": "code",
"execution_count": 57,
"id": "e16ea143-59f6-4366-9a51-9473eefdce3a",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_33/1870784379.py:1: DeprecationWarning: Use the `export_step` function instead\n",
" camcap.part.export_step(\"camcap_note10.step\")\n"
]
},
{
"data": {
"text/plain": [
"<IFSelect_ReturnStatus.IFSelect_RetDone: 1>"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"camcap.part.export_step(\"camcap_note10.step\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "a33280cb-fc8c-4cb7-bf4b-6a707534f02b",
"metadata": {},
"outputs": [],
"source": [
"hs = 9.5\n",
"with BuildPart() as frontcamcap:\n",
" with BuildSketch() as sk:\n",
" Circle(8)\n",
" with Locations((0,8)):\n",
" Rectangle(20, 3)\n",
" make_hull()\n",
" extrude(amount=b)\n",
" chamfer(frontcamcap.edges().sort_by(Axis.Z)[0], length=b*0.9)\n",
" with Locations((0,0,hs)):\n",
" add(frontcamcap.part.mirror(Plane.XY))\n",
" with Locations((0,8+1.5+b/2,hs/2)):\n",
" Box(20,b, hs)\n",
" \n",
" \n",
"frontcamcap"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "403932d5-0058-4480-89de-0ec633436000",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"export_step(frontcamcap.part, \"frontcamcap.step\")"
]
},
{
"cell_type": "code",
"execution_count": 64,
"id": "04750084-62c3-4bfa-8c5a-d172b4e70451",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<cad_viewer_widget.widget.CadViewer at 0x7394290d26e0>"
]
},
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with BuildPart() as akaso_adapter:\n",
" Box(8.5, 70, 20)\n",
" #fillet(akaso_adapter.edges()|Axis.Z, radius=2)\n",
" with Locations((4,0,16)):\n",
" b = Box(16, 14.5, 20)\n",
" with Locations((0,0,3)):\n",
" Cylinder(5.5/2,20, rotation=(90,0,0), mode=Mode.SUBTRACT)\n",
" edgs = b.faces().sort_by(Axis.Z)[-1].edges() | Axis.Y\n",
" fillet(edgs, radius=7.7)\n",
" with Locations((4,0,14)):\n",
" with Locations((0,-2.7*1,2),(0,2.7*1,2)):\n",
" Box(18, 2.7,20, mode=Mode.SUBTRACT)\n",
" fs = akaso_adapter.faces().group_by(Axis.X)[-1].edges().group_by(Axis.Z)[0]\n",
" fillet(fs, radius=7.7)\n",
"show(akaso_adapter, reset_camera=False)"
]
},
{
"cell_type": "code",
"execution_count": 65,
"id": "c30c3133-590e-4f13-be94-eb129e93775f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"export_step(akaso_adapter.part, \"akaso.step\")"
]
},
{
"cell_type": "code",
"execution_count": 60,
"id": "ca641769-775b-4ce8-99a1-211dcc221ab5",
"metadata": {},
"outputs": [],
"source": [
"akaso_adapter.faces().group_by(Axis.X)[-1].edges().group_by(Axis.Z)[0]# | Axis.Y"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "729fa291-80fa-4aa7-ac9b-6f15a887409a",
"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
}