+ std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
+
+ if (!aDocRef->value()) { // create (or open) a document if it is not yet created
+ std::shared_ptr<ModelAPI_Document> aDoc = document()->subDocument(data()->name());
+ if (aDoc) {
+ aDocRef->setValue(aDoc);
+ }
+ }
+ if (aDocRef->value())
+ ModelAPI_Session::get()->setActiveDocument(aDocRef->value());