#include <ModelHighAPI_Double.h>
#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Reference.h>
#include <ModelHighAPI_Tools.h>
//==================================================================================================
//==================================================================================================
FeaturesAPI_Extrusion::~FeaturesAPI_Extrusion()
{
+}
+//==================================================================================================
+void FeaturesAPI_Extrusion::setNestedSketch(const ModelHighAPI_Reference& theSketch)
+{
+ mysketch->setValue(theSketch.feature());
+ mybaseObjects->clear();
+ mybaseObjects->append(theSketch.feature()->firstResult(), GeomShapePtr());
+
+ execIfBaseNotEmpty();
}
//==================================================================================================
void FeaturesAPI_Extrusion::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
{
+ mysketch->setValue(ObjectPtr());
+ mybaseObjects->clear();
fillAttribute(theBaseObjects, mybaseObjects);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
{
fillAttribute(theDirection, mydirection);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
fillAttribute(theToSize, mytoSize);
fillAttribute(theFromSize, myfromSize);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
fillAttribute(theSize, mytoSize);
fillAttribute(ModelHighAPI_Double(), myfromSize);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
fillAttribute(theFromObject, myfromObject);
fillAttribute(theFromOffset, myfromOffset);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
FeaturePtr aBase = feature();
const std::string& aDocName = theDumper.name(aBase->document());
- AttributeSelectionListPtr anObjects = aBase->selectionList(FeaturesPlugin_Extrusion::BASE_OBJECTS_ID());
- AttributeSelectionPtr aDirection = aBase->selection(FeaturesPlugin_Extrusion::DIRECTION_OBJECT_ID());
+ AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Extrusion::BASE_OBJECTS_ID());
+ AttributeSelectionPtr anAttrDirection = aBase->selection(FeaturesPlugin_Extrusion::DIRECTION_OBJECT_ID());
- theDumper << aBase << " = model.addExtrusion(" << aDocName << ", " << anObjects << ", " << aDirection;
+ theDumper << aBase << " = model.addExtrusion(" << aDocName << ", " << anAttrObjects << ", " << anAttrDirection;
std::string aCreationMethod = aBase->string(FeaturesPlugin_Extrusion::CREATION_METHOD())->value();
}
theDumper << ")" << std::endl;
+
+ AttributeReferencePtr anAttrSketch = aBase->reference(FeaturesPlugin_CompositeSketch::SKETCH_ID());
+ if(anAttrSketch->isInitialized()) {
+ theDumper << aBase << ".setNestedSketch(" << anAttrSketch << ")";
+ }
+}
+
+void FeaturesAPI_Extrusion::execIfBaseNotEmpty()
+{
+ if(mybaseObjects->size() > 0) {
+ execute();
+ }
}
//==================================================================================================
#include <ModelHighAPI_Macro.h>
class ModelHighAPI_Double;
+class ModelHighAPI_Reference;
class ModelHighAPI_Selection;
/// \class FeaturesAPI_Extrusion
FEATURESAPI_EXPORT
virtual ~FeaturesAPI_Extrusion();
- INTERFACE_10(FeaturesPlugin_Extrusion::ID(),
+ INTERFACE_11(FeaturesPlugin_Extrusion::ID(),
+ sketch, FeaturesPlugin_Extrusion::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch object */,
baseObjects, FeaturesPlugin_Extrusion::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */,
creationMethod, FeaturesPlugin_Extrusion::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */,
toSize, FeaturesPlugin_Extrusion::TO_SIZE_ID(), ModelAPI_AttributeDouble, /** To size */,
direction, FeaturesPlugin_Extrusion::DIRECTION_OBJECT_ID(), ModelAPI_AttributeSelection, /** Direction */,
sketchLauncher, FeaturesPlugin_Extrusion::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */)
+ /// Modify base attribute of the feature.
+ FEATURESAPI_EXPORT
+ void setNestedSketch(const ModelHighAPI_Reference& theSketch);
+
/// Modify base attribute of the feature.
FEATURESAPI_EXPORT
void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
/// Dump wrapped feature
FEATURESAPI_EXPORT
virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+
+private:
+ void execIfBaseNotEmpty();
};
/// Pointer on Extrusion object.