diff --git a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp index 00b9a6dd99..4f17ca1e73 100644 --- a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp +++ b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp @@ -19,6 +19,7 @@ #include "RicCreateSummaryCaseCollectionFeature.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" #include "cafPdmObject.h" @@ -34,9 +35,16 @@ CAF_CMD_SOURCE_INIT(RicCreateSummaryCaseCollectionFeature, "RicCreateSummaryCase bool RicCreateSummaryCaseCollectionFeature::isCommandEnabled() { std::vector selection; - caf::SelectionManager::instance()->objectsByType(&selection); + caf::SelectionManager::instance()->objectsByType(&selection); - return (selection.size() > 0); + RimSummaryCaseCollection* summaryCaseCollection = nullptr; + + if (selection.size() > 0) + { + selection[0]->firstAncestorOrThisOfType(summaryCaseCollection); + } + + return (selection.size() > 0 && !summaryCaseCollection); } //--------------------------------------------------------------------------------------------------