{ "cells": [ { "cell_type": "markdown", "id": "4997d777", "metadata": { "papermill": { "duration": 0.006447, "end_time": "2026-03-13T21:14:51.389323", "exception": false, "start_time": "2026-03-13T21:14:51.382876", "status": "completed" }, "tags": [] }, "source": [ "(beam_example)=\n", "# Beam Script Examples" ] }, { "cell_type": "markdown", "id": "652c41de", "metadata": { "papermill": { "duration": 0.007828, "end_time": "2026-03-13T21:14:51.403880", "exception": false, "start_time": "2026-03-13T21:14:51.396052", "status": "completed" }, "tags": [] }, "source": [ "Download the [blankModel.rs3v3](https://github.com/Rocscience/rs3-scripting/tree/main/docs/example_code/example_models/blankModel.rs3v3) for this example." ] }, { "cell_type": "code", "execution_count": 1, "id": "f3288b4a", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:14:51.423217Z", "iopub.status.busy": "2026-03-13T21:14:51.422852Z", "iopub.status.idle": "2026-03-13T21:14:51.677650Z", "shell.execute_reply": "2026-03-13T21:14:51.676305Z" }, "papermill": { "duration": 0.26707, "end_time": "2026-03-13T21:14:51.678895", "exception": false, "start_time": "2026-03-13T21:14:51.411825", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "from rs3.RS3Modeler import RS3Modeler\n", "from rs3.properties.PropertyEnums import *\n", "import os\n", "import shutil" ] }, { "cell_type": "markdown", "id": "bdd2f737", "metadata": { "papermill": { "duration": 0.007678, "end_time": "2026-03-13T21:14:51.694422", "exception": false, "start_time": "2026-03-13T21:14:51.686744", "status": "completed" }, "tags": [] }, "source": [ "Get the current folder directory." ] }, { "cell_type": "code", "execution_count": 2, "id": "5fceeae1", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:14:51.715071Z", "iopub.status.busy": "2026-03-13T21:14:51.714630Z", "iopub.status.idle": "2026-03-13T21:14:51.721171Z", "shell.execute_reply": "2026-03-13T21:14:51.719221Z" }, "papermill": { "duration": 0.018656, "end_time": "2026-03-13T21:14:51.722489", "exception": false, "start_time": "2026-03-13T21:14:51.703833", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "current_dir = os.path.abspath(\"\")" ] }, { "cell_type": "markdown", "id": "561e8648", "metadata": { "papermill": { "duration": 0.007639, "end_time": "2026-03-13T21:14:51.736749", "exception": false, "start_time": "2026-03-13T21:14:51.729110", "status": "completed" }, "tags": [] }, "source": [ "Specify a port number that is not in use and start the RS3 program." ] }, { "cell_type": "code", "execution_count": 3, "id": "15e37e90", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:14:51.754250Z", "iopub.status.busy": "2026-03-13T21:14:51.753852Z", "iopub.status.idle": "2026-03-13T21:15:21.089044Z", "shell.execute_reply": "2026-03-13T21:15:21.087762Z" }, "papermill": { "duration": 29.346601, "end_time": "2026-03-13T21:15:21.090388", "exception": false, "start_time": "2026-03-13T21:14:51.743787", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2026-03-13 17:14:51,760 - Rocscience.RS3 - INFO - Attempting to start the application at C:\\Program Files\\Rocscience\\RS3\\RS3 and binding server to port 60301...\n" ] } ], "source": [ "port = 60301\n", "RS3Modeler.startApplication(port)" ] }, { "cell_type": "markdown", "id": "d2432a5b", "metadata": { "papermill": { "duration": 0.008108, "end_time": "2026-03-13T21:15:21.106376", "exception": false, "start_time": "2026-03-13T21:15:21.098268", "status": "completed" }, "tags": [] }, "source": [ "Connect with the RS3 Modeler." ] }, { "cell_type": "code", "execution_count": 4, "id": "48134329", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:21.125107Z", "iopub.status.busy": "2026-03-13T21:15:21.124725Z", "iopub.status.idle": "2026-03-13T21:15:21.348303Z", "shell.execute_reply": "2026-03-13T21:15:21.346812Z" }, "papermill": { "duration": 0.235359, "end_time": "2026-03-13T21:15:21.350177", "exception": false, "start_time": "2026-03-13T21:15:21.114818", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "modeler = RS3Modeler(port)" ] }, { "cell_type": "markdown", "id": "558842a6", "metadata": { "papermill": { "duration": 0.009199, "end_time": "2026-03-13T21:15:21.368604", "exception": false, "start_time": "2026-03-13T21:15:21.359405", "status": "completed" }, "tags": [] }, "source": [ "For the demonstration purposes only, the model is copied for reuse. You may change the model path to your own model path." ] }, { "cell_type": "code", "execution_count": 5, "id": "8e5cba89", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:21.385862Z", "iopub.status.busy": "2026-03-13T21:15:21.385433Z", "iopub.status.idle": "2026-03-13T21:15:21.412853Z", "shell.execute_reply": "2026-03-13T21:15:21.410943Z" }, "papermill": { "duration": 0.038758, "end_time": "2026-03-13T21:15:21.414810", "exception": false, "start_time": "2026-03-13T21:15:21.376052", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "blankModelPath = rf\"{os.path.dirname(current_dir)}\\example_models\\blankModel.rs3v3\"\n", "copiedModelPath = rf\"{os.path.dirname(current_dir)}\\example_models\\copiedModel.rs3v3\"\n", "_ = shutil.copy(blankModelPath, copiedModelPath)" ] }, { "cell_type": "markdown", "id": "b6e405e2", "metadata": { "papermill": { "duration": 0.007287, "end_time": "2026-03-13T21:15:21.430026", "exception": false, "start_time": "2026-03-13T21:15:21.422739", "status": "completed" }, "tags": [] }, "source": [ "Open the copied model file." ] }, { "cell_type": "code", "execution_count": 6, "id": "12597746", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:21.448180Z", "iopub.status.busy": "2026-03-13T21:15:21.447740Z", "iopub.status.idle": "2026-03-13T21:15:33.319647Z", "shell.execute_reply": "2026-03-13T21:15:33.317199Z" }, "papermill": { "duration": 11.883751, "end_time": "2026-03-13T21:15:33.321978", "exception": false, "start_time": "2026-03-13T21:15:21.438227", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "model = modeler.openFile(copiedModelPath)" ] }, { "cell_type": "markdown", "id": "8178f89d", "metadata": { "papermill": { "duration": 0.013664, "end_time": "2026-03-13T21:15:33.354117", "exception": false, "start_time": "2026-03-13T21:15:33.340453", "status": "completed" }, "tags": [] }, "source": [ "## 1. Create and Get Beam" ] }, { "cell_type": "markdown", "id": "91094ee0", "metadata": { "papermill": { "duration": 0.014996, "end_time": "2026-03-13T21:15:33.383657", "exception": false, "start_time": "2026-03-13T21:15:33.368661", "status": "completed" }, "tags": [] }, "source": [ "Get the first beam in the list." ] }, { "cell_type": "code", "execution_count": 7, "id": "f538154b", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:33.412057Z", "iopub.status.busy": "2026-03-13T21:15:33.411453Z", "iopub.status.idle": "2026-03-13T21:15:33.810970Z", "shell.execute_reply": "2026-03-13T21:15:33.809321Z" }, "papermill": { "duration": 0.414616, "end_time": "2026-03-13T21:15:33.812184", "exception": false, "start_time": "2026-03-13T21:15:33.397568", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "'Beam 1'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beam1 = model.getAllBeamProperties()[0]\n", "beam1.getBeamName()" ] }, { "cell_type": "markdown", "id": "592a6630", "metadata": { "papermill": { "duration": 0.00832, "end_time": "2026-03-13T21:15:33.828634", "exception": false, "start_time": "2026-03-13T21:15:33.820314", "status": "completed" }, "tags": [] }, "source": [ "Create a new beam and get the beam by name." ] }, { "cell_type": "code", "execution_count": 8, "id": "749fa49f", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:33.847465Z", "iopub.status.busy": "2026-03-13T21:15:33.847060Z", "iopub.status.idle": "2026-03-13T21:15:34.001642Z", "shell.execute_reply": "2026-03-13T21:15:33.999528Z" }, "papermill": { "duration": 0.166746, "end_time": "2026-03-13T21:15:34.004054", "exception": false, "start_time": "2026-03-13T21:15:33.837308", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "'Beam 2'" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beam2Name = \"Beam 2\"\n", "model.createNewBeamProperty(beam2Name)\n", "beam2 = model.getBeamPropertyByName(beam2Name)\n", "beam2.getBeamName()" ] }, { "cell_type": "markdown", "id": "e099dd78", "metadata": { "papermill": { "duration": 0.00771, "end_time": "2026-03-13T21:15:34.022544", "exception": false, "start_time": "2026-03-13T21:15:34.014834", "status": "completed" }, "tags": [] }, "source": [ "## 2. Set Beam Properties" ] }, { "cell_type": "code", "execution_count": 9, "id": "54e32148", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:34.043048Z", "iopub.status.busy": "2026-03-13T21:15:34.042508Z", "iopub.status.idle": "2026-03-13T21:15:34.096188Z", "shell.execute_reply": "2026-03-13T21:15:34.094429Z" }, "papermill": { "duration": 0.066657, "end_time": "2026-03-13T21:15:34.098070", "exception": false, "start_time": "2026-03-13T21:15:34.031413", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beam1.setBeamType(BeamType.TRUSS)\n", "beam1.getBeamType()" ] }, { "cell_type": "code", "execution_count": 10, "id": "11b4011f", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:34.128121Z", "iopub.status.busy": "2026-03-13T21:15:34.127640Z", "iopub.status.idle": "2026-03-13T21:15:34.152813Z", "shell.execute_reply": "2026-03-13T21:15:34.150488Z" }, "papermill": { "duration": 0.044096, "end_time": "2026-03-13T21:15:34.155011", "exception": false, "start_time": "2026-03-13T21:15:34.110915", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{'YoungsModulus': 30000000.0,\n", " 'PoissonsRatio': 0.2,\n", " 'ShearStrength': 5000.0,\n", " 'Area': 0.5,\n", " 'UnitWeight': 20.0,\n", " 'PreTensioning': False,\n", " 'PreTensioningForce': 0.0,\n", " 'IncludeWeightInStressAnalysis': False,\n", " 'CompressiveStrength': 35000.0,\n", " 'TensileStrength': 5000.0,\n", " 'ResidualCompressiveStrength': 5000.0,\n", " 'ResidualTensileStrength': 0.0}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beam1.Truss.getProperties()" ] }, { "cell_type": "code", "execution_count": 11, "id": "c179e051", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:34.177673Z", "iopub.status.busy": "2026-03-13T21:15:34.177219Z", "iopub.status.idle": "2026-03-13T21:15:34.217635Z", "shell.execute_reply": "2026-03-13T21:15:34.215533Z" }, "papermill": { "duration": 0.054214, "end_time": "2026-03-13T21:15:34.219561", "exception": false, "start_time": "2026-03-13T21:15:34.165347", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beam1.Truss.setMaterialType(MaterialType.PLASTIC)\n", "beam1.Truss.getMaterialType()" ] }, { "cell_type": "code", "execution_count": 12, "id": "f825d655", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:34.251338Z", "iopub.status.busy": "2026-03-13T21:15:34.250755Z", "iopub.status.idle": "2026-03-13T21:15:34.368460Z", "shell.execute_reply": "2026-03-13T21:15:34.366220Z" }, "papermill": { "duration": 0.134127, "end_time": "2026-03-13T21:15:34.370035", "exception": false, "start_time": "2026-03-13T21:15:34.235908", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{'YoungsModulus': 30000000.0,\n", " 'PoissonsRatio': 0.2,\n", " 'ShearStrength': 5000.0,\n", " 'Area': 0.2,\n", " 'UnitWeight': 15.1,\n", " 'PreTensioning': False,\n", " 'PreTensioningForce': 0.0,\n", " 'IncludeWeightInStressAnalysis': False,\n", " 'CompressiveStrength': 35000.0,\n", " 'TensileStrength': 5000.0,\n", " 'ResidualCompressiveStrength': 5000.0,\n", " 'ResidualTensileStrength': 0.0}" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beam1.Truss.setProperties(Area=0.2, UnitWeight=15.1)\n", "beam1Properties = beam1.Truss.getProperties()\n", "beam1Properties" ] }, { "cell_type": "markdown", "id": "719207a0", "metadata": { "papermill": { "duration": 0.011191, "end_time": "2026-03-13T21:15:34.390279", "exception": false, "start_time": "2026-03-13T21:15:34.379088", "status": "completed" }, "tags": [] }, "source": [ "## 3. Copy Beam Properties" ] }, { "cell_type": "code", "execution_count": 13, "id": "5734fb77", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:34.414109Z", "iopub.status.busy": "2026-03-13T21:15:34.413674Z", "iopub.status.idle": "2026-03-13T21:15:34.450174Z", "shell.execute_reply": "2026-03-13T21:15:34.448188Z" }, "papermill": { "duration": 0.052646, "end_time": "2026-03-13T21:15:34.452827", "exception": false, "start_time": "2026-03-13T21:15:34.400181", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beam2.setBeamType(BeamType.TRUSS)\n", "beam2.getBeamType()" ] }, { "cell_type": "code", "execution_count": 14, "id": "ab017b80", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:34.489853Z", "iopub.status.busy": "2026-03-13T21:15:34.488839Z", "iopub.status.idle": "2026-03-13T21:15:34.514002Z", "shell.execute_reply": "2026-03-13T21:15:34.512337Z" }, "papermill": { "duration": 0.045864, "end_time": "2026-03-13T21:15:34.515490", "exception": false, "start_time": "2026-03-13T21:15:34.469626", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{'YoungsModulus': 30000000.0,\n", " 'PoissonsRatio': 0.2,\n", " 'ShearStrength': 5000.0,\n", " 'Area': 0.5,\n", " 'UnitWeight': 20.0,\n", " 'PreTensioning': False,\n", " 'PreTensioningForce': 0.0,\n", " 'IncludeWeightInStressAnalysis': False,\n", " 'CompressiveStrength': 35000.0,\n", " 'TensileStrength': 5000.0,\n", " 'ResidualCompressiveStrength': 5000.0,\n", " 'ResidualTensileStrength': 0.0}" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beam2.Truss.getProperties()" ] }, { "cell_type": "code", "execution_count": 15, "id": "86c2bc42", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:34.534883Z", "iopub.status.busy": "2026-03-13T21:15:34.534450Z", "iopub.status.idle": "2026-03-13T21:15:35.048042Z", "shell.execute_reply": "2026-03-13T21:15:35.046556Z" }, "papermill": { "duration": 0.524558, "end_time": "2026-03-13T21:15:35.049309", "exception": false, "start_time": "2026-03-13T21:15:34.524751", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{'YoungsModulus': 30000000.0,\n", " 'PoissonsRatio': 0.2,\n", " 'ShearStrength': 5000.0,\n", " 'Area': 0.2,\n", " 'UnitWeight': 15.1,\n", " 'PreTensioning': False,\n", " 'PreTensioningForce': 0.0,\n", " 'IncludeWeightInStressAnalysis': False,\n", " 'CompressiveStrength': 35000.0,\n", " 'TensileStrength': 5000.0,\n", " 'ResidualCompressiveStrength': 5000.0,\n", " 'ResidualTensileStrength': 0.0}" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beam2.Truss.setProperties(**beam1Properties)\n", "beam2.Truss.getProperties()" ] }, { "cell_type": "markdown", "id": "5b6f07e6", "metadata": { "papermill": { "duration": 0.007954, "end_time": "2026-03-13T21:15:35.068372", "exception": false, "start_time": "2026-03-13T21:15:35.060418", "status": "completed" }, "tags": [] }, "source": [ "## 4. Set Stage Factors" ] }, { "cell_type": "markdown", "id": "c64ec2e5", "metadata": { "papermill": { "duration": 0.009433, "end_time": "2026-03-13T21:15:35.089519", "exception": false, "start_time": "2026-03-13T21:15:35.080086", "status": "completed" }, "tags": [] }, "source": [ "Turn on the stage factors of beams." ] }, { "cell_type": "code", "execution_count": 16, "id": "c488dd48", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:35.111523Z", "iopub.status.busy": "2026-03-13T21:15:35.111091Z", "iopub.status.idle": "2026-03-13T21:15:35.147433Z", "shell.execute_reply": "2026-03-13T21:15:35.144833Z" }, "papermill": { "duration": 0.050357, "end_time": "2026-03-13T21:15:35.149689", "exception": false, "start_time": "2026-03-13T21:15:35.099332", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "beam1.setApplyStageFactors(True)" ] }, { "cell_type": "markdown", "id": "78cf4674", "metadata": { "papermill": { "duration": 0.015972, "end_time": "2026-03-13T21:15:35.185112", "exception": false, "start_time": "2026-03-13T21:15:35.169140", "status": "completed" }, "tags": [] }, "source": [ "Now, create a stage factor object for stage 2." ] }, { "cell_type": "code", "execution_count": 17, "id": "5ea93281", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:35.214258Z", "iopub.status.busy": "2026-03-13T21:15:35.213846Z", "iopub.status.idle": "2026-03-13T21:15:35.251476Z", "shell.execute_reply": "2026-03-13T21:15:35.249675Z" }, "papermill": { "duration": 0.055702, "end_time": "2026-03-13T21:15:35.253376", "exception": false, "start_time": "2026-03-13T21:15:35.197674", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "beamStageFactors_s2 = beam1.Truss.StageFactorInterface.createStageFactor(2)" ] }, { "cell_type": "markdown", "id": "838e1e58", "metadata": { "papermill": { "duration": 0.009717, "end_time": "2026-03-13T21:15:35.273008", "exception": false, "start_time": "2026-03-13T21:15:35.263291", "status": "completed" }, "tags": [] }, "source": [ "Get the current stage factor of compressive strength." ] }, { "cell_type": "code", "execution_count": 18, "id": "6b928a7c", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:35.297052Z", "iopub.status.busy": "2026-03-13T21:15:35.296637Z", "iopub.status.idle": "2026-03-13T21:15:35.312144Z", "shell.execute_reply": "2026-03-13T21:15:35.310461Z" }, "papermill": { "duration": 0.030141, "end_time": "2026-03-13T21:15:35.313466", "exception": false, "start_time": "2026-03-13T21:15:35.283325", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "1.0" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beamStageFactors_s2.getCompressiveStrengthFactor()" ] }, { "cell_type": "markdown", "id": "32b46d31", "metadata": { "papermill": { "duration": 0.008802, "end_time": "2026-03-13T21:15:35.332608", "exception": false, "start_time": "2026-03-13T21:15:35.323806", "status": "completed" }, "tags": [] }, "source": [ "Set stage factor of compressive strength." ] }, { "cell_type": "code", "execution_count": 19, "id": "a0243a17", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:35.361246Z", "iopub.status.busy": "2026-03-13T21:15:35.360239Z", "iopub.status.idle": "2026-03-13T21:15:35.377661Z", "shell.execute_reply": "2026-03-13T21:15:35.375217Z" }, "papermill": { "duration": 0.034954, "end_time": "2026-03-13T21:15:35.379460", "exception": false, "start_time": "2026-03-13T21:15:35.344506", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "beamStageFactors_s2.setCompressiveStrengthFactor(1.43)" ] }, { "cell_type": "markdown", "id": "0b2be899", "metadata": { "papermill": { "duration": 0.009919, "end_time": "2026-03-13T21:15:35.399510", "exception": false, "start_time": "2026-03-13T21:15:35.389591", "status": "completed" }, "tags": [] }, "source": [ "Get stage factors of all stages and check stage factor of compressive strength at stage 2." ] }, { "cell_type": "code", "execution_count": 20, "id": "19980170", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:35.424485Z", "iopub.status.busy": "2026-03-13T21:15:35.423880Z", "iopub.status.idle": "2026-03-13T21:15:35.442241Z", "shell.execute_reply": "2026-03-13T21:15:35.440428Z" }, "papermill": { "duration": 0.032392, "end_time": "2026-03-13T21:15:35.443900", "exception": false, "start_time": "2026-03-13T21:15:35.411508", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "1.43" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stageFactors_s2 = beam1.Truss.StageFactorInterface.getStageFactor(2)\n", "stageFactors_s2.getCompressiveStrengthFactor()" ] }, { "cell_type": "markdown", "id": "b4857a83", "metadata": { "papermill": { "duration": 0.010536, "end_time": "2026-03-13T21:15:35.464726", "exception": false, "start_time": "2026-03-13T21:15:35.454190", "status": "completed" }, "tags": [] }, "source": [ "Create another stage factor for stage 4 and set the stage factor of compressive strength." ] }, { "cell_type": "code", "execution_count": 21, "id": "61507c97", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:35.495221Z", "iopub.status.busy": "2026-03-13T21:15:35.494726Z", "iopub.status.idle": "2026-03-13T21:15:35.528058Z", "shell.execute_reply": "2026-03-13T21:15:35.526439Z" }, "papermill": { "duration": 0.049764, "end_time": "2026-03-13T21:15:35.529650", "exception": false, "start_time": "2026-03-13T21:15:35.479886", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "2.1" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beam1.Truss.StageFactorInterface.createStageFactor(4)\n", "beamStageFactors_s4 = beam1.Truss.StageFactorInterface.getDefinedStageFactors()[4]\n", "beamStageFactors_s4.setCompressiveStrengthFactor(2.1)\n", "beamStageFactors_s4.getCompressiveStrengthFactor()" ] }, { "cell_type": "markdown", "id": "de1e5587", "metadata": { "papermill": { "duration": 0.010927, "end_time": "2026-03-13T21:15:35.551978", "exception": false, "start_time": "2026-03-13T21:15:35.541051", "status": "completed" }, "tags": [] }, "source": [ "## 5. Delete Beam Stage Factor" ] }, { "cell_type": "markdown", "id": "ac8d4ff7", "metadata": { "papermill": { "duration": 0.014217, "end_time": "2026-03-13T21:15:35.580302", "exception": false, "start_time": "2026-03-13T21:15:35.566085", "status": "completed" }, "tags": [] }, "source": [ "Get the dictionary of all stage factors." ] }, { "cell_type": "code", "execution_count": 22, "id": "474048ca", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:35.599543Z", "iopub.status.busy": "2026-03-13T21:15:35.599145Z", "iopub.status.idle": "2026-03-13T21:15:35.612894Z", "shell.execute_reply": "2026-03-13T21:15:35.610737Z" }, "papermill": { "duration": 0.024321, "end_time": "2026-03-13T21:15:35.614517", "exception": false, "start_time": "2026-03-13T21:15:35.590196", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{2: ,\n", " 4: }" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beamStageFactors = beam1.Truss.StageFactorInterface.getDefinedStageFactors()\n", "beamStageFactors" ] }, { "cell_type": "markdown", "id": "d898ef1b", "metadata": { "papermill": { "duration": 0.011342, "end_time": "2026-03-13T21:15:35.637650", "exception": false, "start_time": "2026-03-13T21:15:35.626308", "status": "completed" }, "tags": [] }, "source": [ "Remove stage factors at stage 4." ] }, { "cell_type": "code", "execution_count": 23, "id": "7b063466", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:35.663076Z", "iopub.status.busy": "2026-03-13T21:15:35.662562Z", "iopub.status.idle": "2026-03-13T21:15:35.669567Z", "shell.execute_reply": "2026-03-13T21:15:35.668281Z" }, "papermill": { "duration": 0.022959, "end_time": "2026-03-13T21:15:35.670984", "exception": false, "start_time": "2026-03-13T21:15:35.648025", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beamStageFactors.pop(4)" ] }, { "cell_type": "markdown", "id": "7af01f16", "metadata": { "papermill": { "duration": 0.013843, "end_time": "2026-03-13T21:15:35.697657", "exception": false, "start_time": "2026-03-13T21:15:35.683814", "status": "completed" }, "tags": [] }, "source": [ "Set the dictionary back and check the defined stage factors. Now only stage 2 has stage factors defined." ] }, { "cell_type": "code", "execution_count": 24, "id": "38cd2bfb", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:35.720948Z", "iopub.status.busy": "2026-03-13T21:15:35.720612Z", "iopub.status.idle": "2026-03-13T21:15:35.764726Z", "shell.execute_reply": "2026-03-13T21:15:35.763132Z" }, "papermill": { "duration": 0.056666, "end_time": "2026-03-13T21:15:35.766238", "exception": false, "start_time": "2026-03-13T21:15:35.709572", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{2: }" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "beam1.Truss.StageFactorInterface.setDefinedStageFactors(beamStageFactors)\n", "beam1.Truss.StageFactorInterface.getDefinedStageFactors()" ] }, { "cell_type": "markdown", "id": "c9eaf85f", "metadata": { "papermill": { "duration": 0.0085, "end_time": "2026-03-13T21:15:35.785661", "exception": false, "start_time": "2026-03-13T21:15:35.777161", "status": "completed" }, "tags": [] }, "source": [ "## 6. Delete Beam" ] }, { "cell_type": "markdown", "id": "5bc2abf2", "metadata": { "papermill": { "duration": 0.010929, "end_time": "2026-03-13T21:15:35.812644", "exception": false, "start_time": "2026-03-13T21:15:35.801715", "status": "completed" }, "tags": [] }, "source": [ "Delete beam2." ] }, { "cell_type": "code", "execution_count": 25, "id": "60c835b7", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:35.841348Z", "iopub.status.busy": "2026-03-13T21:15:35.840703Z", "iopub.status.idle": "2026-03-13T21:15:35.897058Z", "shell.execute_reply": "2026-03-13T21:15:35.892864Z" }, "papermill": { "duration": 0.075561, "end_time": "2026-03-13T21:15:35.899442", "exception": false, "start_time": "2026-03-13T21:15:35.823881", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "model.deleteBeamProperty(beam2Name)" ] }, { "cell_type": "markdown", "id": "26128543", "metadata": { "papermill": { "duration": 0.014243, "end_time": "2026-03-13T21:15:35.935030", "exception": false, "start_time": "2026-03-13T21:15:35.920787", "status": "completed" }, "tags": [] }, "source": [ "Check if beam2 still exist in the beam list." ] }, { "cell_type": "code", "execution_count": 26, "id": "67d78560", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:35.966941Z", "iopub.status.busy": "2026-03-13T21:15:35.966442Z", "iopub.status.idle": "2026-03-13T21:15:35.978479Z", "shell.execute_reply": "2026-03-13T21:15:35.976406Z" }, "papermill": { "duration": 0.03066, "end_time": "2026-03-13T21:15:35.979984", "exception": false, "start_time": "2026-03-13T21:15:35.949324", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Beam 1\n" ] } ], "source": [ "allBeams = model.getAllBeamProperties()\n", "for beam in allBeams:\n", " print(beam.getBeamName())" ] }, { "cell_type": "markdown", "id": "3852fe39", "metadata": { "papermill": { "duration": 0.022239, "end_time": "2026-03-13T21:15:36.014888", "exception": false, "start_time": "2026-03-13T21:15:35.992649", "status": "completed" }, "tags": [] }, "source": [ "Save and close the model." ] }, { "cell_type": "code", "execution_count": 27, "id": "0cf5fc5d", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:36.038829Z", "iopub.status.busy": "2026-03-13T21:15:36.037203Z", "iopub.status.idle": "2026-03-13T21:15:39.732863Z", "shell.execute_reply": "2026-03-13T21:15:39.731030Z" }, "papermill": { "duration": 3.707149, "end_time": "2026-03-13T21:15:39.734506", "exception": false, "start_time": "2026-03-13T21:15:36.027357", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "model.close(True)" ] }, { "cell_type": "markdown", "id": "0b833245", "metadata": { "papermill": { "duration": 0.011157, "end_time": "2026-03-13T21:15:39.756651", "exception": false, "start_time": "2026-03-13T21:15:39.745494", "status": "completed" }, "tags": [] }, "source": [ "Close the program." ] }, { "cell_type": "code", "execution_count": 28, "id": "95db1bd4", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:39.785004Z", "iopub.status.busy": "2026-03-13T21:15:39.784272Z", "iopub.status.idle": "2026-03-13T21:15:45.538741Z", "shell.execute_reply": "2026-03-13T21:15:45.536535Z" }, "papermill": { "duration": 5.772622, "end_time": "2026-03-13T21:15:45.540724", "exception": false, "start_time": "2026-03-13T21:15:39.768102", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "modeler.closeProgram()" ] }, { "cell_type": "markdown", "id": "1547f9de", "metadata": { "papermill": { "duration": 0.017428, "end_time": "2026-03-13T21:15:45.573502", "exception": false, "start_time": "2026-03-13T21:15:45.556074", "status": "completed" }, "tags": [] }, "source": [ "## Full Script" ] }, { "cell_type": "code", "execution_count": 29, "id": "4ae778c7", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:15:45.609147Z", "iopub.status.busy": "2026-03-13T21:15:45.608682Z", "iopub.status.idle": "2026-03-13T21:16:31.362525Z", "shell.execute_reply": "2026-03-13T21:16:31.360491Z" }, "papermill": { "duration": 45.772582, "end_time": "2026-03-13T21:16:31.364347", "exception": false, "start_time": "2026-03-13T21:15:45.591765", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2026-03-13 17:15:45,620 - Rocscience.RS3 - INFO - Attempting to start the application at C:\\Program Files\\Rocscience\\RS3\\RS3 and binding server to port 60301...\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Beam 1\n" ] } ], "source": [ "# Beam Script Examples\n", "# Download the [blankModel.rs3v3](https://github.com/Rocscience/rs3-scripting/tree/main/docs/example_code/example_models/blankModel.rs3v3) for this example.\n", "from rs3.RS3Modeler import RS3Modeler\n", "from rs3.properties.PropertyEnums import *\n", "import os\n", "import shutil\n", "# Get the current folder directory.\n", "current_dir = os.path.abspath(\"\")\n", "# Specify a port number that is not in use and start the RS3 program.\n", "port = 60301\n", "RS3Modeler.startApplication(port)\n", "# Connect with the RS3 Modeler.\n", "modeler = RS3Modeler(port)\n", "# For the demonstration purposes only, the model is copied for reuse. You may change the model path to your own model path.\n", "blankModelPath = rf\"{os.path.dirname(current_dir)}\\example_models\\blankModel.rs3v3\"\n", "copiedModelPath = rf\"{os.path.dirname(current_dir)}\\example_models\\copiedModel.rs3v3\"\n", "_ = shutil.copy(blankModelPath, copiedModelPath)\n", "# Open the copied model file.\n", "model = modeler.openFile(copiedModelPath)\n", "\n", "# 1. Create and Get Beam\n", "# Get the first beam in the list.\n", "beam1 = model.getAllBeamProperties()[0]\n", "# Create a new beam and get the beam by name.\n", "beam2Name = \"Beam 2\"\n", "model.createNewBeamProperty(beam2Name)\n", "beam2 = model.getBeamPropertyByName(beam2Name)\n", "\n", "# 2. Set Beam Properties\n", "beam1.setBeamType(BeamType.TRUSS)\n", "beam1.Truss.setMaterialType(MaterialType.PLASTIC)\n", "beam1.Truss.setProperties(Area=0.2, UnitWeight=15.1)\n", "beam1Properties = beam1.Truss.getProperties()\n", "\n", "# 3. Copy Beam Properties\n", "beam2.setBeamType(BeamType.TRUSS)\n", "beam2.Truss.setProperties(**beam1Properties)\n", "\n", "# 4. Set Stage Factors\n", "# Turn on the stage factors of beams.\n", "beam1.setApplyStageFactors(True)\n", "# Now, create a stage factor object for stage 2.\n", "beamStageFactors_s2 = beam1.Truss.StageFactorInterface.createStageFactor(2)\n", "# Set stage factor of compressive strength.\n", "beamStageFactors_s2.setCompressiveStrengthFactor(1.43)\n", "# Get stage factors of all stages and check stage factor of compressive strength at stage 2.\n", "stageFactors_s2 = beam1.Truss.StageFactorInterface.getStageFactor(2)\n", "# Create another stage factor for stage 4 and set the stage factor of compressive strength.\n", "beam1.Truss.StageFactorInterface.createStageFactor(4)\n", "beamStageFactors_s4 = beam1.Truss.StageFactorInterface.getDefinedStageFactors()[4]\n", "beamStageFactors_s4.setCompressiveStrengthFactor(2.1)\n", "\n", "# 5. Delete Beam Stage Factor\n", "# Get the dictionary of all stage factors.\n", "beamStageFactors = beam1.Truss.StageFactorInterface.getDefinedStageFactors()\n", "# Remove stage factors at stage 4.\n", "beamStageFactors.pop(4)\n", "# Set the dictionary back and check the defined stage factors. Now only stage 2 has stage factors defined.\n", "beam1.Truss.StageFactorInterface.setDefinedStageFactors(beamStageFactors)\n", "\n", "# 6. Delete Beam\n", "# Delete beam2.\n", "model.deleteBeamProperty(beam2Name)\n", "# Check if beam2 still exist in the beam list.\n", "allBeams = model.getAllBeamProperties()\n", "for beam in allBeams:\n", " print(beam.getBeamName())\n", " \n", "# Save and close the model.\n", "model.close(True)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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": 103.028382, "end_time": "2026-03-13T21:16:33.075303", "environment_variables": {}, "exception": null, "input_path": "C:\\Users\\GraceHu\\source\\repos\\RS3Scripting_Compute\\docs\\example_code\\supports\\beam_example.ipynb", "output_path": "C:\\Users\\GraceHu\\source\\repos\\RS3Scripting_Compute\\docs\\example_code\\supports\\beam_example.ipynb", "parameters": {}, "start_time": "2026-03-13T21:14:50.046921", "version": "2.6.0" } }, "nbformat": 4, "nbformat_minor": 5 }