#14772 Python: Add FractureTemplate.set_containment as object method and forward setFractureContainment to it

RimFractureTemplate_setContainment validates the layer range and
updates the template. RicfSetFractureContainment forwards to it.
Project.set_fracture_containment(template_id=...) in Python resolves
the template object and calls the new method, emitting a
DeprecationWarning.
This commit is contained in:
Kristian Bendiksen committed 2026-09-22 14:19:23 +02:00
1 parent eda2d73fed
commit 0416bd041e
1 file changed
+10 -28
@@ -19,11 +19,10 @@
#include "RicfSetFractureContainment.h"
#include "RiaLogging.h"
#include "RicfCommandForwarding.h"
#include "RimFractureTemplate.h"
#include "RimFractureTemplateCollection.h"
#include "RimProject.h"
#include "RimcFractureTemplate.h"
#include "cafPdmFieldScriptingCapability.h"
@@ -44,35 +43,18 @@ RicfSetFractureContainment::RicfSetFractureContainment()
//--------------------------------------------------------------------------------------------------
caf::PdmScriptResponse RicfSetFractureContainment::execute()
{
const QString commandName = classKeyword();
if ( m_id < 0 || m_topLayer < 0 || m_baseLayer < 0 )
{
QString error( "setFractureContainment: Required argument missing" );
RiaLogging::error( error.toStdString() );
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error );
return RicfForwarding::errorResponse( "Required argument missing", commandName );
}
RimProject* project = RimProject::current();
auto fractureTemplate = RicfForwarding::findFractureTemplate( m_id() );
if ( !fractureTemplate ) return RicfForwarding::errorResponse( fractureTemplate.error(), commandName );
if ( !project )
{
QString error( "setFractureContainment: Project not found" );
RiaLogging::error( error.toStdString() );
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error );
}
RimFractureTemplate_setContainment method( fractureTemplate.value() );
method.setLayers( m_topLayer(), m_baseLayer() );
RimFractureTemplateCollection* templColl =
!project->allFractureTemplateCollections().empty() ? project->allFractureTemplateCollections()[0] : nullptr;
RimFractureTemplate* templ = templColl ? templColl->fractureTemplate( m_id ) : nullptr;
if ( !templ )
{
QString error = QString( "setFractureContainment: Fracture template not found. Id=%1" ).arg( m_id() );
RiaLogging::error( error.toStdString() );
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error );
}
templ->setContainmentTopKLayer( m_topLayer );
templ->setContainmentBaseKLayer( m_baseLayer );
templ->loadDataAndUpdateGeometryHasChanged();
return caf::PdmScriptResponse();
return RicfForwarding::toScriptResponse( method.execute(), commandName );
}