diff --git a/ApplicationCode/Commands/SurfaceCommands/RicImportSurfacesFeature.cpp b/ApplicationCode/Commands/SurfaceCommands/RicImportSurfacesFeature.cpp index 095cb8eb02..9216528b6d 100644 --- a/ApplicationCode/Commands/SurfaceCommands/RicImportSurfacesFeature.cpp +++ b/ApplicationCode/Commands/SurfaceCommands/RicImportSurfacesFeature.cpp @@ -62,11 +62,22 @@ void RicImportSurfacesFeature::onActionTriggered( bool isChecked ) app->setLastUsedDialogDirectory( "BINARY_GRID", QFileInfo( fileNames.last() ).absolutePath() ); // Find the selected SurfaceCollection - std::vector colls = caf::selectedObjectsByTypeStrict(); - if ( colls.empty() ) return; - RimSurfaceCollection* surfColl = colls[0]; + RimSurfaceCollection* surfColl = nullptr; + { + std::vector colls = caf::selectedObjectsByTypeStrict(); + if ( !colls.empty() ) + { + surfColl = colls.front(); + } + } - // For each file, + if ( !surfColl ) + { + auto proj = RimProject::current(); + surfColl = proj->activeOilField()->surfaceCollection(); + } + + if ( !surfColl ) return; RimSurface* lastCreatedOrUpdated = surfColl->importSurfacesFromFiles( fileNames );