Water By Location Script Examples#

Download the blankModel.rs3v3 for this example.

from rs3.RS3Modeler import RS3Modeler
from rs3.properties.PropertyEnums import *
from rs3.projectSettings.ProjectSettingEnums 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 = 60401
RS3Modeler.startApplication(port)
2026-03-13 16:39:18,466 - Rocscience.RS3 - INFO - Attempting to start the application at C:\Program Files\Rocscience\RS3\RS3 and binding server to port 60401...

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)

1. Turn On Groundwater#

model.ProjectSettings.Groundwater.setGroundwaterMethod(GroundwaterMethodType.GW_SURFACES)

2. Define Groundwater Surface#

Create a water surface.

waterSurface1Name = "Water Surface 1"
model.createNewWaterByLocationProperty(waterSurface1Name)
waterSurface1 = model.getWaterByLocationPropertyByName(waterSurface1Name)
waterSurface1.getName()
'Water Surface 1'

Set the water surface. The input tuple is (X, Y, elevation).

waterSurfaceCoord = [(0, 0, -3), (30, 0, -3), (30, 30, -3), (0, 30, -3)]
waterSurface1.setWaterSurfaceLocation(waterSurfaceCoord)
waterSurface1.getWaterSurfaceLocation()
[(0.0, 0.0, -3.0), (30.0, 0.0, -3.0), (30.0, 30.0, -3.0), (0.0, 30.0, -3.0)]
waterSurface1.setInterpolationMethod(GroundwaterInterpolationMethodType.GAUSSIAN)
waterSurface1.getInterpolationMethod()
<GroundwaterInterpolationMethodType.GAUSSIAN: 'Gaussian'>
waterSurface1.setResolutionMethod(GroundwaterResolutionMethodType.FINE)
waterSurface1.getResolutionMethod()
<GroundwaterResolutionMethodType.FINE: 'Fine'>
waterSurface1.setIsExtrapolate(True)
waterSurface1.getIsExtrapolate()
True

Save and close the model.

model.close(True)

Close the program.

modeler.closeProgram()

Full Script#

# Water By Location 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 *
from rs3.projectSettings.ProjectSettingEnums 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 = 60401
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)

# 1. Turn On Groundwater
model.ProjectSettings.Groundwater.setGroundwaterMethod(GroundwaterMethodType.GW_SURFACES)

# 2. Define Groundwater Surface
# Create a water surface.
waterSurface1Name = "Water Surface 1"
model.createNewWaterByLocationProperty(waterSurface1Name)
waterSurface1 = model.getWaterByLocationPropertyByName(waterSurface1Name)
# Set the water surface. The input tuple is (X, Y, elevation).
waterSurfaceCoord = [(0, 0, -3), (30, 0, -3), (30, 30, -3), (0, 30, -3)]
waterSurface1.setWaterSurfaceLocation(waterSurfaceCoord)
waterSurface1.setInterpolationMethod(GroundwaterInterpolationMethodType.GAUSSIAN)
waterSurface1.setResolutionMethod(GroundwaterResolutionMethodType.FINE)
waterSurface1.setIsExtrapolate(True)

# Save and close the model.
model.close(True)
2026-03-13 16:40:07,375 - Rocscience.RS3 - INFO - Attempting to start the application at C:\Program Files\Rocscience\RS3\RS3 and binding server to port 60401...