}
}
}
+ if (anAttributeType == ModelAPI_AttributeSelection::typeId()) {
+ AttributeSelectionPtr aSelectAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ ObjectPtr anObject = aSelectAttr->context();
+ // a context of the selection attribute is a feature result. It can be a case when the result
+ // of the feature is null, e.g. the feature is modified and has not been executed yet.
+ // The validator returns an invalid result here. The case is an extrusion built on a sketch
+ // feature. A new sketch element creation leads to an empty result.
+ if (!anObject.get())
+ isSketchEntities = false;
+ else {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+ isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+ }
+ }
if (anAttributeType == ModelAPI_AttributeRefList::typeId()) {
AttributeRefListPtr aRefListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
#include "SketchShapePlugin_Feature.h"
+#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeBoolean.h>
void SketchShapePlugin_Feature::initAttributes()
{
+ data()->addAttribute(SKETCH_ID(), ModelAPI_AttributeSelection::typeId());
data()->addAttribute(VERTEX_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
data()->addAttribute(VERTEX_CHOICE_ID(), ModelAPI_AttributeBoolean::typeId());
}
return MY_SKETCH_SHAPE_ID;
}
+ /// Sketch feature
+ inline static const std::string& SKETCH_ID()
+ {
+ static const std::string MY_SKETCH_ID("Sketch");
+ return MY_SKETCH_ID;
+ }
+
/// List of vertices to be extracted
inline static const std::string& VERTEX_LIST_ID()
{
<workbench id="Sketch">
<group id="Exchange">
<feature id="SketchShape" title="Sketch vertices, edges and faces" tooltip="Construct vertices, edges and faces by sketch" icon=":icons/sketchshape.png">
+ <shape_selector id="Sketch"
+ label="Sketch"
+ icon=":icons/sketch.png"
+ tooltip="Select a sketch"
+ shape_types="objects">
+ <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
+ </shape_selector>
<sketchshape_groupbox title="Direction">
<boolvalue id="VertexChoice" label="VERTICES" default="true" tooltip="Vertices selection on sketch"/>
<sketch_multi_selector id="VertexList"