Grouping Script Examples#
Download the blankModel.rs3v3 for this example.
from rs3.RS3Modeler import RS3Modeler
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 = 60112
RS3Modeler.startApplication(port)
2026-09-16 16:19:04,179 - Rocscience.RS3 - INFO - Attempting to start the application at C:\Program Files\Rocscience\RS3\RS3 and binding server to port 60112...
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 a Group#
Create an exacavation group with the name “Excavation Group”. Get the excavation group object.
excavationGroupName = "Excavation Group"
model.createNewGroupProperty(excavationGroupName)
exacationGroup = model.getGroupByName(excavationGroupName)
2. Define Group Properties#
Set the group color.
exacationGroup.setColor("#D6AE2A")
Set the group transparency.
exacationGroup.setGroupSetsTransparency(True)
exacationGroup.setGroupTransparency(0.1)
3. Set the Group of an External Volume#
Get the tunnel volume and set the grouping to the Excavation Group from stage 2.
tunnelVolume = model.getExternalVolumeByName("Underground Tunnel")
tunnelVolume.setGrouping(2, excavationGroupName)
Get the foundation volume and set the grouping to the Excavation Group from stage 3.
foundationVolume = model.getExternalVolumeByName("Foundation")
foundationVolume.setGrouping(3, excavationGroupName)
Set the foundation volume and set the grouping back to Ungrouped.
foundationVolume.setGrouping(4, "Ungrouped")
Save and close the model.
model.close(True)
Close the program.
modeler.closeProgram()
Full Script#
# Grouping 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
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 = 60112
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 an Excavation Group
# Create an excavation group with the name "Excavation Group". Get the excavation group object.
excavationGroupName = "Excavation Group"
model.createNewGroupProperty(excavationGroupName)
exacationGroup = model.getGroupByName(excavationGroupName)
# 2. Define Group Properties
# Set the group color
exacationGroup.setColor("#D6AE2A")
# Set the group transparency
exacationGroup.setGroupSetsTransparency(True)
exacationGroup.setGroupTransparency(0.1)
# 3. Set the Group of an External Volume
# Get the tunnel volume and set the grouping to the Excavation Group from stage 2.
tunnelVolume = model.getExternalVolumeByName("Underground Tunnel")
tunnelVolume.setGrouping(2, excavationGroupName)
# Get the foundation volume and set the grouping to the Excavation Group from stage 3.
foundationVolume = model.getExternalVolumeByName("Foundation")
foundationVolume.setGrouping(3, excavationGroupName)
# Set the foundation volume and set the grouping back to Ungrouped.
foundationVolume.setGrouping(4, "Ungrouped")
# Save and close the model.
model.close(True)
2026-09-16 16:20:16,278 - Rocscience.RS3 - INFO - Attempting to start the application at C:\Program Files\Rocscience\RS3\RS3 and binding server to port 60112...