{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "9a610a27-cc42-4311-a288-ad89e86b5b73", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Overwriting auto display for cadquery Workplane and Shape\n", "Overwriting auto display for build123d BuildPart, BuildSketch, BuildLine, ShapeList\n" ] } ], "source": [ "from build123d import *\n", "from jupyter_cadquery import show, show_all,open_viewer,show_clear\n", "from IPython.display import display\n", "import ipywidgets as widgets" ] }, { "cell_type": "code", "execution_count": 2, "id": "68ca929c-7e78-4ce9-bafc-a336328244db", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "c3fd5673698d49c7ae097f6ec5deed41", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(Button(description='Viewer dół', style=ButtonStyle()), Button(description='Viewer prawo', style…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ " \n", "cv = None # viewer globalny\n", "\n", "def open_bottom(b):\n", " global cv\n", " print(\"Otwieram viewer (split-bottom)\")\n", " cv = open_viewer(\"Build123d\", anchor=\"split-bottom\")\n", "\n", "def open_right(b):\n", " global cv\n", " print(\"Otwieram viewer (right)\")\n", " cv = open_viewer(\"Build123d\", anchor=\"right\")\n", "\n", "# Przycisk 1 – bottom\n", "btn_bottom = widgets.Button(description=\"Viewer dół\")\n", "btn_bottom.on_click(open_bottom)\n", "\n", "# Przycisk 2 – right\n", "btn_right = widgets.Button(description=\"Viewer prawo\")\n", "btn_right.on_click(open_right)\n", "\n", "# Wyświetl przyciski\n", "display(widgets.HBox([btn_bottom, btn_right]))\n", " " ] }, { "cell_type": "code", "execution_count": 3, "id": "167a8aea-a7cb-4c0a-bd67-11bcf92c4be9", "metadata": {}, "outputs": [], "source": [ "grubosc_scianki = 3\n" ] }, { "cell_type": "code", "execution_count": 31, "id": "ffefb0fe-56f5-4d89-816c-9a964445e1fb", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "cc\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with BuildPart() as uchwycik:\n", " with BuildSketch():\n", " with BuildLine() as uch_ln:\n", " l1 = Line((0,0),(10,0))\n", " l5 = PolarLine((10,0),22,-22)\n", " # p2 = l5.end_point()\n", " # print(p2)\n", " l6 = PolarLine(l5.end_point(),10,90)\n", " l4 = PolarLine((10,10),22,-22)\n", " l3 = Line((0,10),(10,10))\n", " l2 = Line((0,0),(0,10))\n", " make_face()\n", " extrude(amount=grubosc_scianki)\n", " test = uchwycik.part.faces().filter_by(Axis.Z)[-1]\n", "\n", "# with BuildPart() as filarki:\n", "# with GridLocations(0,20,1,2):\n", "# Cylinder(7/2,15)\n", "# Hole(4/2)\n", "# with Locations((2,grubosc_scianki/2,-2.5)):\n", "# add(uchwycik,rotation=((90,0,0)))\n", "# f1 = filarki.faces().filter_by(Axis.Y)[1]\n", "# f2 = filarki.faces().filter_by(Axis.Y)[2]\n", " # with BuildSketch(f1):\n", " # with BuildLine():\n", " # pass\n", " \n", " \n", " \n", "show(uchwycik,test)\n", "\n", "# with BuildPart() as test:\n", "# with BuildSketch():\n", "# with BuildLine()" ] }, { "cell_type": "code", "execution_count": null, "id": "f309c60a-d31a-4363-b75e-443f85df11d3", "metadata": {}, "outputs": [], "source": [ "# length, width, thickness = 80.0, 60.0, 10.0\n", "\n", "# with BuildPart() as ex4:\n", "# with BuildSketch() as ex4_sk:\n", "# with BuildLine() as ex4_ln:\n", "# l1 = Line((0, 0), (length, 0))\n", "# l2 = Line((length, 0), (length, width))\n", "# l3 = ThreePointArc((length, width), (width, width * 1.5), (0.0, width))\n", "# l4 = Line((0.0, width), (0, 0))\n", "# # make_face()\n", "# # extrude(amount=thickness)\n", "\n", "# show(ex4_ln)" ] }, { "cell_type": "code", "execution_count": null, "id": "e2facbc6-5f0c-45b8-beaf-4a0b3c8f8856", "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.12.10" } }, "nbformat": 4, "nbformat_minor": 5 }