diff --git a/ApplicationCode/GrpcInterface/CMakeLists.cmake b/ApplicationCode/GrpcInterface/CMakeLists.cmake index 0046d4e44e..65d97b6ed4 100644 --- a/ApplicationCode/GrpcInterface/CMakeLists.cmake +++ b/ApplicationCode/GrpcInterface/CMakeLists.cmake @@ -227,4 +227,4 @@ list ( APPEND GRPC_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list ( APPEND GRPC_CPP_SOURCES ${SOURCE_GROUP_SOURCE_FILES}) source_group( "GrpcInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.cmake ) -source_group( "GrpcInterface\\GrpcProtos" FILES ${GRPC_PROTO_FILES_FULL_PATH} ) \ No newline at end of file +source_group( "GrpcInterface\\GrpcProtos" FILES ${GRPC_PROTO_FILES_FULL_PATH} ) diff --git a/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_wells.py b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_wells.py new file mode 100644 index 0000000000..ae8ecc7e57 --- /dev/null +++ b/ApplicationCode/GrpcInterface/Python/rips/PythonExamples/all_wells.py @@ -0,0 +1,17 @@ +################################################################################### +# This example will connect to ResInsight, retrieve a list of wells and print info +# +################################################################################### + +# Import the ResInsight Processing Server Module +import rips + +# Connect to ResInsight +resinsight = rips.Instance.find() +if resinsight is not None: + # Get a list of all wells + wells = resinsight.project.wells() + + print ("Got " + str(len(wells)) + " wells: ") + for well in wells: + print("Well name: " + well.name) diff --git a/ApplicationCode/GrpcInterface/Python/rips/project.py b/ApplicationCode/GrpcInterface/Python/rips/project.py index 240bbf7527..7b4f45eb10 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/project.py +++ b/ApplicationCode/GrpcInterface/Python/rips/project.py @@ -10,6 +10,7 @@ from rips.gridcasegroup import GridCaseGroup from rips.pdmobject import PdmObject from rips.plot import Plot from rips.view import View +from rips.well import Well from rips.contour_map import ContourMap, ContourMapType import rips.generated.Commands_pb2 as Cmd @@ -298,6 +299,19 @@ class Project(PdmObject): wellPathFiles=well_path_files)) return res.importWellPathsResult.wellPathNames + def wells(self): + """Get a list of all wells in the project + + Returns: + A list of rips Well objects + """ + pdm_objects = self.descendants("WellPathBase") + wells = [] + for pdm_object in pdm_objects: + wells.append(Well(pdm_object.get_value("WellPathName"), pdm_object)) + return wells + + def import_well_log_files(self, well_log_files=None, well_log_folder=''): """ Import well log files into project diff --git a/ApplicationCode/GrpcInterface/Python/rips/tests/test_wells.py b/ApplicationCode/GrpcInterface/Python/rips/tests/test_wells.py new file mode 100644 index 0000000000..8475b8c3e7 --- /dev/null +++ b/ApplicationCode/GrpcInterface/Python/rips/tests/test_wells.py @@ -0,0 +1,19 @@ +import sys +import os + +sys.path.insert(1, os.path.join(sys.path[0], '../../')) +import rips + +import dataroot + +def test_10k(rips_instance, initialize_test): + case_root_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC" + case_path = case_root_path + "/TEST10K_FLT_LGR_NNC.EGRID" + case = rips_instance.project.load_case(path=case_path) + assert(len(case.grids()) == 2) + well_path_files = [case_root_path + "/wellpath_a.dev", case_root_path + "/wellpath_b.dev"] + well_paths = rips_instance.project.import_well_paths(well_path_files) + wells = rips_instance.project.wells() + assert(len(wells) == 2) + assert(wells[0].name == "Well Path A") + assert(wells[1].name == "Well Path B") diff --git a/ApplicationCode/GrpcInterface/Python/rips/well.py b/ApplicationCode/GrpcInterface/Python/rips/well.py new file mode 100644 index 0000000000..a10fb84280 --- /dev/null +++ b/ApplicationCode/GrpcInterface/Python/rips/well.py @@ -0,0 +1,17 @@ +""" +ResInsight Well +""" +import rips.generated.Commands_pb2 as Cmd + +from rips.pdmobject import PdmObject + +class Well(PdmObject): + """ResInsight well class + + Attributes: + name(string): Name of the well. + + """ + def __init__(self, name, pdm_object): + PdmObject.__init__(self, pdm_object.pb2_object(), pdm_object.channel(), pdm_object.project()) + self.name = name