#13398 Python: Add API for custom well path segments

Add Python GRPC interface support for creating and managing custom segment
intervals for multi-segment wells. This provides API parity with the existing
GUI functionality.

Changes:
- Add createInterval() method to RimCustomSegmentIntervalCollection
- Add GRPC method addCustomSegmentInterval to RimcWellPathCompletionSettings
- Add validation to prevent creating intervals with start_md >= end_md
- Add Python test test_custom_segment_intervals.py with validation test
- Add usage example to modeled_well_path.py

Follows the pattern established by diameter roughness intervals.

Fixes #13398.
This commit is contained in:
Kristian Bendiksen authored and Magne Sjaastad committed 2026-01-13 10:44:55 +01:00
1 parent e34d36ee99
commit a71fb9ad19
6 files changed
+194

No files matched your search

@@ -18,6 +18,8 @@
#include "RimcWellPathCompletionSettings.h"
#include "RimCustomSegmentInterval.h"
#include "RimCustomSegmentIntervalCollection.h"
#include "RimDiameterRoughnessInterval.h"
#include "RimDiameterRoughnessIntervalCollection.h"
#include "RimMswCompletionParameters.h"
@@ -29,6 +31,10 @@ CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimWellPathCompletionSettings,
RimcWellPathCompletionSettings_addDiameterRoughnessInterval,
"AddDiameterRoughnessInterval" );
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimWellPathCompletionSettings,
RimcWellPathCompletionSettings_addCustomSegmentInterval,
"AddCustomSegmentInterval" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -88,3 +94,65 @@ QString RimcWellPathCompletionSettings_addDiameterRoughnessInterval::classKeywor
{
return RimDiameterRoughnessInterval::classKeywordStatic();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcWellPathCompletionSettings_addCustomSegmentInterval::RimcWellPathCompletionSettings_addCustomSegmentInterval( caf::PdmObjectHandle* self )
: caf::PdmObjectCreationMethod( self )
{
CAF_PDM_InitObject( "Add Custom Segment Interval" );
CAF_PDM_InitScriptableField( &m_startMD, "StartMd", 0.0, "Start Measured Depth" );
CAF_PDM_InitScriptableField( &m_endMD, "EndMd", 100.0, "End Measured Depth" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::expected<caf::PdmObjectHandle*, QString> RimcWellPathCompletionSettings_addCustomSegmentInterval::execute()
{
auto completionSettings = self<RimWellPathCompletionSettings>();
if ( !completionSettings )
{
return std::unexpected( QString( "Completion settings is null. Cannot add custom segment interval." ) );
}
auto mswParams = completionSettings->mswCompletionParameters();
if ( !mswParams )
{
return std::unexpected( QString( "MSW completion parameters is null. Cannot add custom segment interval." ) );
}
auto intervalCollection = mswParams->customSegmentIntervals();
if ( !intervalCollection )
{
return std::unexpected( QString( "Custom segment interval collection is null. Cannot add interval." ) );
}
// Validate that end MD is greater than start MD
if ( m_endMD() <= m_startMD() )
{
return std::unexpected(
QString( "End MD must be greater than Start MD. Start MD: %1, End MD: %2" ).arg( m_startMD() ).arg( m_endMD() ) );
}
// Create new interval
auto* newInterval = intervalCollection->createInterval( m_startMD(), m_endMD() );
if ( !newInterval )
{
return std::unexpected( QString( "Failed to create custom segment interval." ) );
}
completionSettings->updateAllRequiredEditors();
return newInterval;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimcWellPathCompletionSettings_addCustomSegmentInterval::classKeywordReturnedType() const
{
return RimCustomSegmentInterval::classKeywordStatic();
}