+ // Check that object belongs to active document or PartSet
+ DocumentPtr aDoc = aRes->document();
+ SessionPtr aMgr = ModelAPI_Session::get();
+ if (!(aDoc == aMgr->activeDocument()) && !(aDoc == aMgr->moduleDocument()))
+ return false;
+
+ // Check that the result has a shape
+ GeomShapePtr aShape = ModelAPI_Tools::shape(aRes);
+ if (!aShape)
+ return false;
+
+ /// Check that object has acceptable type
+ if (!acceptObjectType(aObject))
+ return false;
+
+ // Get sub-shapes from local selection
+ if (!theValue.shape().IsNull()) {
+ aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(theValue.shape()));
+ }
+
+ // Check that the selection corresponds to selection type
+ if (!acceptSubShape(aShape))
+ return false;
+// if (!acceptObjectShape(aObject))
+// return false;
+
+ if (isValid(aObject, aShape)) {
+ setObject(aObject, aShape);
+ return true;
+ }
+ return false;