Model Script Examples#
Download the blankModel.rs3v3 for this example.
from rs3.RS3Modeler import RS3Modeler
from rs3.properties.PropertyEnums import *
import os
import shutil
Get the current folder directory.
current_dir = os.path.dirname(os.path.abspath(""))
Specify a port number that is not in use and start the RS3 program.
port = 60101
RS3Modeler.startApplication(port)
2026-03-13 16:53:51,845 - Rocscience.RS3 - INFO - Attempting to start the application at C:\Program Files\Rocscience\RS3\RS3 and binding server to port 60101...
Connect with the RS3 Modeler.
modeler = RS3Modeler(port)
For the demonstration purposes only, the model is copied for reuse. You may change the model path to your own model path.
blankModelPath = rf"{current_dir}\example_models\blankModel.rs3v3"
copiedModelPath = rf"{current_dir}\example_models\copiedModel.rs3v3"
_ = shutil.copy(blankModelPath, copiedModelPath)
Open the copied model file.
model = modeler.openFile(copiedModelPath)
Get the first bolt, liner and joint objects.
bolt = model.getAllBoltProperties()[0]
liner = model.getAllLinerProperties()[0]
joint = model.getAllJointProperties()[0]
bolt.getBoltType()
<BoltTypes.PLAIN_STRAND_CABLE: 'PLAIN_STRAND_CABLE'>
liner.getLinerType()
<LinerTypes.STANDARD: 'STANDARD'>
joint.getConstitutiveModel()
<JointConstitutiveModelTypes.NONE: 'NONE'>
Set the properties of bolt, liner and joint to something different from the current properties.
bolt.setBoltType(BoltTypes.SWELLEX)
liner.setLinerType(LinerTypes.REINFORCED_CONCRETE)
joint.setConstitutiveModel(JointConstitutiveModelTypes.MATERIAL_DEPENDENT)
Get bolt type again.
bolt.getBoltType()
<BoltTypes.SWELLEX: 'SWELLEX_BOLT'>
Get liner type again.
liner.getLinerType()
<LinerTypes.REINFORCED_CONCRETE: 'REINFORCED_CONCRETE'>
Get the constitutive model of joint again.
joint.getConstitutiveModel()
<JointConstitutiveModelTypes.MATERIAL_DEPENDENT: 'MATERIAL_DEPENDENT'>
Save the model.
model.save()
Compute the model.
model.Compute.compute()
Recovery: True
Stages Convergence:
Stage Status
----------------
1 Yes
2 Yes
3 Yes
4 Yes
5 Yes
(True, '')
Save and close the model.
model.close(True)
Close the program.
modeler.closeProgram()
Full Script#
# Model Script Examples
# Download the [blankModel.rs3v3](https://github.com/Rocscience/rs3-scripting/tree/main/docs/example_code/example_models/blankModel.rs3v3) for this example.
from rs3.RS3Modeler import RS3Modeler
from rs3.properties.PropertyEnums import *
import os
import shutil
# Get the current folder directory.
current_dir = os.path.dirname(os.path.abspath(""))
# Specify a port number that is not in use and start the RS3 program.
port = 60101
RS3Modeler.startApplication(port)
# Connect with the RS3 Modeler.
modeler = RS3Modeler(port)
# For the demonstration purposes only, the model is copied for reuse. You may change the model path to your own model path.
blankModelPath = rf"{current_dir}\example_models\blankModel.rs3v3"
copiedModelPath = rf"{current_dir}\example_models\copiedModel.rs3v3"
_ = shutil.copy(blankModelPath, copiedModelPath)
# Open the copied model file.
model = modeler.openFile(copiedModelPath)
# Get the first bolt, liner and joint objects.
bolt = model.getAllBoltProperties()[0]
liner = model.getAllLinerProperties()[0]
joint = model.getAllJointProperties()[0]
# Set the properties of bolt, liner and joint to something different from the current properties.
bolt.setBoltType(BoltTypes.SWELLEX)
liner.setLinerType(LinerTypes.REINFORCED_CONCRETE)
joint.setConstitutiveModel(JointConstitutiveModelTypes.MATERIAL_DEPENDENT)
# Save the model.
model.save()
# Compute the model.
model.Compute.compute()
# Save and close the model.
model.close(True)
2026-03-13 16:56:04,758 - Rocscience.RS3 - INFO - Attempting to start the application at C:\Program Files\Rocscience\RS3\RS3 and binding server to port 60101...
Recovery: True
Stages Convergence:
Stage Status
----------------
1 Yes
2 Yes
3 Yes
4 Yes
5 Yes