{
"cells": [
{
"cell_type": "markdown",
"id": "22a38332",
"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": "f2f96c82",
"metadata": {},
"source": [
"## Perform required imports"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "6eb4e295",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-19T20:10:25.308376Z",
"iopub.status.busy": "2025-02-19T20:10:25.306350Z",
"iopub.status.idle": "2025-02-19T20:10:29.465709Z",
"shell.execute_reply": "2025-02-19T20:10:29.465709Z"
}
},
"outputs": [],
"source": [
"from pathlib import Path\n",
"import requests\n",
"\n",
"from ansys.geometry.core import launch_modeler"
]
},
{
"cell_type": "markdown",
"id": "5cd15b9e",
"metadata": {},
"source": [
"The file for this example is in the integration tests folder and can be downloaded."
]
},
{
"cell_type": "markdown",
"id": "e4955604",
"metadata": {},
"source": [
"## Download the example file"
]
},
{
"cell_type": "markdown",
"id": "7a199e53",
"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": "33644cbd",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-19T20:10:29.469761Z",
"iopub.status.busy": "2025-02-19T20:10:29.469761Z",
"iopub.status.idle": "2025-02-19T20:10:29.720524Z",
"shell.execute_reply": "2025-02-19T20:10:29.720524Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"File is downloaded to C:\\Users\\ansys\\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": "ef3d7ddf",
"metadata": {},
"source": [
"## Import a design with parameters"
]
},
{
"cell_type": "markdown",
"id": "733adc9b",
"metadata": {},
"source": [
"Import the model using the ``open_file()`` method of the modeler."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "e018bb58",
"metadata": {
"execution": {
"iopub.execute_input": "2025-02-19T20:10:29.724563Z",
"iopub.status.busy": "2025-02-19T20:10:29.724563Z",
"iopub.status.idle": "2025-02-19T20:10:34.315603Z",
"shell.execute_reply": "2025-02-19T20:10:34.315603Z"
}
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "796f11d595554079baa54ae5588a5d4f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"EmbeddableWidget(value='"
}
},
"b7fd8506d9d649788e13dca79fcb3e2d": {
"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": ""
}
},
"c734a9dd9dd44d4fbc07a5ebae22da9e": {
"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_d5de8b7426814a15b4e56925d107450a",
"placeholder": "",
"style": "IPY_MODEL_b7fd8506d9d649788e13dca79fcb3e2d",
"value": ""
}
},
"d5de8b7426814a15b4e56925d107450a": {
"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
}