2019-08-19 06:46:14 -05:00
|
|
|
###############################################################################
|
2019-09-23 04:50:33 -05:00
|
|
|
# This example will show setting time step, window size and export snapshots and properties
|
2019-08-19 06:46:14 -05:00
|
|
|
###############################################################################
|
2019-05-20 06:21:02 -05:00
|
|
|
import os
|
2019-06-03 14:11:27 -05:00
|
|
|
import tempfile
|
|
|
|
import rips
|
2019-05-20 06:21:02 -05:00
|
|
|
|
|
|
|
# Load instance
|
2019-09-19 06:25:04 -05:00
|
|
|
resinsight = rips.Instance.find()
|
2019-05-20 06:21:02 -05:00
|
|
|
|
2019-09-23 04:50:33 -05:00
|
|
|
# Set window size
|
|
|
|
resinsight.set_main_window_size(width=800, height=500)
|
|
|
|
|
|
|
|
# Retrieve first case
|
|
|
|
case = resinsight.project.cases()[0]
|
|
|
|
|
|
|
|
# Get a view
|
|
|
|
view1 = case.view(view_id=0)
|
|
|
|
|
|
|
|
# Clone the view
|
|
|
|
view2 = view1.clone()
|
|
|
|
|
|
|
|
# Set the time step for view1 only
|
|
|
|
view1.set_time_step(time_step=2)
|
|
|
|
|
|
|
|
# Set cell result to SOIL
|
|
|
|
view1.apply_cell_result(result_type='DYNAMIC_NATIVE', result_variable='SOIL')
|
|
|
|
|
2019-08-19 06:46:14 -05: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 14:11:27 -05:00
|
|
|
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
|
|
|
|
print("Temporary folder: ", tmpdirname)
|
2019-08-19 06:46:14 -05:00
|
|
|
|
|
|
|
# Set export folder for snapshots and properties
|
2019-09-23 04:50:33 -05:00
|
|
|
resinsight.set_export_folder(export_type='SNAPSHOTS', path=tmpdirname)
|
|
|
|
resinsight.set_export_folder(export_type='PROPERTIES', path=tmpdirname)
|
2019-08-19 06:46:14 -05:00
|
|
|
|
2019-09-23 04:50:33 -05:00
|
|
|
# Export all snapshots
|
|
|
|
resinsight.project.export_snapshots()
|
|
|
|
|
2019-06-05 04:26:19 -05:00
|
|
|
assert(len(os.listdir(tmpdirname)) > 0)
|
2019-08-19 06:46:14 -05:00
|
|
|
|
|
|
|
# Export properties in the view
|
2019-09-23 04:50:33 -05:00
|
|
|
view1.export_property()
|
|
|
|
|
2019-08-19 06:46:14 -05:00
|
|
|
# Check that the exported file exists
|
2019-09-23 04:50:33 -05:00
|
|
|
expected_file_name = case.name + "-" + str("3D_View") + "-" + "T2" + "-SOIL"
|
2019-09-19 08:14:01 -05:00
|
|
|
full_path = tmpdirname + "/" + expected_file_name
|
2019-09-23 04:50:33 -05:00
|
|
|
|
|
|
|
# Print contents of temporary folder
|
|
|
|
print(os.listdir(tmpdirname))
|
|
|
|
|
2019-09-19 08:14:01 -05:00
|
|
|
assert(os.path.exists(full_path))
|
2019-06-05 04:26:19 -05:00
|
|
|
|