Pile 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.abspath("")

Specify a port number that is not in use and start the RS3 program.

port = 60305
RS3Modeler.startApplication(port)
2026-03-13 17:23:50,055 - Rocscience.RS3 - INFO - Attempting to start the application at C:\Program Files\Rocscience\RS3\RS3 and binding server to port 60305...

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"{os.path.dirname(current_dir)}\example_models\blankModel.rs3v3"
copiedModelPath = rf"{os.path.dirname(current_dir)}\example_models\copiedModel.rs3v3"
_ = shutil.copy(blankModelPath, copiedModelPath)

Open the copied model file.

model = modeler.openFile(copiedModelPath)

1. Create and Get Pile#

Get the first pile in the list.

pile1 = model.getAllPileProperties()[0]
pile1.getPileName()
'Pile 1'

Create a new pile and get the pile by name.

pile2Name = "Pile 2"
model.createNewPileProperty(pile2Name)
pile2 = model.getPilePropertyByName(pile2Name)
pile2.getPileName()
'Pile 2'

2. Set Pile Properties#

Create a beam for the later example.

newBeamName = "Beam for pile"
model.createNewBeamProperty(newBeamName)
pile1.setConnectionType(ConnectionType.HINGED)
pile1.setLiningConnectionType(LiningConnectionType.FIRST_LINER_AT_INSTALL)
pile1.setBeamMaterial(newBeamName)
pile1.setSkinResistance(PileSkinResistanceType.MULTI_LINEAR)
pile1.getSkinResistance()
<PileSkinResistanceType.MULTI_LINEAR: 'MULTILINEAR'>
pile1.MultiLinear.getProperties()
{'ShearStiffness': 10000.0,
 'NormalStiffness': 100000.0,
 'UsingPileProperties': True,
 'BaseNormalStiffness': 100000.0,
 'BaseForceResistance': 100.0}
pile1.MultiLinear.setProperties(BaseForceResistance=205)
pile1Properties = pile1.MultiLinear.getProperties()
pile1Properties
{'ShearStiffness': 10000.0,
 'NormalStiffness': 100000.0,
 'UsingPileProperties': True,
 'BaseNormalStiffness': 100000.0,
 'BaseForceResistance': 205.0}

Set multi-linear skin resistance properties. Each tuple takes (Distance to Top, Max Traction).

pile1.MultiLinear.setMultiLinearGrid([(1.1, 2.2), (3.3, 4.4)])
pile1.MultiLinear.getMultiLinearGrid()
[(1.1, 2.2), (3.3, 4.4)]

Set pile end conditions (force/displacement).

pile1.EndCondition.setEndConditionType(EndConditionType.DISPLACEMENT)
pile1.EndCondition.setProperties(12.3, 1.1, 2.2, 3.3)
pile1.EndCondition.getProperties()
{'Magnitude': 12.3, 'X': 1.1, 'Y': 2.2, 'Z': 3.3}

To turn off the pile end conditions, set EndConditionType to NONE.

pile1.EndCondition.setEndConditionType(EndConditionType.NONE)

3. Copy Pile Properties#

pile1.setSkinResistance(PileSkinResistanceType.MULTI_LINEAR)
pile1.getSkinResistance()
<PileSkinResistanceType.MULTI_LINEAR: 'MULTILINEAR'>
pile2.MultiLinear.getProperties()
{'ShearStiffness': 10000.0,
 'NormalStiffness': 100000.0,
 'UsingPileProperties': True,
 'BaseNormalStiffness': 100000.0,
 'BaseForceResistance': 100.0}
pile2.MultiLinear.setProperties(**pile1Properties)
pile2.MultiLinear.getProperties()
{'ShearStiffness': 10000.0,
 'NormalStiffness': 100000.0,
 'UsingPileProperties': True,
 'BaseNormalStiffness': 100000.0,
 'BaseForceResistance': 205.0}

4. Set Stage Factors#

Turn on the stage factors of piles.

pile1.setApplyStageFactors(True)

Create a stage factor for stage 2.

pileStageFactor_s2 = pile1.MultiLinear.StageFactorInterface.createStageFactor(2)
pileStageFactor_s2 = pile1.MultiLinear.StageFactorInterface.getDefinedStageFactors()[2]

Get the current stage factor of multi-liear grid.

pileStageFactor_s2.getMultiLinearFactor()
1.0

Set stage factor of multi-linear grid.

pileStageFactor_s2.setMultiLinearFactor(1.5)

Get stage factors of all stages and check stage factor of multi-linear grid at stage 2.

stageFactors_s2 = pile1.MultiLinear.StageFactorInterface.getStageFactor(2)
stageFactors_s2.getMultiLinearFactor()
1.5

Create another stage factor for stage 4 and set the stage multi-linear grid stage factor to 2.1.

pile1.MultiLinear.StageFactorInterface.createStageFactor(4)
newPileStageFactor_s4 = pile1.MultiLinear.StageFactorInterface.getDefinedStageFactors()[4]
newPileStageFactor_s4.setMultiLinearFactor(2.1)

5. Delete Pile Stage Factor#

Get the dictionary of all stage factors.

pileStageFactors = pile1.MultiLinear.StageFactorInterface.getDefinedStageFactors()
pileStageFactors
{2: <rs3.properties.pile.MultiLinear.MultiLinearDefinedStageFactor at 0x1bcc1944ef0>,
 4: <rs3.properties.pile.MultiLinear.MultiLinearDefinedStageFactor at 0x1bcb1b7b130>}

Remove stage factors at stage 4.

pileStageFactors.pop(4)
<rs3.properties.pile.MultiLinear.MultiLinearDefinedStageFactor at 0x1bcb1b7b130>

Set the dictionary back and check the defined stage factors. Now only stage 2 has stage factors defined.

pile1.MultiLinear.StageFactorInterface.setDefinedStageFactors(pileStageFactors)
pile1.MultiLinear.StageFactorInterface.getDefinedStageFactors()
{2: <rs3.properties.pile.MultiLinear.MultiLinearDefinedStageFactor at 0x1bcb1b7b460>}

6. Delete Pile#

Delete pile2.

model.deletePileProperty(pile2Name)

Check if pile2 still exist in the pile list.

allPiles = model.getAllPileProperties()
for pile in allPiles:
    print(pile.getPileName())
Pile 1

Save and close the model.

model.close(True)

Close the program.

modeler.closeProgram()

Full Script#

# Pile 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.abspath("")
# Specify a port number that is not in use and start the RS3 program.
port = 60305
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"{os.path.dirname(current_dir)}\example_models\blankModel.rs3v3"
copiedModelPath = rf"{os.path.dirname(current_dir)}\example_models\copiedModel.rs3v3"
_ = shutil.copy(blankModelPath, copiedModelPath)
# Open the copied model file.
model = modeler.openFile(copiedModelPath)

# 1. Create and Get Pile
# Get the first pile in the list.
pile1 = model.getAllPileProperties()[0]
# Create a new pile and get the pile by name.
pile2Name = "Pile 2"
model.createNewPileProperty(pile2Name)
pile2 = model.getPilePropertyByName(pile2Name)

# 2. Set Pile Properties
# Create a beam for the later example.
newBeamName = "Beam for pile"
model.createNewBeamProperty(newBeamName)
pile1.setConnectionType(ConnectionType.HINGED)
pile1.setLiningConnectionType(LiningConnectionType.FIRST_LINER_AT_INSTALL)
pile1.setBeamMaterial(newBeamName)
pile1.setSkinResistance(PileSkinResistanceType.MULTI_LINEAR)
pile1.MultiLinear.setProperties(BaseForceResistance=205)
pile1Properties = pile1.MultiLinear.getProperties()
# Set multi-linear skin resistance properties. Each tuple takes (Distance to Top, Max Traction).
pile1.MultiLinear.setMultiLinearGrid([(1.1, 2.2), (3.3, 4.4)])
# Set pile end conditions (force/displacement).
pile1.EndCondition.setEndConditionType(EndConditionType.DISPLACEMENT)
pile1.EndCondition.setProperties(12.3, 1.1, 2.2, 3.3)
# To turn off the pile end conditions, set EndConditionType to NONE.
pile1.EndCondition.setEndConditionType(EndConditionType.NONE)

# 3. Copy Pile Properties
pile1.setSkinResistance(PileSkinResistanceType.MULTI_LINEAR)
pile2.MultiLinear.setProperties(**pile1Properties)

# 4. Set Stage Factors
# Turn on the stage factors of piles.
pile1.setApplyStageFactors(True)
# Create a stage factor for stage 2.
pileStageFactor_s2 = pile1.MultiLinear.StageFactorInterface.createStageFactor(2)
pileStageFactor_s2 = pile1.MultiLinear.StageFactorInterface.getDefinedStageFactors()[2]
# Set stage factor of multi-linear grid.
pileStageFactor_s2.setMultiLinearFactor(1.5)
# Get stage factors of all stages and check stage factor of multi-linear grid at stage 2.
stageFactors_s2 = pile1.MultiLinear.StageFactorInterface.getStageFactor(2)
# Create another stage factor for stage 4 and set the stage multi-linear grid stage factor to 2.1.
pile1.MultiLinear.StageFactorInterface.createStageFactor(4)
newPileStageFactor_s4 = pile1.MultiLinear.StageFactorInterface.getDefinedStageFactors()[4]
newPileStageFactor_s4.setMultiLinearFactor(2.1)

# 5. Delete Pile Stage Factor
# Get the dictionary of all stage factors.
pileStageFactors = pile1.MultiLinear.StageFactorInterface.getDefinedStageFactors()
# Remove stage factors at stage 4.
pileStageFactors.pop(4)
# Set the dictionary back and check the defined stage factors. Now only stage 2 has stage factors defined.
pile1.MultiLinear.StageFactorInterface.setDefinedStageFactors(pileStageFactors)

# 6. Delete Pile
# Delete pile2.
model.deletePileProperty(pile2Name)
# Check if pile2 still exist in the pile list.
allPiles = model.getAllPileProperties()
for pile in allPiles:
    print(pile.getPileName())
    
# Save and close the model.
model.close(True)
2026-03-13 17:24:41,951 - Rocscience.RS3 - INFO - Attempting to start the application at C:\Program Files\Rocscience\RS3\RS3 and binding server to port 60305...
Pile 1