From acdcbe44b40ff987395035b5b212124b8cd40558 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 9 Sep 2021 10:16:37 +0200 Subject: [PATCH] Merge pull request #7975 from OPM/7973-custom-export-filename Export Completions : Custom export file name fails in some cases --- ...ellPathExportCompletionDataFeatureImpl.cpp | 1 + .../RicWellPathExportMswCompletionsImpl.cpp | 23 +++++++++++++++---- .../export_well_path_completions.py | 23 +++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 GrpcInterface/Python/rips/PythonExamples/export_well_path_completions.py diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 19f75e6e0d..d1269c9549 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -94,6 +94,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions( const std::v return; } + if ( exportSettings.customFileName().isEmpty() ) { QDir folder( exportSettings.folder ); if ( !folder.exists() ) diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index fba6ed89a6..39e3bae93e 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -71,28 +71,43 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( if ( exportSettings.fileSplit() == RicExportCompletionDataSettingsUi::ExportSplit::UNIFIED_FILE ) { { - QString fileName; + QString fileName; + QString folderName; + QFileInfo fi( exportSettings.customFileName() ); if ( !exportSettings.customFileName().isEmpty() ) - fileName = fi.baseName() + "_MSW"; + { + fileName = fi.baseName(); + folderName = fi.absolutePath(); + } else + { fileName = QString( "UnifiedCompletions_MSW_%1" ).arg( exportSettings.caseToApply->caseUserDescription() ); + folderName = exportSettings.folder; + } unifiedExportFile = - RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName, fi.suffix() ); + RicWellPathExportCompletionsFileTools::openFileForExport( folderName, fileName, fi.suffix() ); } { QString lgrFileName; + QString folderName; QFileInfo fi( exportSettings.customFileName() ); if ( !exportSettings.customFileName().isEmpty() ) + { lgrFileName = fi.baseName() + "_LGR_MSW"; + folderName = fi.absolutePath(); + } else + { lgrFileName = QString( "UnifiedCompletions_LGR_MSW_%1" ).arg( exportSettings.caseToApply->caseUserDescription() ); + folderName = exportSettings.folder; + } unifiedLgrExportFile = - RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, lgrFileName, fi.suffix() ); + RicWellPathExportCompletionsFileTools::openFileForExport( folderName, lgrFileName, fi.suffix() ); } } diff --git a/GrpcInterface/Python/rips/PythonExamples/export_well_path_completions.py b/GrpcInterface/Python/rips/PythonExamples/export_well_path_completions.py new file mode 100644 index 0000000000..e9586ea0a1 --- /dev/null +++ b/GrpcInterface/Python/rips/PythonExamples/export_well_path_completions.py @@ -0,0 +1,23 @@ +############################################################################ +# This script will export completions for a well path for all cases in the project +# +############################################################################ + +import os +import rips + +# Load instance +resinsight = rips.Instance.find() +cases = resinsight.project.cases() + +for case in cases: + print("Case name: ", case.name) + print("Case id: ", case.id) + + case.export_well_path_completions( + time_step=0, + well_path_names=["Well-1"], + file_split="UNIFIED_FILE", + include_perforations=True, + custom_file_name="d:/scratch/well_path_export/myfile.myext", + )