+
+FeaturePtr InitializationPlugin_Plugin::createAxis(DocumentPtr theDoc, FeaturePtr theOrigin,
+ double theX, double theY, double theZ)
+{
+ std::shared_ptr<ModelAPI_Feature> aAxis = theDoc->addFeature("Axis");
+ aAxis->string("CreationMethod")->setValue("AxisByPointAndDirection");
+
+ ResultPtr aResult = theOrigin->firstResult();
+ aAxis->selection("FirstPoint")->setValue(aResult, aResult->shape());
+
+ aAxis->real("X_Direction")->setValue(theX);
+ aAxis->real("Y_Direction")->setValue(theY);
+ aAxis->real("Z_Direction")->setValue(theZ);
+
+ if (theX != 0) {
+ aAxis->data()->setName("OX");
+ } else if (theY != 0) {
+ aAxis->data()->setName("OY");
+ } else if (theZ != 0) {
+ aAxis->data()->setName("OZ");
+ }
+ // don't show automatically created feature in the features history
+ aAxis->setInHistory(aAxis, false);
+ aAxis->execute();
+ aAxis->data()->execState(ModelAPI_StateDone);
+ aAxis->firstResult()->data()->execState(ModelAPI_StateDone);
+
+ return aAxis;
+}