Model Script Example#
This example opens blankProject.rocslope2, renames a joint set, saves, saves-as, exports an image, computes, and closes RocSlope2.
Download the blankProject.rocslope2 for this example.
Code Snippet: Model Manipulation#
from rocslope2.RocSlope2Modeler import RocSlope2Modeler
import os
import inspect
current_file = inspect.getfile(lambda: None)
current_dir = os.path.dirname(os.path.abspath(current_file))
example_model = os.path.join(current_dir, "example_models", "blankProject.rocslope2")
save_as_path = os.path.join(current_dir, "example_models", "blankProject_saveAs.rocslope2")
image_path = os.path.join(current_dir, "example_models", "blankProject_export.png")
RocSlope2Modeler.startApplication()
modeler = RocSlope2Modeler()
model = modeler.openFile(example_model)
joint_set = model.getAllJointSets()[0]
joint_set.setName("Joint Set A")
print(f"Joint set name: {joint_set.getName()}")
model.save()
model.saveAs(
save_as_path,
createDirectory=True,
)
model.exportImage(image_path)
model.compute()
print("Model saved, saved-as, image exported, and computed.")
model.close(saveProject=False)
modeler.closeProgram()
Output#
Joint set name: Joint Set A
Model saved, saved-as, image exported, and computed.