}
// set as current also after it becomes sub to set correctly enabled for other sketch subs
document()->setCurrentFeature(aNew, false);
+
return aNew;
}
void SketchPlugin_Sketch::attributeChanged(const std::string& theID) {
if (theID == SketchPlugin_SketchEntity::EXTERNAL_ID()) {
- std::shared_ptr<GeomAPI_Shape> aSelection =
- data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->value();
- if (aSelection) { // update arguments due to the selection value
+ AttributeSelectionPtr aSelAttr = selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
+ if (aSelAttr->context().get()) { // update arguments due to the selection value
+ std::shared_ptr<GeomAPI_Shape> aSelection = aSelAttr->value();
+ if (!aSelection.get()) aSelection = aSelAttr->context()->shape();
// update the sketch plane
std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aSelection));
std::shared_ptr<GeomAPI_Pln> aPlane = aFace->getPlane();
theFeature->data()->copyTo(aNewFeature->data());
// external state should not be copied as a new object is an object of the current sketch
if (theFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID()).get())
- theFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->setValue(ResultPtr(),
- GeomShapePtr());
+ aNewFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->setValue(ResultPtr(),
+ GeomShapePtr());
aNewFeature->data()->setName(aUniqueFeatureName);
// text expressions could block setValue of some attributes
SketchPlugin_Tools::clearExpressions(aNewFeature);