assert (len(aWireFeature.results()) > 0)
import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(-68.61063464837, 232.418524871355, -488.85077186964, 232.418524871355)
+SketchLine_2 = Sketch_1.addLine(-488.85077186964, 232.418524871355, -488.85077186964, -153.516295025729)
+SketchLine_3 = Sketch_1.addLine(-488.85077186964, -153.516295025729, -68.61063464837, -153.516295025729)
+SketchLine_4 = Sketch_1.addLine(-68.61063464837, -153.516295025729, -68.61063464837, 232.418524871355)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()[0])
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()[0])
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()[0])
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()[0])
+model.do()
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")])
+Wire_1.addContour()
+model.end()
+
assert(model.checkPythonDump())
}
}
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ setByTwoPlanes(thePlane1, thePlane2, theOffset2, theReverseOffset2);
+ }
+}
+
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ setByTwoPlanes(thePlane1, theOffset1, theReverseOffset1, thePlane2);
+ }
+}
+
//==================================================================================================
ConstructionAPI_Axis::~ConstructionAPI_Axis()
{
execute();
}
+//==================================================================================================
+void ConstructionAPI_Axis::setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2)
+{
+ fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES(), creationMethod());
+ fillAttribute(thePlane1, plane1());
+ fillAttribute("", useOffset1());
+ fillAttribute(thePlane2, plane2());
+ fillAttribute(ConstructionPlugin_Axis::USE_OFFSET2(), useOffset2());
+ fillAttribute(theOffset2, offset2());
+ fillAttribute(theReverseOffset2, reverseOffset2());
+
+ execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Axis::setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2)
+{
+ fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES(), creationMethod());
+ fillAttribute(thePlane1, plane1());
+ fillAttribute(ConstructionPlugin_Axis::USE_OFFSET1(), useOffset1());
+ fillAttribute(theOffset1, offset1());
+ fillAttribute(theReverseOffset1, reverseOffset1());
+ fillAttribute(thePlane2, plane2());
+ fillAttribute("", useOffset2());
+
+ execute();
+}
+
//==================================================================================================
void ConstructionAPI_Axis::dump(ModelHighAPI_Dumper& theDumper) const
{
theDumper << ", " << anAttrPlane << ", " << anAttrPoint;
} else if(aCreationMethod == ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES()) {
AttributeSelectionPtr anAttrPlane1 = aBase->selection(ConstructionPlugin_Axis::PLANE1());
- AttributeDoublePtr anAttrOffset1 = aBase->real(ConstructionPlugin_Axis::OFFSET1());
- AttributeBooleanPtr anAttrReverseOffset1 = aBase->boolean(ConstructionPlugin_Axis::REVERSE_OFFSET1());
AttributeSelectionPtr anAttrPlane2 = aBase->selection(ConstructionPlugin_Axis::PLANE2());
- AttributeDoublePtr anAttrOffset2 = aBase->real(ConstructionPlugin_Axis::OFFSET2());
- AttributeBooleanPtr anAttrReverseOffset2 = aBase->boolean(ConstructionPlugin_Axis::REVERSE_OFFSET2());
- theDumper << ", " << anAttrPlane1 << ", " << anAttrOffset1 << ", " << anAttrReverseOffset1
- << ", " << anAttrPlane2 << ", " << anAttrOffset2 << ", " << anAttrReverseOffset2;
+ theDumper << ", " << anAttrPlane1;
+ if(aBase->string(ConstructionPlugin_Axis::USE_OFFSET1())->isInitialized()
+ && !aBase->string(ConstructionPlugin_Axis::USE_OFFSET1())->value().empty()) {
+ AttributeDoublePtr anAttrOffset1 = aBase->real(ConstructionPlugin_Axis::OFFSET1());
+ AttributeBooleanPtr anAttrReverseOffset1 = aBase->boolean(ConstructionPlugin_Axis::REVERSE_OFFSET1());
+ theDumper << ", " << anAttrOffset1 << ", " << anAttrReverseOffset1;
+ }
+
+ theDumper << ", " << anAttrPlane2;
+ if(aBase->string(ConstructionPlugin_Axis::USE_OFFSET2())->isInitialized()
+ && !aBase->string(ConstructionPlugin_Axis::USE_OFFSET2())->value().empty()) {
+ AttributeDoublePtr anAttrOffset2 = aBase->real(ConstructionPlugin_Axis::OFFSET2());
+ AttributeBooleanPtr anAttrReverseOffset2 = aBase->boolean(ConstructionPlugin_Axis::REVERSE_OFFSET2());
+ theDumper << ", " << anAttrOffset2 << ", " << anAttrReverseOffset2;
+ }
} else if(aCreationMethod == ConstructionPlugin_Axis::CREATION_METHOD_BY_POINT_AND_DIRECTION()) {
AttributeSelectionPtr anAttrFirstPnt = aBase->selection(ConstructionPlugin_Axis::POINT_FIRST());
AttributeDoublePtr anAttrX = aBase->real(ConstructionPlugin_Axis::X_DIRECTION());
return AxisPtr(new ConstructionAPI_Axis(aFeature, thePlane1, theOffset1, theReverseOffset1,
thePlane2, theOffset2, theReverseOffset2));
}
+
+//==================================================================================================
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2)
+{
+ // TODO(spo): check that thePart is not empty
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
+ return AxisPtr(new ConstructionAPI_Axis(aFeature, thePlane1,
+ thePlane2, theOffset2, theReverseOffset2));
+}
+
+//==================================================================================================
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2)
+{
+ // TODO(spo): check that thePart is not empty
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
+ return AxisPtr(new ConstructionAPI_Axis(aFeature, thePlane1, theOffset1, theReverseOffset1,
+ thePlane2));
+}
const ModelHighAPI_Double& theOffset2,
const bool theReverseOffset2);
+ /// Constructor with values
+ CONSTRUCTIONAPI_EXPORT
+ ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2);
+
+ /// Constructor with values
+ CONSTRUCTIONAPI_EXPORT
+ ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2);
+
/// Destructor
CONSTRUCTIONAPI_EXPORT
virtual ~ConstructionAPI_Axis();
const ModelHighAPI_Double& theOffset2,
const bool theReverseOffset2);
+ /// Set by two planes
+ CONSTRUCTIONAPI_EXPORT
+ void setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2);
+
+ /// Set by two planes
+ CONSTRUCTIONAPI_EXPORT
+ void setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2);
+
/// Dump wrapped feature
CONSTRUCTIONAPI_EXPORT
virtual void dump(ModelHighAPI_Dumper& theDumper) const;
const ModelHighAPI_Double& theOffset2,
const bool theReverseOffset2);
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
+CONSTRUCTIONAPI_EXPORT
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
+CONSTRUCTIONAPI_EXPORT
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2);
+
#endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_ */