{ "cells": [ { "cell_type": "markdown", "id": "dcd832ce", "metadata": {}, "source": [ "# Modeling: Using design parameters\n", "\n", "You can read and update parameters that are part of the design.\n", "The simple design in this example has two associated parameters." ] }, { "cell_type": "markdown", "id": "b1781d5b", "metadata": {}, "source": [ "## Perform required imports" ] }, { "cell_type": "code", "execution_count": 1, "id": "4ede0ec7", "metadata": { "execution": { "iopub.execute_input": "2025-02-18T15:28:52.516206Z", "iopub.status.busy": "2025-02-18T15:28:52.516206Z", "iopub.status.idle": "2025-02-18T15:28:56.130350Z", "shell.execute_reply": "2025-02-18T15:28:56.130350Z" } }, "outputs": [], "source": [ "from pathlib import Path\n", "import requests\n", "\n", "from ansys.geometry.core import launch_modeler" ] }, { "cell_type": "markdown", "id": "c6040968", "metadata": {}, "source": [ "The file for this example is in the integration tests folder and can be downloaded." ] }, { "cell_type": "markdown", "id": "4b46518c", "metadata": {}, "source": [ "## Download the example file" ] }, { "cell_type": "markdown", "id": "1975ad37", "metadata": {}, "source": [ "Download the file for this example from the integration tests folder in the PyAnsys Geometry repository." ] }, { "cell_type": "code", "execution_count": 2, "id": "1a8f2a95", "metadata": { "execution": { "iopub.execute_input": "2025-02-18T15:28:56.130350Z", "iopub.status.busy": "2025-02-18T15:28:56.130350Z", "iopub.status.idle": "2025-02-18T15:28:56.392001Z", "shell.execute_reply": "2025-02-18T15:28:56.392001Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "File is downloaded to C:\\Users\\Public\\actions-runner\\_work\\pyansys-geometry\\pyansys-geometry\\doc\\source\\examples\\03_modeling\\blockswithparameters.dsco\n" ] } ], "source": [ "def download_file(url, filename):\n", " \"\"\"Download a file from a URL and save it to a local file.\"\"\"\n", " response = requests.get(url)\n", " response.raise_for_status() # Check if the request was successful\n", " with open(filename, 'wb') as file:\n", " file.write(response.content)\n", "\n", "# URL of the file to download\n", "url = \"https://raw.githubusercontent.com/ansys/pyansys-geometry/main/tests/integration/files/blockswithparameters.dsco\"\n", "\n", "# Local path to save the file to\n", "file_path = Path.cwd() / \"blockswithparameters.dsco\"\n", "\n", "# Download the file\n", "download_file(url, file_path)\n", "print(f\"File is downloaded to {file_path}\")" ] }, { "cell_type": "markdown", "id": "7216b529", "metadata": {}, "source": [ "## Import a design with parameters" ] }, { "cell_type": "markdown", "id": "63fa244d", "metadata": {}, "source": [ "Import the model using the ``open_file()`` method of the modeler." ] }, { "cell_type": "code", "execution_count": 3, "id": "b2580447", "metadata": { "execution": { "iopub.execute_input": "2025-02-18T15:28:56.392001Z", "iopub.status.busy": "2025-02-18T15:28:56.392001Z", "iopub.status.idle": "2025-02-18T15:28:59.634156Z", "shell.execute_reply": "2025-02-18T15:28:59.634156Z" } }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "20d9440e2f2b4bf8b763ad4bebe44bb6", "version_major": 2, "version_minor": 0 }, "text/plain": [ "EmbeddableWidget(value='" } }, "4148f8ba02094291aac8ae4070ec6067": { "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_64b35fd6736b4775b45b5b2eb7f6753b", "placeholder": "​", "style": "IPY_MODEL_a17d780b650f4c518779c4bbd894b835", "value": "" } }, "64b35fd6736b4775b45b5b2eb7f6753b": { "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 } }, "a17d780b650f4c518779c4bbd894b835": { "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": "" } }, "af4859f4e52f46189bb047a3e6c0a014": { "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": "" } }, "cb46728f8f434e81ab7be697f8c734b1": { "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 } } }, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 5 }