Add the rips.Project.summary_cases() method and an example

This commit is contained in:
Gaute Lindkvist 2020-09-23 11:04:51 +02:00
parent df51c9becb
commit 2741b24e27
2 changed files with 27 additions and 6 deletions

View File

@ -0,0 +1,14 @@
# Load ResInsight Processing Server Client Library
import rips
# Connect to ResInsight instance
resinsight = rips.Instance.find()
# Example code
# Specific summary case with case_id = 1
summary_case = resinsight.project.summary_case(case_id=1)
summary_case.print_object_info()
# All summary cases
summary_cases = resinsight.project.summary_cases()
for summary_case in summary_cases:
print("Summary case found: ", summary_case.short_name)

View File

@ -17,7 +17,7 @@ from Definitions_pb2 import Empty
import Project_pb2_grpc import Project_pb2_grpc
import Project_pb2 import Project_pb2
import PdmObject_pb2 import PdmObject_pb2
from resinsight_classes import Project, PlotWindow, WellPath from resinsight_classes import Project, PlotWindow, WellPath, SummaryCase
@add_method(Project) @add_method(Project)
@ -63,7 +63,7 @@ def close(self):
@add_method(Project) @add_method(Project)
def load_case(self, path): def load_case(self, path):
"""Load a new case from the given file path """Load a new grid case from the given file path
Arguments: Arguments:
path(str): file path to case path(str): file path to case
@ -77,7 +77,7 @@ def load_case(self, path):
@add_method(Project) @add_method(Project)
def selected_cases(self): def selected_cases(self):
"""Get a list of all cases selected in the project tree """Get a list of all grid cases selected in the project tree
Returns: Returns:
A list of :class:`rips.generated.resinsight_classes.Case` A list of :class:`rips.generated.resinsight_classes.Case`
@ -91,7 +91,7 @@ def selected_cases(self):
@add_method(Project) @add_method(Project)
def cases(self): def cases(self):
"""Get a list of all cases in the project """Get a list of all grid cases in the project
Returns: Returns:
A list of :class:`rips.generated.resinsight_classes.Case` A list of :class:`rips.generated.resinsight_classes.Case`
@ -101,7 +101,7 @@ def cases(self):
@add_method(Project) @add_method(Project)
def case(self, case_id): def case(self, case_id):
"""Get a specific case from the provided case Id """Get a specific grid case from the provided case Id
Arguments: Arguments:
id(int): case id id(int): case id
@ -117,7 +117,7 @@ def case(self, case_id):
@add_method(Project) @add_method(Project)
def replace_source_cases(self, grid_list_file, case_group_id=0): def replace_source_cases(self, grid_list_file, case_group_id=0):
"""Replace all source cases within a case group """Replace all source grid cases within a case group
Arguments: Arguments:
grid_list_file (str): path to file containing a list of cases grid_list_file (str): path to file containing a list of cases
@ -143,6 +143,13 @@ def create_grid_case_group(self, case_paths):
return self.grid_case_group( return self.grid_case_group(
command_reply.createGridCaseGroupResult.groupId) command_reply.createGridCaseGroupResult.groupId)
@add_method(Project)
def summary_cases(self):
"""Get a list of all summary cases in the Project
Returns: A list of :class:`rips.generated.resinsight_classes.SummaryCase`
"""
return self.descendants(SummaryCase)
@add_method(Project) @add_method(Project)
def views(self): def views(self):