{
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
if (thePart) {
- boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = thePart->data()->docRef("PartDocument");
- if (aDocRef)
- aMgr->setCurrentDocument(aDocRef->value());
+ DocumentPtr aFeaDoc;
+ if (thePart->data()) {
+ aFeaDoc = thePart->data()->docRef("PartDocument")->value();
+ } else {
+ ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(thePart);
+ aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value();
+ }
+ if (aFeaDoc)
+ aMgr->setCurrentDocument(aFeaDoc);
} else {
aMgr->setCurrentDocument(aMgr->rootDocument());
}
aMgr->rootDocument()->startOperation();
foreach (FeaturePtr aFeature, theList) {
if (aFeature->getKind() == "Part") {
- DocumentPtr aDoc = aFeature->data()->docRef("PartDocument")->value();
+ DocumentPtr aDoc;
+ if (aFeature->data()) {
+ aDoc = aFeature->data()->docRef("PartDocument")->value();
+ } else {
+ ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
+ aDoc = aObject->featureRef()->data()->docRef("PartDocument")->value();
+ }
if (aDoc == aMgr->currentDocument()) {
aDoc->close();
}