- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = data()->refattr(PART_DUPLICATE_ATTR_REF);
- if (!aRef->attr()) { // create a copy: if not created yet attribute is not initialized
- boost::shared_ptr<ModelAPI_PluginManager> aPManager = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->rootDocument();
- boost::shared_ptr<PartSetPlugin_Part> aSource; // searching for source document attribute
- for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
- aSource = boost::dynamic_pointer_cast<PartSetPlugin_Part>(
- aRoot->feature(getGroup(), a, true));
- if (aSource->data()->docRef(PART_ATTR_DOC_REF)->value() == aPManager->currentDocument())
- break;
- aSource.reset();
- }
- if (aSource) {
- boost::shared_ptr<ModelAPI_Document> aCopy =
- aPManager->copy(aSource->data()->docRef(PART_ATTR_DOC_REF)->value(), data()->getName());
- aRef->setFeature(aSource);
- }
+ std::shared_ptr<ModelAPI_Document> aCopy = aPManager->copy(
+ aSource->data()->document(ModelAPI_ResultPart::DOC_REF())->value(),
+ std::dynamic_pointer_cast<ModelAPI_ResultPart>(aNewPart->firstResult())->partDoc()->id());