{ "cells": [ { "cell_type": "markdown", "id": "aececd27", "metadata": { "papermill": { "duration": 0.001311, "end_time": "2026-03-19T15:23:45.592085", "exception": false, "start_time": "2026-03-19T15:23:45.590774", "status": "completed" }, "tags": [] }, "source": [ "(History Query Example)=\n", "# History Query Script Examples" ] }, { "cell_type": "markdown", "id": "8f03602b", "metadata": { "papermill": { "duration": 0.001334, "end_time": "2026-03-19T15:23:45.594780", "exception": false, "start_time": "2026-03-19T15:23:45.593446", "status": "completed" }, "tags": [] }, "source": [ "Download the [ExampleModel.fez](https://github.com/Rocscience/rs2-scripting/blob/main/docs/example_code/example_models/ExampleModel.fez) for this example." ] }, { "cell_type": "code", "execution_count": 1, "id": "efd68734", "metadata": { "execution": { "iopub.execute_input": "2026-03-19T15:23:45.598829Z", "iopub.status.busy": "2026-03-19T15:23:45.598563Z", "iopub.status.idle": "2026-03-19T15:24:02.061125Z", "shell.execute_reply": "2026-03-19T15:24:02.059727Z" }, "papermill": { "duration": 16.466868, "end_time": "2026-03-19T15:24:02.063104", "exception": false, "start_time": "2026-03-19T15:23:45.596236", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "from rs2.modeler.RS2Modeler import RS2Modeler\n", "from rs2.interpreter.RS2Interpreter import RS2Interpreter\n", "from rs2.interpreter.InterpreterEnums import *\n", "from rs2.interpreter.InterpreterGraphEnums import *\n", "import os\n", "\n", "current_dir = os.path.dirname(os.path.abspath(\"\")) \n", "RS2Modeler.startApplication(port=60058)\n", "modeler = RS2Modeler(port=60058)\n", "RS2Interpreter.startApplication(port=60059)\n", "interpreter = RS2Interpreter(port=60059)\n", "modelPath = rf\"{current_dir}\\example_models\\ExampleModel.fez\"\n", "modeler_model = modeler.openFile(modelPath)\n", "\n", "modeler_model.AddHistoryQueryPoint(history_query_name=\"Testing Point 1\", x=-3.1, y=2.8)\n", "\n", "modeler_model.RemoveHistoryQueryPoint(\"HQ 1\")\n", "\n", "interpreter_model = interpreter.openFile(modelPath)\n", "results = interpreter_model.GetHistoryQueryResults(hq_name=\"HQ 2\", \n", " horizontal_axis=HistoryQueryGraphEnums.HorizontalAxisTypes.TIME,\n", " vertical_axis=HistoryQueryGraphEnums.VerticalAxisTypes.EFFECTIVE_STRESS_YY, \n", " stages=[1, 2])\n", "\n", "stage_number = 1\n", "results_for_stage_1 = results[stage_number]\n", "\n", "for data in results_for_stage_1:\n", " x_coord = data.GetXCoordinate()\n", " y_coord = data.GetYCoordinate()\n", " horizontal_result = data.GetHorizontalAxisResult()\n", " vertical_result = data.GetVerticalAxisResult()\n", "\n", "modeler_model.close()\n", "interpreter_model.close()\n", "modeler.closeProgram()\n", "interpreter.closeProgram()" ] } ], "metadata": { "kernelspec": { "display_name": "myenv", "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.13.0" }, "papermill": { "default_parameters": {}, "duration": 18.009703, "end_time": "2026-03-19T15:24:02.308814", "environment_variables": {}, "exception": null, "input_path": "C:\\Users\\GraceHu\\source\\repos\\RS2_Python_Client_Library\\docs\\example_code\\results\\history_query_script_example.ipynb", "output_path": "C:\\Users\\GraceHu\\source\\repos\\RS2_Python_Client_Library\\docs\\example_code\\results\\history_query_script_example.ipynb", "parameters": {}, "start_time": "2026-03-19T15:23:44.299111", "version": "2.6.0" } }, "nbformat": 4, "nbformat_minor": 5 }