{ "cells": [ { "cell_type": "markdown", "id": "3793a79f", "metadata": {}, "source": [ "# Sketching: Basic usage\n", "\n", "This example shows how to use basic PyAnsys Geometry sketching capabilities." ] }, { "cell_type": "markdown", "id": "e22382bf", "metadata": {}, "source": [ "## Perform required imports\n", "\n", "Perform the required imports." ] }, { "cell_type": "code", "execution_count": 1, "id": "8ec13f4a", "metadata": { "execution": { "iopub.execute_input": "2024-10-31T14:35:10.269193Z", "iopub.status.busy": "2024-10-31T14:35:10.269193Z", "iopub.status.idle": "2024-10-31T14:35:12.697462Z", "shell.execute_reply": "2024-10-31T14:35:12.697462Z" } }, "outputs": [], "source": [ "from ansys.geometry.core.misc.units import UNITS as u\n", "from ansys.geometry.core.sketch import Sketch" ] }, { "cell_type": "markdown", "id": "8a06b608", "metadata": {}, "source": [ "## Create a sketch\n", "\n", "Sketches are fundamental objects for drawing basic shapes like lines, segments, circles,\n", "ellipses, arcs, and polygons.\n", "\n", "You create a ``Sketch`` instance by defining a drawing plane. To define a plane, you\n", "declare a point and two fundamental orthogonal directions." ] }, { "cell_type": "code", "execution_count": 2, "id": "46617384", "metadata": { "execution": { "iopub.execute_input": "2024-10-31T14:35:12.697462Z", "iopub.status.busy": "2024-10-31T14:35:12.697462Z", "iopub.status.idle": "2024-10-31T14:35:12.705578Z", "shell.execute_reply": "2024-10-31T14:35:12.705578Z" } }, "outputs": [], "source": [ "from ansys.geometry.core.math import Plane, Point2D, Point3D" ] }, { "cell_type": "markdown", "id": "45e252ac", "metadata": {}, "source": [ "Define a plane for creating a sketch." ] }, { "cell_type": "code", "execution_count": 3, "id": "23dfdaa0", "metadata": { "execution": { "iopub.execute_input": "2024-10-31T14:35:12.705578Z", "iopub.status.busy": "2024-10-31T14:35:12.705578Z", "iopub.status.idle": "2024-10-31T14:35:12.713455Z", "shell.execute_reply": "2024-10-31T14:35:12.713455Z" } }, "outputs": [], "source": [ "# Define the origin point of the plane\n", "origin = Point3D([1, 1, 1])\n", "\n", "# Create a plane located in previous point with desired fundamental directions\n", "plane = Plane(\n", " origin, direction_x=[1, 0, 0], direction_y=[0, -1, 1]\n", ")\n", "\n", "# Instantiate a new sketch object from previous plane\n", "sketch = Sketch(plane)" ] }, { "cell_type": "markdown", "id": "f9075f54", "metadata": {}, "source": [ "## Draw shapes\n", "\n", "To draw different shapes in the sketch, you use ``draw`` methods." ] }, { "cell_type": "markdown", "id": "abea47bb", "metadata": {}, "source": [ "### Draw a circle\n", "\n", "You draw a circle in a sketch by specifying the center and radius." ] }, { "cell_type": "code", "execution_count": 4, "id": "a5bb9218", "metadata": { "execution": { "iopub.execute_input": "2024-10-31T14:35:12.713455Z", "iopub.status.busy": "2024-10-31T14:35:12.713455Z", "iopub.status.idle": "2024-10-31T14:35:15.025226Z", "shell.execute_reply": "2024-10-31T14:35:15.025226Z" } }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "73ea95df25ea4e0ca9fda91de9db9b2f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "EmbeddableWidget(value='" } }, "7595bdd0517c422796d4e22418f397e7": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "80314dfbe4c4470c8acf96101e684130": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_7595bdd0517c422796d4e22418f397e7", "placeholder": "​", "style": "IPY_MODEL_30d8b8073f0847d69faff46c2db51288", "value": "" } }, "8122fbf04d0c4165908184edebfbbaef": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_edc8d3502e624e958e906e552daa890d", "placeholder": "​", "style": "IPY_MODEL_6090a0eea5d44c478a57dc4a73d02d9f", "value": "" } }, "9d9615aab8d445b89cd31feb3f3b81b7": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_4da8db7836aa43a0b66805b1935b80ce", "placeholder": "​", "style": "IPY_MODEL_16299a61eb524cc0886edc037764850d", "value": "" } }, "c7012ccce577462c95d8fa66d6ee7aa9": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_2ef4ffdc82924096aca146b7d4460a7b", "placeholder": "​", "style": "IPY_MODEL_3ea80796d5064cfeb5663f4a9a5b3ec3", "value": "" } }, "ce86ff3798af4dc79546341cf5f0572a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "d20316e7d7dd4d929e3efb0b67b63bcb": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_1a9ab1f151dc4003a83f0be9de3d503d", "placeholder": "​", "style": "IPY_MODEL_03c723d973f34511b134a1202b904f93", "value": "" } }, "d3a0f3e858234ed4a4fcbab7dad4dd6c": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "d3d94d2c158b4828873e91d9d383910d": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_05695708151e47c39c273fba124aea81", "placeholder": "​", "style": "IPY_MODEL_10b279c61c15433a9a7384ebed30001b", "value": "" } }, "da13737015534478a3c60ae3ff82688d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "dcc0b3cc7ceb45c0b31f27e94b84d6d2": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_2734da51368648e39a86a5772ba4e76f", "placeholder": "​", "style": "IPY_MODEL_d3a0f3e858234ed4a4fcbab7dad4dd6c", "value": "" } }, "edc8d3502e624e958e906e552daa890d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "f6b19924fdf9437ba5abc7be52e795ba": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_1831a64b6eb04c19bfa505daef5d94ab", "placeholder": "​", "style": "IPY_MODEL_ce86ff3798af4dc79546341cf5f0572a", "value": "" } }, "fb553135fa6043bba2d555ba9db5329a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_da13737015534478a3c60ae3ff82688d", "placeholder": "​", "style": "IPY_MODEL_2daecadc64fe4aef90e66a1e07b7dc8f", "value": "" } } }, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 5 }