FeaturesAPI_Extrusion.h
FeaturesAPI_Group.h
FeaturesAPI_Placement.h
+ FeaturesAPI_Revolution.h
FeaturesAPI_Rotation.h
FeaturesAPI_Translation.h
)
FeaturesAPI_Group.cpp
FeaturesAPI_Placement.cpp
FeaturesAPI_Rotation.cpp
+ FeaturesAPI_Revolution.cpp
FeaturesAPI_Translation.cpp
)
%shared_ptr(FeaturesAPI_Extrusion)
%shared_ptr(FeaturesAPI_Group)
%shared_ptr(FeaturesAPI_Placement)
+%shared_ptr(FeaturesAPI_Revolution)
%shared_ptr(FeaturesAPI_Rotation)
%shared_ptr(FeaturesAPI_Translation)
%include "FeaturesAPI_Extrusion.h"
%include "FeaturesAPI_Group.h"
%include "FeaturesAPI_Placement.h"
+%include "FeaturesAPI_Revolution.h"
%include "FeaturesAPI_Rotation.h"
%include "FeaturesAPI_Translation.h"
void FeaturesAPI_Extrusion::setSizes(const ModelHighAPI_Double& theToSize,
const ModelHighAPI_Double& theFromSize)
{
- fillAttribute("BySizes", mycreationMethod);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
fillAttribute(theToSize, mytoSize);
fillAttribute(theFromSize, myfromSize);
//==================================================================================================
void FeaturesAPI_Extrusion::setSize(const ModelHighAPI_Double& theSize)
{
- fillAttribute("BySizes", mycreationMethod);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
fillAttribute(theSize, mytoSize);
fillAttribute(ModelHighAPI_Double(), myfromSize);
const ModelHighAPI_Selection& theFromObject,
const ModelHighAPI_Double& theFromOffset)
{
- fillAttribute("ByPlanesAndOffsets", mycreationMethod);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
fillAttribute(theToObject, mytoObject);
fillAttribute(theToOffset, mytoOffset);
fillAttribute(theFromObject, myfromObject);
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: FeaturesAPI_Revolution.cpp
+// Created: 09 June 2016
+// Author: Dmitry Bobylev
+
+#include "FeaturesAPI_Revolution.h"
+
+#include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//==================================================================================================
+FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theAngle)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(theAxis, myaxis);
+ setAngles(theAngle, ModelHighAPI_Double());
+ }
+}
+
+//==================================================================================================
+FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theToAngle,
+ const ModelHighAPI_Double& theFromAngle)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(theAxis, myaxis);
+ setAngles(theToAngle, theFromAngle);
+ }
+}
+
+//==================================================================================================
+FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Selection& theToObject,
+ const ModelHighAPI_Double& theToOffset,
+ const ModelHighAPI_Selection& theFromObject,
+ const ModelHighAPI_Double& theFromOffset)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(theAxis, myaxis);
+ setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
+ }
+}
+
+//==================================================================================================
+FeaturesAPI_Revolution::~FeaturesAPI_Revolution()
+{
+
+}
+
+//==================================================================================================
+void FeaturesAPI_Revolution::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+ fillAttribute(theBaseObjects, mybaseObjects);
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Revolution::setAxis(const ModelHighAPI_Selection& theAxis)
+{
+ fillAttribute(theAxis, myaxis);
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Revolution::setAngles(const ModelHighAPI_Double& theToAngle,
+ const ModelHighAPI_Double& theFromAngle)
+{
+ fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
+ fillAttribute(theToAngle, mytoAngle);
+ fillAttribute(theFromAngle, myfromAngle);
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Revolution::setAngle(const ModelHighAPI_Double& theAngle)
+{
+ fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
+ fillAttribute(theAngle, mytoAngle);
+ fillAttribute(ModelHighAPI_Double(), myfromAngle);
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Revolution::setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject,
+ const ModelHighAPI_Double& theToOffset,
+ const ModelHighAPI_Selection& theFromObject,
+ const ModelHighAPI_Double& theFromOffset)
+{
+ fillAttribute("ByPlanesAndOffsets", mycreationMethod);
+ fillAttribute(theToObject, mytoObject);
+ fillAttribute(theToOffset, mytoOffset);
+ fillAttribute(theFromObject, myfromObject);
+ fillAttribute(theFromOffset, myfromOffset);
+
+ execute();
+}
+
+// TODO(spo): make add* as static functions of the class
+//==================================================================================================
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theAngle)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
+ return RevolutionPtr(new FeaturesAPI_Revolution(aFeature, theBaseObjects, theAxis, theAngle));
+}
+
+//==================================================================================================
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theToAngle,
+ const ModelHighAPI_Double& theFromAngle)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
+ return RevolutionPtr(new FeaturesAPI_Revolution(aFeature,
+ theBaseObjects,
+ theAxis,
+ theToAngle,
+ theFromAngle));
+}
+
+//==================================================================================================
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Selection& theToObject,
+ const ModelHighAPI_Double& theToOffset,
+ const ModelHighAPI_Selection& theFromObject,
+ const ModelHighAPI_Double& theFromOffset)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
+ return RevolutionPtr(new FeaturesAPI_Revolution(aFeature,
+ theBaseObjects,
+ theAxis,
+ theToObject,
+ theToOffset,
+ theFromObject,
+ theFromOffset));
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: FeaturesAPI_Revolution.h
+// Created: 09 June 2016
+// Author: Dmitry Bobylev
+
+#ifndef FeaturesAPI_Revolution_H_
+#define FeaturesAPI_Revolution_H_
+
+#include "FeaturesAPI.h"
+
+#include <FeaturesPlugin_Revolution.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+
+/// \class FeaturesAPI_Revolution
+/// \ingroup CPPHighAPI
+/// \brief Interface for Revolution feature.
+class FeaturesAPI_Revolution: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ FEATURESAPI_EXPORT
+ explicit FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ FEATURESAPI_EXPORT
+ explicit FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theAngle);
+
+ /// Constructor with values.
+ FEATURESAPI_EXPORT
+ explicit FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theToAngle,
+ const ModelHighAPI_Double& theFromAngle);
+
+ /// Constructor with values.
+ FEATURESAPI_EXPORT
+ explicit FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Selection& theToObject,
+ const ModelHighAPI_Double& theToOffset,
+ const ModelHighAPI_Selection& theFromObject,
+ const ModelHighAPI_Double& theFromOffset);
+
+ /// Destructor.
+ FEATURESAPI_EXPORT
+ virtual ~FeaturesAPI_Revolution();
+
+ INTERFACE_10(FeaturesPlugin_Revolution::ID(),
+ baseObjects, FeaturesPlugin_CompositeSketch::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */,
+ axis, FeaturesPlugin_Revolution::AXIS_OBJECT_ID(), ModelAPI_AttributeSelection, /** Axis */,
+ creationMethod, FeaturesPlugin_Revolution::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */,
+ toAngle, FeaturesPlugin_Revolution::TO_ANGLE_ID(), ModelAPI_AttributeDouble, /** To angle */,
+ fromAngle, FeaturesPlugin_Revolution::FROM_ANGLE_ID(), ModelAPI_AttributeDouble, /** From angle */,
+ toObject, FeaturesPlugin_Revolution::TO_OBJECT_ID(), ModelAPI_AttributeSelection, /** To object */,
+ toOffset, FeaturesPlugin_Revolution::TO_OFFSET_ID(), ModelAPI_AttributeDouble, /** To offset */,
+ fromObject, FeaturesPlugin_Revolution::FROM_OBJECT_ID(), ModelAPI_AttributeSelection, /** From object */,
+ fromOffset, FeaturesPlugin_Revolution::FROM_OFFSET_ID(), ModelAPI_AttributeDouble, /** From offset */,
+ sketchLauncher, FeaturesPlugin_CompositeSketch::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */)
+
+ /// Modify base attribute of the feature.
+ FEATURESAPI_EXPORT
+ void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+ /// Modify axis_object attribute of the feature.
+ FEATURESAPI_EXPORT
+ void setAxis(const ModelHighAPI_Selection& theAxis);
+
+ /// Modify CreationMethod, to_angle, from_angle attributes of the feature.
+ FEATURESAPI_EXPORT
+ void setAngles(const ModelHighAPI_Double& theToAngle, const ModelHighAPI_Double& theFromAngle);
+
+ /// Modify CreationMethod, to_angle, from_angle attributes of the feature.
+ FEATURESAPI_EXPORT
+ void setAngle(const ModelHighAPI_Double& theAngle);
+
+ /// Modify CreationMethod, to_object, to_offset, from_object, from_offset attributes of the feature.
+ FEATURESAPI_EXPORT
+ void setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject,
+ const ModelHighAPI_Double& theToOffset,
+ const ModelHighAPI_Selection& theFromObject,
+ const ModelHighAPI_Double& theFromOffset);
+};
+
+/// Pointer on Revolution object.
+typedef std::shared_ptr<FeaturesAPI_Revolution> RevolutionPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Revolution feature.
+FEATURESAPI_EXPORT
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theAngle);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Revolution feature.
+FEATURESAPI_EXPORT
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Double& theToAngle,
+ const ModelHighAPI_Double& theFromAngle);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Revolution feature.
+FEATURESAPI_EXPORT
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theAxis,
+ const ModelHighAPI_Selection& theToObject,
+ const ModelHighAPI_Double& theToOffset,
+ const ModelHighAPI_Selection& theFromObject,
+ const ModelHighAPI_Double& theFromOffset);
+
+#endif // FeaturesAPI_Revolution_H_
#include "FeaturesAPI_Extrusion.h"
#include "FeaturesAPI_Group.h"
#include "FeaturesAPI_Placement.h"
+ #include "FeaturesAPI_Revolution.h"
#include "FeaturesAPI_Rotation.h"
#include "FeaturesAPI_Translation.h"
double aToSize = 0.0;
double aFromSize = 0.0;
- if(string(CREATION_METHOD())->value() == "BySizes") {
+ if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_SIZES()) {
aToSize = real(TO_SIZE_ID())->value();
aFromSize = real(FROM_SIZE_ID())->value();
} else {
GeomShapePtr aToShape;
GeomShapePtr aFromShape;
- if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
+ if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_PLANES()) {
aSelection = selection(TO_OBJECT_ID());
if(aSelection.get()) {
aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(aSelection->value());
return MY_CREATION_METHOD_ID;
}
+ /// Attribute name for creation method.
+ inline static const std::string& CREATION_METHOD_BY_SIZES()
+ {
+ static const std::string MY_CREATION_METHOD_ID("BySizes");
+ return MY_CREATION_METHOD_ID;
+ }
+
+ /// Attribute name for creation method.
+ inline static const std::string& CREATION_METHOD_BY_PLANES()
+ {
+ static const std::string MY_CREATION_METHOD_ID("ByPlanesAndOffsets");
+ return MY_CREATION_METHOD_ID;
+ }
+
/// Attribute name of an object to which the extrusion grows.
inline static const std::string& DIRECTION_OBJECT_ID()
{
double aToAngle = 0.0;
double aFromAngle = 0.0;
- if(string(CREATION_METHOD())->value() == "ByAngles") {
+ if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_ANGLES()) {
aToAngle = real(TO_ANGLE_ID())->value();
aFromAngle = real(FROM_ANGLE_ID())->value();
} else {
GeomShapePtr aToShape;
GeomShapePtr aFromShape;
- if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
+ if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_PLANES()) {
aSelection = selection(TO_OBJECT_ID());
if(aSelection.get()) {
aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(aSelection->value());
return MY_CREATION_METHOD_ID;
}
+ /// Attribute name for creation method.
+ inline static const std::string& CREATION_METHOD_BY_ANGLES()
+ {
+ static const std::string MY_CREATION_METHOD_ID("ByAngles");
+ return MY_CREATION_METHOD_ID;
+ }
+
+ /// Attribute name for creation method.
+ inline static const std::string& CREATION_METHOD_BY_PLANES()
+ {
+ static const std::string MY_CREATION_METHOD_ID("ByPlanesAndOffsets");
+ return MY_CREATION_METHOD_ID;
+ }
+
/// Attribute name of an revolution axis.
inline static const std::string& AXIS_OBJECT_ID()
{
circle = sketch.addCircle(0, 0, 10)
model.do()
- base = sketch.selectFace(circle.result())
+ base = sketch.selectFace()
self.extrusion = model.addExtrusion(self.part, base, 10, 0)
model.do()
circle = sketch.addCircle(0, 0, 10)
model.do()
- base = sketch.selectFace(circle.result())
+ base = sketch.selectFace()
extrusion = model.addExtrusion(self.part, base, 10, 0)
model.do()
- self.assertEqual(extrusion.getCreationMethod().value(), "BySizes")
- self.assertEqual(extrusion.getToSize().value(), 10)
- self.assertEqual(extrusion.getFromSize().value(), 0)
- self.assertEqual(extrusion.getToObject().context(), None)
- self.assertEqual(extrusion.getToOffset().value(), 0)
- self.assertEqual(extrusion.getFromObject().context(), None)
- self.assertEqual(extrusion.getFromOffset().value(), 0)
+ self.assertEqual(extrusion.creationMethod().value(), "BySizes")
+ self.assertEqual(extrusion.toSize().value(), 10)
+ self.assertEqual(extrusion.fromSize().value(), 0)
+ self.assertEqual(extrusion.toObject().context(), None)
+ self.assertEqual(extrusion.toOffset().value(), 0)
+ self.assertEqual(extrusion.fromObject().context(), None)
+ self.assertEqual(extrusion.fromOffset().value(), 0)
def test_add_extrusion_by_face_and_planes(self):
# base
model.do()
- base = base_sketch.selectFace(base_circle.result())
- to_object = to_sketch.selectFace(to_circle.result())[0]
- from_object = from_sketch.selectFace(from_circle.result())[0]
+ base = base_sketch.selectFace()
+ to_object = to_sketch.selectFace()[0]
+ from_object = from_sketch.selectFace()[0]
extrusion = model.addExtrusion(self.part, base,
to_object, 15,
from_object, 20)
- self.assertEqual(extrusion.getCreationMethod().value(), "ByPlanesAndOffsets")
- self.assertEqual(extrusion.getToSize().value(), 0)
- self.assertEqual(extrusion.getFromSize().value(), 0)
+ self.assertEqual(extrusion.creationMethod().value(), "ByPlanesAndOffsets")
+ self.assertEqual(extrusion.toSize().value(), 0)
+ self.assertEqual(extrusion.fromSize().value(), 0)
# self.assertEqual(extrusion.getToObject().context(),
# to_sketch.result())
- self.assertEqual(extrusion.getToOffset().value(), 15)
+ self.assertEqual(extrusion.toOffset().value(), 15)
# self.assertEqual(extrusion.getFromObject().context(),
# from_sketch.result())
- self.assertEqual(extrusion.getFromOffset().value(), 20)
+ self.assertEqual(extrusion.fromOffset().value(), 20)
class FeaturesExtrusionTestCase(FeaturesExtrusionFixture):
def test_extrusion_get_attribute(self):
# call method of the feature
- self.assertTrue(isinstance(self.extrusion.getBase(),
+ self.assertTrue(isinstance(self.extrusion.baseObjects(),
ModelAPI.ModelAPI_AttributeSelectionList))
- self.assertTrue(isinstance(self.extrusion.getCreationMethod(),
+ self.assertTrue(isinstance(self.extrusion.creationMethod(),
ModelAPI.ModelAPI_AttributeString))
- self.assertTrue(isinstance(self.extrusion.getToSize(),
+ self.assertTrue(isinstance(self.extrusion.toSize(),
ModelAPI.ModelAPI_AttributeDouble))
- self.assertTrue(isinstance(self.extrusion.getFromSize(),
+ self.assertTrue(isinstance(self.extrusion.fromSize(),
ModelAPI.ModelAPI_AttributeDouble))
- self.assertTrue(isinstance(self.extrusion.getToObject(),
+ self.assertTrue(isinstance(self.extrusion.toObject(),
ModelAPI.ModelAPI_AttributeSelection))
- self.assertTrue(isinstance(self.extrusion.getToOffset(),
+ self.assertTrue(isinstance(self.extrusion.toOffset(),
ModelAPI.ModelAPI_AttributeDouble))
- self.assertTrue(isinstance(self.extrusion.getFromObject(),
+ self.assertTrue(isinstance(self.extrusion.fromObject(),
ModelAPI.ModelAPI_AttributeSelection))
- self.assertTrue(isinstance(self.extrusion.getFromOffset(),
+ self.assertTrue(isinstance(self.extrusion.fromOffset(),
ModelAPI.ModelAPI_AttributeDouble))
def test_extrusion_set_sizes(self):
self.extrusion.setSizes(15, 20)
- self.assertEqual(self.extrusion.getCreationMethod().value(), "BySizes")
- self.assertEqual(self.extrusion.getToSize().value(), 15)
- self.assertEqual(self.extrusion.getFromSize().value(), 20)
- self.assertEqual(self.extrusion.getToObject().context(), None)
- self.assertEqual(self.extrusion.getToOffset().value(), 0)
- self.assertEqual(self.extrusion.getFromObject().context(), None)
- self.assertEqual(self.extrusion.getFromOffset().value(), 0)
+ self.assertEqual(self.extrusion.creationMethod().value(), "BySizes")
+ self.assertEqual(self.extrusion.toSize().value(), 15)
+ self.assertEqual(self.extrusion.fromSize().value(), 20)
+ self.assertEqual(self.extrusion.toObject().context(), None)
+ self.assertEqual(self.extrusion.toOffset().value(), 0)
+ self.assertEqual(self.extrusion.fromObject().context(), None)
+ self.assertEqual(self.extrusion.fromOffset().value(), 0)
def test_extrusion_set_planes_and_offsets(self):
# to
model.do()
- to_object = to_sketch.selectFace(to_circle.result())[0]
- from_object = from_sketch.selectFace(from_circle.result())[0]
+ to_object = to_sketch.selectFace()[0]
+ from_object = from_sketch.selectFace()[0]
self.extrusion.setPlanesAndOffsets(to_object, 15, from_object, 20)
model.do()
- base = base_sketch.selectFace(circle.lastResult())
- axis_object = Selection(axis_sketch.firstResult(),
- line.firstResult().shape())
+ base = base_sketch.selectFace()
+ axis_object = Selection(axis_sketch.result()[0],
+ line.result()[0])
self.revolution = model.addRevolution(self.part, base, axis_object,
0, 180)
# base
base_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
circle = base_sketch.addCircle(0, 0, 10)
- # axis
- axis_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
- line = axis_sketch.addLine(20, -10, 20, 10)
model.do()
- base = base_sketch.selectFace(circle.lastResult())
- axis_object = Selection(axis_sketch.firstResult(),
- line.firstResult().shape())
+ base = base_sketch.selectFace()
+ axis_point1 = model.addPoint(self.part, 20, -10, 0)
+ axis_point2 = model.addPoint(self.part, 20, 10, 0)
+ axis_object = model.addAxis(self.part, axis_point1.result()[0], axis_point2.result()[0]).result()[0]
revolution = model.addRevolution(self.part, base, axis_object,
0, 180)
- self.assertEqual(revolution.getCreationMethod().value(), "ByAngles")
- self.assertEqual(revolution.getToAngle().value(), 0)
- self.assertEqual(revolution.getFromAngle().value(), 180)
- self.assertEqual(revolution.getToObject().context(), None)
- self.assertEqual(revolution.getToOffset().value(), 0)
- self.assertEqual(revolution.getFromObject().context(), None)
- self.assertEqual(revolution.getFromOffset().value(), 0)
+ self.assertEqual(revolution.creationMethod().value(), "ByAngles")
+ self.assertEqual(revolution.toAngle().value(), 0)
+ self.assertEqual(revolution.fromAngle().value(), 180)
+ self.assertEqual(revolution.toObject().context(), None)
+ self.assertEqual(revolution.toOffset().value(), 0)
+ self.assertEqual(revolution.fromObject().context(), None)
+ self.assertEqual(revolution.fromOffset().value(), 0)
def test_add_revolution_by_face_and_planes(self):
# base
base_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
base_circle = base_sketch.addCircle(0, 0, 10)
- # axis
- axis_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
- line = axis_sketch.addLine(20, -10, 20, 10)
# to
to_plane = model.defaultPlane("XOY")
- to_plane.location().setZ(10)
+ to_plane.origin().setZ(10)
to_sketch = model.addSketch(self.part, to_plane)
to_circle = to_sketch.addCircle(0, 0, 10)
# from
from_plane = model.defaultPlane("XOY")
- from_plane.location().setZ(-10)
+ from_plane.origin().setZ(-10)
from_sketch = model.addSketch(self.part, from_plane)
from_circle = from_sketch.addCircle(0, 0, 10)
model.do()
- base = base_sketch.selectFace(base_circle.result())
- axis_object = Selection(axis_sketch.firstResult(),
- line.firstResult().shape())
- to_obejct = to_sketch.selectFace(to_circle.result())[0]
- from_object = from_sketch.selectFace(from_circle.result())[0]
+ base = base_sketch.selectFace()
+ axis_point1 = model.addPoint(self.part, 20, -10, 0)
+ axis_point2 = model.addPoint(self.part, 20, 10, 0)
+ axis_object = model.addAxis(self.part, axis_point1.result()[0], axis_point2.result()[0]).result()[0]
+ to_obejct = to_sketch.selectFace()[0]
+ from_object = from_sketch.selectFace()[0]
revolution = model.addRevolution(self.part, base, axis_object,
to_obejct, 15,
from_object, 20)
- self.assertEqual(revolution.getCreationMethod().value(), "ByPlanesAndOffsets")
- self.assertEqual(revolution.getToAngle().value(), 0)
- self.assertEqual(revolution.getFromAngle().value(), 0)
+ self.assertEqual(revolution.creationMethod().value(), "ByPlanesAndOffsets")
+ self.assertEqual(revolution.toAngle().value(), 0)
+ self.assertEqual(revolution.fromAngle().value(), 0)
# self.assertEqual(revolution.getToObject().context(),
# to_sketch.result())
- self.assertEqual(revolution.getToOffset().value(), 15)
+ self.assertEqual(revolution.toOffset().value(), 15)
# self.assertEqual(revolution.getFromObject().context(),
# from_sketch.result())
- self.assertEqual(revolution.getFromOffset().value(), 20)
+ self.assertEqual(revolution.fromOffset().value(), 20)
class FeaturesRevolutionTestCase(FeaturesRevolutionFixture):
def test_revolution_get_attribute(self):
# call method of the feature
- self.assertTrue(isinstance(self.revolution.getBase(),
+ self.assertTrue(isinstance(self.revolution.base(),
ModelAPI.ModelAPI_AttributeSelectionList))
- self.assertTrue(isinstance(self.revolution.getAxisObject(),
+ self.assertTrue(isinstance(self.revolution.axisObject(),
ModelAPI.ModelAPI_AttributeSelection))
- self.assertTrue(isinstance(self.revolution.getCreationMethod(),
+ self.assertTrue(isinstance(self.revolution.creationMethod(),
ModelAPI.ModelAPI_AttributeString))
- self.assertTrue(isinstance(self.revolution.getToAngle(),
+ self.assertTrue(isinstance(self.revolution.toAngle(),
ModelAPI.ModelAPI_AttributeDouble))
- self.assertTrue(isinstance(self.revolution.getFromAngle(),
+ self.assertTrue(isinstance(self.revolution.fromAngle(),
ModelAPI.ModelAPI_AttributeDouble))
- self.assertTrue(isinstance(self.revolution.getToObject(),
+ self.assertTrue(isinstance(self.revolution.toObject(),
ModelAPI.ModelAPI_AttributeSelection))
- self.assertTrue(isinstance(self.revolution.getToOffset(),
+ self.assertTrue(isinstance(self.revolution.toOffset(),
ModelAPI.ModelAPI_AttributeDouble))
- self.assertTrue(isinstance(self.revolution.getFromObject(),
+ self.assertTrue(isinstance(self.revolution.fromObject(),
ModelAPI.ModelAPI_AttributeSelection))
- self.assertTrue(isinstance(self.revolution.getFromOffset(),
+ self.assertTrue(isinstance(self.revolution.fromOffset(),
ModelAPI.ModelAPI_AttributeDouble))
def test_revolution_set_angles(self):
self.revolution.setAngles(90, 270)
- self.assertEqual(self.revolution.getCreationMethod().value(), "ByAngles")
- self.assertEqual(self.revolution.getToAngle().value(), 90)
- self.assertEqual(self.revolution.getFromAngle().value(), 270)
- self.assertEqual(self.revolution.getToObject().context(), None)
- self.assertEqual(self.revolution.getToOffset().value(), 0)
- self.assertEqual(self.revolution.getFromObject().context(), None)
- self.assertEqual(self.revolution.getFromOffset().value(), 0)
+ self.assertEqual(self.revolution.creationMethod().value(), "ByAngles")
+ self.assertEqual(self.revolution.toAngle().value(), 90)
+ self.assertEqual(self.revolution.fromAngle().value(), 270)
+ self.assertEqual(self.revolution.toObject().context(), None)
+ self.assertEqual(self.revolution.toOffset().value(), 0)
+ self.assertEqual(self.revolution.fromObject().context(), None)
+ self.assertEqual(self.revolution.fromOffset().value(), 0)
def test_revolution_set_planes_and_offsets(self):
# base
base_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
base_circle = base_sketch.addCircle(0, 0, 10)
- # axis
- axis_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
- line = axis_sketch.addLine(20, -10, 20, 10)
# to
to_plane = model.defaultPlane("XOY")
- to_plane.location().setZ(10)
+ to_plane.origin().setZ(10)
to_sketch = model.addSketch(self.part, to_plane)
to_circle = to_sketch.addCircle(0, 0, 10)
# from
from_plane = model.defaultPlane("XOY")
- from_plane.location().setZ(-10)
+ from_plane.origin().setZ(-10)
from_sketch = model.addSketch(self.part, from_plane)
from_circle = from_sketch.addCircle(0, 0, 10)
model.do()
- base = base_sketch.selectFace(base_circle.result())
- axis_object = Selection(axis_sketch.firstResult(),
- line.firstResult().shape())
- to_obejct = to_sketch.selectFace(to_circle.result())[0]
- from_object = from_sketch.selectFace(from_circle.result())[0]
+ base = base_sketch.selectFace()
+ axis_point1 = model.addPoint(self.part, 20, -10, 0)
+ axis_point2 = model.addPoint(self.part, 20, 10, 0)
+ axis_object = model.addAxis(self.part, axis_point1.result()[0], axis_point2.result()[0]).result()[0]
+ to_obejct = to_sketch.selectFace()[0]
+ from_object = from_sketch.selectFace()[0]
self.revolution.setPlanesAndOffsets(to_obejct, 15, from_object, 20)
- self.assertEqual(self.revolution.getCreationMethod().value(), "ByPlanesAndOffsets")
- self.assertEqual(self.revolution.getToAngle().value(), 0)
- self.assertEqual(self.revolution.getFromAngle().value(), 0)
+ self.assertEqual(self.revolution.creationMethod().value(), "ByPlanesAndOffsets")
+ self.assertEqual(self.revolution.toAngle().value(), 0)
+ self.assertEqual(self.revolution.fromAngle().value(), 0)
# self.assertEqual(self.revolution.getToObject().context(), None)
- self.assertEqual(self.revolution.getToOffset().value(), 15)
+ self.assertEqual(self.revolution.toOffset().value(), 15)
# self.assertEqual(self.revolution.getFromObject().context(), None)
- self.assertEqual(self.revolution.getFromOffset().value(), 20)
+ self.assertEqual(self.revolution.fromOffset().value(), 20)
if __name__ == "__main__":