Material Datum 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 = 60204
RS3Modeler.startApplication(port)
2026-03-13 16:25:22,345 - Rocscience.RS3 - INFO - Attempting to start the application at C:\Program Files\Rocscience\RS3\RS3 and binding server to port 60204...

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. Create and Get Material#

Get the first material in the list.

material1 = model.getAllMaterialProperties()[0]
material1.getMaterialName()
'Soil'
newMaterialName = "New Material"
model.createNewMaterialProperty(newMaterialName)
newMaterial = model.getMaterialPropertyByName(newMaterialName)
newMaterial.getMaterialName()
'New Material'

2. Set Datum#

material1.Datum.YoungsModulusDatumDependency.setInUse(True)
material1.Datum.YoungsModulusDatumDependency.getInUse()
True
material1.Datum.YoungsModulusDatumDependency.getProperties()
{'PeakCutoff': False,
 'PeakCutoffValue': 0.0,
 'Change': 0.0,
 'Datum': 0.0,
 'InUse': True}
material1.Datum.YoungsModulusDatumDependency.setDatumType(DatumType.DEPTH)
material1.Datum.YoungsModulusDatumDependency.setProperties(Datum=1.5, Change=0.2)
material1.Datum.YoungsModulusDatumDependency.getProperties()
{'PeakCutoff': False,
 'PeakCutoffValue': 0.0,
 'Change': 0.2,
 'Datum': 1.5,
 'InUse': True}

Save and close the model.

model.close(True)

Close the program.

modeler.closeProgram()

Full Script#

# Material Datum 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 = 60204
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. Create and Get Material
# Get the first material in the list.
material1 = model.getAllMaterialProperties()[0]
newMaterialName = "New Material"
model.createNewMaterialProperty(newMaterialName)
newMaterial = model.getMaterialPropertyByName(newMaterialName)

# 2. Set Datum
material1.Datum.YoungsModulusDatumDependency.setInUse(True)
material1.Datum.YoungsModulusDatumDependency.setDatumType(DatumType.DEPTH)
material1.Datum.YoungsModulusDatumDependency.setProperties(Datum=1.5, Change=0.2)

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