From 5e92eacb641ca1a6ba35854db8eb5ac93aa76e5f Mon Sep 17 00:00:00 2001 From: Rafal Date: Sun, 13 Jul 2025 11:22:41 +0000 Subject: [PATCH] Start --- .ipynb_checkpoints/mamba-checkpoint.ipynb | 126 ++++++++++++++++++ __pycache__/snippets_panel.cpython-312.pyc | Bin 0 -> 2029 bytes mamba.ipynb | 147 +++++++++++++++++++++ snippets_panel.py | 55 ++++++++ t1.svg | 8 ++ 5 files changed, 336 insertions(+) create mode 100644 .ipynb_checkpoints/mamba-checkpoint.ipynb create mode 100644 __pycache__/snippets_panel.cpython-312.pyc create mode 100644 mamba.ipynb create mode 100644 snippets_panel.py create mode 100644 t1.svg diff --git a/.ipynb_checkpoints/mamba-checkpoint.ipynb b/.ipynb_checkpoints/mamba-checkpoint.ipynb new file mode 100644 index 0000000..19ca0dc --- /dev/null +++ b/.ipynb_checkpoints/mamba-checkpoint.ipynb @@ -0,0 +1,126 @@ +{ + "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": 18, + "id": "68ca929c-7e78-4ce9-bafc-a336328244db", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d4c2b63ffa7a48cfa7c929f5cb97270f", + "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": null, + "id": "010eed22-3a06-4d28-bdce-4cc8e593b1aa", + "metadata": {}, + "outputs": [], + "source": [ + "# -*- coding: utf-8 -*-\n", + "from build123d import *\n", + "\n", + "# Rozpoczynamy tworzenie nowego szkicu 2D\n", + "# Wszystko, co narysujemy wewnątrz tego bloku 'with', będzie częścią 'my_sketch'\n", + "with BuildSketch() as my_sketch:\n", + " # Używamy Polyline, aby narysować kształt, podając współrzędne kolejnych punktów\n", + " Polyline(\n", + " (0, 10), # Punkt startowy\n", + " (0, 30), # Linia prosto w górę\n", + " (30, 30), # Linia w prawo\n", + " (60, 15), # Linia ukośna w dół i w prawo\n", + " (50, 0), # Linia ukośna w dół i w lewo\n", + " (20, 0), # Linia w lewo\n", + " close=True # Automatycznie zamykamy kształt, rysując linię do punktu startowego\n", + " )\n", + " # Tworzymy wypełnioną powierzchnię (Face) z narysowanego, zamkniętego konturu\n", + " make_face()\n", + "\n", + "# Wyświetlamy gotowy szkic\n", + "# Możesz też użyć show_all(), jeśli masz więcej obiektów\n", + "show(my_sketch)" + ] + } + ], + "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 +} diff --git a/__pycache__/snippets_panel.cpython-312.pyc b/__pycache__/snippets_panel.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..06827a15ef6d9c171b58a5469842f4d05da0f812 GIT binary patch literal 2029 zcmb7FUuYaf7~g-FyX;-sG+vVyjTtT|yCr{YRD{x&w$z#mJp=I%M&#JrncQu%x4X{n z<$6a8K?==P#6nRYRP?3Pk~~!VppOOVlP`%@8rIeaee%hZRM0;8&FpRyBZ3{+*>7gQ z-}i66`R%toJ*of$FZk7;QiAXcTO>n@g^hh6d?;W6i?&b`XGD?7k}cKb8JWwnt<0pb za!#1(YRY=*R|eF@FpVwWvyCQ**$N3tme&lbu2VE)!~B(oS%zoh22AJ0^AdOxv4mx; zd@Ns(0ui?Pm`mbGHsFm@6)}LgqtTY;n6+(VIbJWvmRhjJT`TG3*xm(kNnDa5QQL{=(NSet|&AGJzH#jqRvvchRSuz#``Cp#>lF9E)CGW zXn(E_RUouv8u+a`q0Qv8Uv(QJh|ML#wnto#IHd)PGzg7%O`8}rvT<^X7ji7FZ(<@| zsx5#M27ICN<&&V{BE>RUV#Oo+Do47I8DVerq&TCr={7;V)+#`>L1G)77{CU)9xUoMD+vbk%ac{3RZ+-;l7TCy( zGqu#XAGIX0$z$$m?TyXYM-Y>_jW_k^T-n*`a-ES<=hI7<(R5(Ypx(=uSH46iqpLLi z^7B*m9N+xl@^4?i$6Mw8?$J@yXqKUQTF7@S&m#dE9c^W%Bl&4&c`3y&5c}3Zz4lK2$ z(gP}MGSWyDL)jq>+64wqFy5pDXwxLROj$VL4j;(VA*X>s9j_jQsRhHX6I}_r%&Os3 zNGQ*fW|+a$^|0G;!c3gK?=v_;i;MTQ@v2)R;|-V2V~dWTGHPYxg{kTBM6=`>4zb6) zX4nl4<-@f%gVq!Ly2mQ9#zEUP4ckA=8X;193ViqnVES`WSl^Mq_)5FBB(G<8toG^O zW%WC`fp<>b&S`5o?ejg?hOZ9ZNUi3yTe%bKgU>8YzFX|1gxtOjKnt`7CdfYJ7&YSS zU12)zn=o@c$xN{=KL`~_*N3w#`-CnK%1RHVVy8w~r_fz6`D_;*IYRs39rpb@6Z$B8 zV80H(0@GiMLPt>sP$wr1_IEM^dvm`J4EJ^|PTqS_6nY14?;Kj&Ikdh@TkX|Xj$hmJ z)!-L{*N46zIl9(+bUpw0y_C#!|4^0Gvz?rf>bb4t*OdIl*FUSQD*0Q=*c~OiH2H(F zo94lno(^|zV{o2Bn2vX&Q&%_noAv{Y2YglFCZen|2Z4j@HaScYd}m$kvm$h4Q55eA S!*_+DABD#@lnJq)gZ>8P=tsl= literal 0 HcmV?d00001 diff --git a/mamba.ipynb b/mamba.ipynb new file mode 100644 index 0000000..a67d7f0 --- /dev/null +++ b/mamba.ipynb @@ -0,0 +1,147 @@ +{ + "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": "bf5c66caae4c4b81934a1e3b0c25301d", + "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": 18, + "id": "ffefb0fe-56f5-4d89-816c-9a964445e1fb", + "metadata": {}, + "outputs": [], + "source": [ + "with BuildSketch() as bobo:\n", + " with BuildLine():\n", + " Polyline(\n", + " (0,0),(30,0)\n", + " )\n", + " PolarLine(\n", + " (30,0),\n", + " 20,\n", + " 30\n", + " \n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "e2facbc6-5f0c-45b8-beaf-4a0b3c8f8856", + "metadata": {}, + "outputs": [ + { + "ename": "ValueError", + "evalue": "Unable to repositioned type with respect to local coordinates", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[19], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mshow\u001b[49m\u001b[43m(\u001b[49m\u001b[43mbobo\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m/usr/local/lib/python3.12/site-packages/jupyter_cadquery/show.py:247\u001b[0m, in \u001b[0;36mshow\u001b[0;34m(names, colors, alphas, viewer, anchor, cad_width, height, theme, pinning, progress, glass, tools, tree_width, axes, axes0, grid, ortho, transparent, default_opacity, black_edges, orbit_control, tab, control, collapse, explode, ticks, center_grid, up, zoom, position, quaternion, target, reset_camera, clip_slider_0, clip_slider_1, clip_slider_2, clip_normal_0, clip_normal_1, clip_normal_2, clip_intersection, clip_planes, clip_object_colors, pan_speed, rotate_speed, zoom_speed, deviation, angular_tolerance, edge_accuracy, default_color, default_edgecolor, default_facecolor, default_thickedgecolor, default_vertexcolor, ambient_intensity, direct_intensity, metalness, roughness, render_edges, render_normals, render_mates, render_joints, show_parent, show_sketch_local, helper_scale, mate_scale, debug, timeit, _force_in_debug, *cad_objs)\u001b[0m\n\u001b[1;32m 148\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Show CAD objects in Visual Studio Code\u001b[39;00m\n\u001b[1;32m 149\u001b[0m \u001b[38;5;124;03mParameters\u001b[39;00m\n\u001b[1;32m 150\u001b[0m \u001b[38;5;124;03m cad_objs: All cad objects that should be shown as positional parameters\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 244\u001b[0m \u001b[38;5;124;03m timeit: Show timing information from level 0-3 (default=False)\u001b[39;00m\n\u001b[1;32m 245\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 246\u001b[0m kwargs \u001b[38;5;241m=\u001b[39m none_filter(\u001b[38;5;28mlocals\u001b[39m(), [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcad_objs\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[0;32m--> 247\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_show\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mcad_objs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m/usr/local/lib/python3.12/site-packages/ocp_vscode/show.py:605\u001b[0m, in \u001b[0;36m_show\u001b[0;34m(*cad_objs, **kwargs)\u001b[0m\n\u001b[1;32m 602\u001b[0m progress \u001b[38;5;241m=\u001b[39m Progress([] \u001b[38;5;28;01mif\u001b[39;00m progress \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m [c \u001b[38;5;28;01mfor\u001b[39;00m c \u001b[38;5;129;01min\u001b[39;00m progress])\n\u001b[1;32m 604\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m Timer(timeit, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124moverall\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n\u001b[0;32m--> 605\u001b[0m t, mapping \u001b[38;5;241m=\u001b[39m \u001b[43m_convert\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 606\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mcad_objs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 607\u001b[0m \u001b[43m \u001b[49m\u001b[43mnames\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnames\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 608\u001b[0m \u001b[43m \u001b[49m\u001b[43mcolors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcolors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 609\u001b[0m \u001b[43m \u001b[49m\u001b[43malphas\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43malphas\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 610\u001b[0m \u001b[43m \u001b[49m\u001b[43mprogress\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mprogress\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 611\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 612\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 614\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m _force_in_debug:\n\u001b[1;32m 615\u001b[0m LAST_CALL \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mshow\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", + "File \u001b[0;32m/usr/local/lib/python3.12/site-packages/ocp_vscode/show.py:283\u001b[0m, in \u001b[0;36m_convert\u001b[0;34m(names, colors, alphas, progress, *cad_objs, **kwargs)\u001b[0m\n\u001b[1;32m 280\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m progress \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 281\u001b[0m progress \u001b[38;5;241m=\u001b[39m Progress([c \u001b[38;5;28;01mfor\u001b[39;00m c \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m-+c\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[0;32m--> 283\u001b[0m instances, shapes, config, count_shapes, mapping \u001b[38;5;241m=\u001b[39m \u001b[43m_tessellate\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 284\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mcad_objs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 285\u001b[0m \u001b[43m \u001b[49m\u001b[43mnames\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnames\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 286\u001b[0m \u001b[43m \u001b[49m\u001b[43mcolors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcolors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 287\u001b[0m \u001b[43m \u001b[49m\u001b[43malphas\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43malphas\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 288\u001b[0m \u001b[43m \u001b[49m\u001b[43mprogress\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mprogress\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 289\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 290\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 292\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m config\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdark\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 293\u001b[0m config[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtheme\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdark\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", + "File \u001b[0;32m/usr/local/lib/python3.12/site-packages/ocp_vscode/show.py:175\u001b[0m, in \u001b[0;36m_tessellate\u001b[0;34m(names, colors, alphas, progress, *cad_objs, **kwargs)\u001b[0m\n\u001b[1;32m 173\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m Timer(timeit, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mto_ocpgroup\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m1\u001b[39m):\n\u001b[1;32m 174\u001b[0m changed_config \u001b[38;5;241m=\u001b[39m get_changed_config()\n\u001b[0;32m--> 175\u001b[0m part_group, instances \u001b[38;5;241m=\u001b[39m \u001b[43mto_ocpgroup\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 176\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mcad_objs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 177\u001b[0m \u001b[43m \u001b[49m\u001b[43mnames\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnames\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 178\u001b[0m \u001b[43m \u001b[49m\u001b[43mcolors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcolors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 179\u001b[0m \u001b[43m \u001b[49m\u001b[43malphas\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43malphas\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 180\u001b[0m \u001b[43m \u001b[49m\u001b[43mrender_mates\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mrender_mates\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mchanged_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mrender_mates\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 181\u001b[0m \u001b[43m \u001b[49m\u001b[43mrender_joints\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 182\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mrender_joints\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mchanged_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mrender_joints\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 183\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 184\u001b[0m \u001b[43m \u001b[49m\u001b[43mhelper_scale\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhelper_scale\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mchanged_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhelper_scale\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 185\u001b[0m \u001b[43m \u001b[49m\u001b[43mdefault_color\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 186\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mdefault_color\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mchanged_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mdefault_color\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 187\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 188\u001b[0m \u001b[43m \u001b[49m\u001b[43mshow_parent\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mshow_parent\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mchanged_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mshow_parent\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 189\u001b[0m \u001b[43m \u001b[49m\u001b[43mshow_sketch_local\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 190\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mshow_sketch_local\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mchanged_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mshow_sketch_local\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 191\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 192\u001b[0m \u001b[43m \u001b[49m\u001b[43mprogress\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mprogress\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 193\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 195\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(part_group\u001b[38;5;241m.\u001b[39mobjects) \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m1\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(part_group\u001b[38;5;241m.\u001b[39mobjects[\u001b[38;5;241m0\u001b[39m], OcpGroup):\n\u001b[1;32m 196\u001b[0m loc \u001b[38;5;241m=\u001b[39m part_group\u001b[38;5;241m.\u001b[39mloc\n", + "File \u001b[0;32m/usr/local/lib/python3.12/site-packages/ocp_tessellate/convert.py:1552\u001b[0m, in \u001b[0;36mto_ocpgroup\u001b[0;34m(names, colors, alphas, render_mates, render_joints, helper_scale, default_color, show_parent, show_sketch_local, loc, progress, *cad_objs)\u001b[0m\n\u001b[1;32m 1533\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1534\u001b[0m \u001b[38;5;124;03mCentral converter routine to convert a list of objects to an OcpGroup hierarchy.\u001b[39;00m\n\u001b[1;32m 1535\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1549\u001b[0m \u001b[38;5;124;03m@return: The OcpGroup hierarchy\u001b[39;00m\n\u001b[1;32m 1550\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1551\u001b[0m converter \u001b[38;5;241m=\u001b[39m OcpConverter(progress\u001b[38;5;241m=\u001b[39mprogress)\n\u001b[0;32m-> 1552\u001b[0m ocp_group \u001b[38;5;241m=\u001b[39m \u001b[43mconverter\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mto_ocp\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1553\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mcad_objs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1554\u001b[0m \u001b[43m \u001b[49m\u001b[43mnames\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnames\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1555\u001b[0m \u001b[43m \u001b[49m\u001b[43mcolors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcolors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1556\u001b[0m \u001b[43m \u001b[49m\u001b[43malphas\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43malphas\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1557\u001b[0m \u001b[43m \u001b[49m\u001b[43mloc\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mloc\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1558\u001b[0m \u001b[43m \u001b[49m\u001b[43mrender_mates\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrender_mates\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1559\u001b[0m \u001b[43m \u001b[49m\u001b[43mrender_joints\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrender_joints\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1560\u001b[0m \u001b[43m \u001b[49m\u001b[43mhelper_scale\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mhelper_scale\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1561\u001b[0m \u001b[43m \u001b[49m\u001b[43mdefault_color\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdefault_color\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1562\u001b[0m \u001b[43m \u001b[49m\u001b[43mshow_parent\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mshow_parent\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1563\u001b[0m \u001b[43m \u001b[49m\u001b[43msketch_local\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mshow_sketch_local\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1564\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1566\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ocp_group, converter\u001b[38;5;241m.\u001b[39minstances\n", + "File \u001b[0;32m/usr/local/lib/python3.12/site-packages/ocp_tessellate/convert.py:1445\u001b[0m, in \u001b[0;36mOcpConverter.to_ocp\u001b[0;34m(self, names, colors, alphas, loc, render_mates, render_joints, helper_scale, default_color, show_parent, sketch_local, unroll_compounds, level, *cad_objs)\u001b[0m\n\u001b[1;32m 1443\u001b[0m \u001b[38;5;66;03m# build123d BuildPart, BuildSketch, BuildLine\u001b[39;00m\n\u001b[1;32m 1444\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m is_build123d(cad_obj):\n\u001b[0;32m-> 1445\u001b[0m ocp_obj \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhandle_build123d_builder\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1446\u001b[0m \u001b[43m \u001b[49m\u001b[43mcad_obj\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mobj_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcolor\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43malpha\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msketch_local\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrender_joints\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mlevel\u001b[49m\n\u001b[1;32m 1447\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1449\u001b[0m \u001b[38;5;66;03m# TopoDS_Shape, TopoDS_Compound, TopoDS_Edge, TopoDS_Face, TopoDS_Shell,\u001b[39;00m\n\u001b[1;32m 1450\u001b[0m \u001b[38;5;66;03m# TopoDS_Solid, TopoDS_Vertex, TopoDS_Wire,\u001b[39;00m\n\u001b[1;32m 1451\u001b[0m \u001b[38;5;66;03m# build123d Shape, Compound, Edge, Face, Shell, Solid, Vertex\u001b[39;00m\n\u001b[1;32m 1452\u001b[0m \u001b[38;5;66;03m# CadQuery shapes Solid, Shell, Face, Wire, Edge, Vertex\u001b[39;00m\n\u001b[1;32m 1453\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m (\n\u001b[1;32m 1454\u001b[0m is_topods_shape(cad_obj)\n\u001b[1;32m 1455\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m is_build123d_shape(cad_obj)\n\u001b[1;32m 1456\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m is_cadquery_shape(cad_obj)\n\u001b[1;32m 1457\u001b[0m ):\n", + "File \u001b[0;32m/usr/local/lib/python3.12/site-packages/ocp_tessellate/convert.py:979\u001b[0m, in \u001b[0;36mOcpConverter.handle_build123d_builder\u001b[0;34m(self, cad_obj, obj_name, color, alpha, sketch_local, render_joints, level)\u001b[0m\n\u001b[1;32m 977\u001b[0m \u001b[38;5;66;03m# build123d BuildSketch().sketch\u001b[39;00m\n\u001b[1;32m 978\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m is_build123d_sketch(cad_obj):\n\u001b[0;32m--> 979\u001b[0m obj \u001b[38;5;241m=\u001b[39m \u001b[43mcad_obj\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msketch\u001b[49m\u001b[38;5;241m.\u001b[39mfaces()\n\u001b[1;32m 980\u001b[0m obj_name \u001b[38;5;241m=\u001b[39m get_name(cad_obj, obj_name, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mFace\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 982\u001b[0m \u001b[38;5;66;03m# build123d BuildLine().line\u001b[39;00m\n", + "File \u001b[0;32m/usr/local/lib/python3.12/site-packages/build123d/build_sketch.py:85\u001b[0m, in \u001b[0;36mBuildSketch.sketch\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 83\u001b[0m global_objs \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m 84\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m plane \u001b[38;5;129;01min\u001b[39;00m workplanes:\n\u001b[0;32m---> 85\u001b[0m global_objs\u001b[38;5;241m.\u001b[39mappend(\u001b[43mplane\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfrom_local_coords\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_obj\u001b[49m\u001b[43m)\u001b[49m)\n\u001b[1;32m 86\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m Sketch(Compound(global_objs)\u001b[38;5;241m.\u001b[39mwrapped)\n", + "File \u001b[0;32m/usr/local/lib/python3.12/site-packages/build123d/geometry.py:2436\u001b[0m, in \u001b[0;36mPlane.from_local_coords\u001b[0;34m(self, obj)\u001b[0m\n\u001b[1;32m 2425\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21mfrom_local_coords\u001b[39m(\u001b[38;5;28mself\u001b[39m, obj: Union[\u001b[38;5;28mtuple\u001b[39m, Vector, Any, BoundBox]):\n\u001b[1;32m 2426\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Reposition the object relative from this plane\u001b[39;00m\n\u001b[1;32m 2427\u001b[0m \n\u001b[1;32m 2428\u001b[0m \u001b[38;5;124;03m Args:\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 2434\u001b[0m \n\u001b[1;32m 2435\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m-> 2436\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_to_from_local_coords\u001b[49m\u001b[43m(\u001b[49m\u001b[43mobj\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m/usr/local/lib/python3.12/site-packages/build123d/geometry.py:2407\u001b[0m, in \u001b[0;36mPlane._to_from_local_coords\u001b[0;34m(self, obj, to_from)\u001b[0m\n\u001b[1;32m 2405\u001b[0m return_value \u001b[38;5;241m=\u001b[39m obj\u001b[38;5;241m.\u001b[39mtransform_shape(transform_matrix)\n\u001b[1;32m 2406\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 2407\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 2408\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUnable to repositioned type \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mtype\u001b[39m(obj)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m with respect to local coordinates\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 2409\u001b[0m )\n\u001b[1;32m 2410\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m return_value\n", + "\u001b[0;31mValueError\u001b[0m: Unable to repositioned type with respect to local coordinates" + ] + } + ], + "source": [ + "show(bobo)" + ] + } + ], + "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 +} diff --git a/snippets_panel.py b/snippets_panel.py new file mode 100644 index 0000000..8f8eaf9 --- /dev/null +++ b/snippets_panel.py @@ -0,0 +1,55 @@ +from IPython.display import display +from IPython import get_ipython +import ipywidgets as widgets + +def show_snippet_panel(): + snippets = { + "📥 Start": ''' +from build123d import * +from jupyter_cadquery import show, show_all,open_viewer, show_clear +from IPython.display import display +import ipywidgets as widgets''', + + "🧲 Import STEP": '''from build123d import * +model = import_step("element.step") +show_object(model)''', + + "🖥️ view": ''' +cv = None # viewer globalny + +def open_bottom(b): + global cv + print("Otwieram viewer (split-bottom)") + cv = open_viewer("Build123d", anchor="split-bottom") + +def open_right(b): + global cv + print("Otwieram viewer (right)") + cv = open_viewer("Build123d", anchor="right") + +# Przycisk 1 – bottom +btn_bottom = widgets.Button(description="Viewer dół") +btn_bottom.on_click(open_bottom) + +# Przycisk 2 – right +btn_right = widgets.Button(description="Viewer prawo") +btn_right.on_click(open_right) + +# Wyświetl przyciski +display(widgets.HBox([btn_bottom, btn_right])) + ''' + } + + dropdown = widgets.Dropdown( + options=["-- wybierz snippet --"] + list(snippets.keys()), + description="Snippet:" + ) + + def on_select(change): + key = change["new"] + if key != "-- wybierz snippet --": + get_ipython().set_next_input(snippets[key], replace=False) + dropdown.value = "-- wybierz snippet --" + + dropdown.observe(on_select, names="value") + display(dropdown) diff --git a/t1.svg b/t1.svg new file mode 100644 index 0000000..a46f223 --- /dev/null +++ b/t1.svg @@ -0,0 +1,8 @@ + + + + + +b'Sketch' + + \ No newline at end of file