2019-08-19 13:46:14 +02:00
|
|
|
###############################################################################
|
|
|
|
|
# This example will run a few ResInsight command file commands
|
|
|
|
|
# .. which are exposed in the Python interface.
|
|
|
|
|
# Including setting time step, window size and export snapshots and properties
|
|
|
|
|
###############################################################################
|
2019-05-20 13:21:02 +02:00
|
|
|
import os
|
2019-06-03 21:11:27 +02:00
|
|
|
import tempfile
|
|
|
|
|
import rips
|
2019-05-20 13:21:02 +02:00
|
|
|
|
|
|
|
|
# Load instance
|
2019-09-19 13:25:04 +02:00
|
|
|
resinsight = rips.Instance.find()
|
2019-05-20 13:21:02 +02:00
|
|
|
|
|
|
|
|
# Run a couple of commands
|
2019-09-19 13:25:04 +02:00
|
|
|
resinsight.commands.set_time_step(case_id=0, time_step=3)
|
|
|
|
|
resinsight.commands.set_main_window_size(width=800, height=500)
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
|
|
|
# Create a temporary directory which will disappear at the end of this script
|
|
|
|
|
# If you want to keep the files, provide a good path name instead of tmpdirname
|
2019-06-03 21:11:27 +02:00
|
|
|
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
|
|
|
|
|
print("Temporary folder: ", tmpdirname)
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
|
|
|
# Set export folder for snapshots and properties
|
2019-09-19 13:25:04 +02:00
|
|
|
resinsight.commands.set_export_folder(type='SNAPSHOTS', path=tmpdirname)
|
|
|
|
|
resinsight.commands.set_export_folder(type='PROPERTIES', path=tmpdirname)
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
|
|
|
# Export snapshots
|
2019-09-19 13:25:04 +02:00
|
|
|
resinsight.commands.export_snapshots()
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
|
|
|
# Print contents of temporary folder
|
2019-06-03 21:11:27 +02:00
|
|
|
print(os.listdir(tmpdirname))
|
2019-08-19 13:46:14 +02:00
|
|
|
|
2019-06-05 11:26:19 +02:00
|
|
|
assert(len(os.listdir(tmpdirname)) > 0)
|
2019-09-19 13:25:04 +02:00
|
|
|
case = resinsight.project.case(id=0)
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
|
|
|
# Export properties in the view
|
2019-09-19 13:25:04 +02:00
|
|
|
resinsight.commands.export_property_in_views(0, "3D View", 0)
|
2019-08-19 13:46:14 +02:00
|
|
|
|
|
|
|
|
# Check that the exported file exists
|
2019-06-05 11:26:19 +02:00
|
|
|
expectedFileName = case.name + "-" + str("3D_View") + "-" + "T3" + "-SOIL"
|
|
|
|
|
fullPath = tmpdirname + "/" + expectedFileName
|
|
|
|
|
assert(os.path.exists(fullPath))
|
|
|
|
|
|