Ejemplo n.º 1
0
void  CirclePy::setYAxis(Py::Object arg)
{
    PyObject* p = arg.ptr();
    Base::Vector3d val;
    if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
        val = static_cast<Base::VectorPy*>(p)->value();
    }
    else if (PyTuple_Check(p)) {
        val = Base::getVectorFromTuple<double>(p);
    }
    else {
        std::string error = std::string("type must be 'Vector', not ");
        error += p->ob_type->tp_name;
        throw Py::TypeError(error);
    }

    Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
    try {
        gp_Ax2 pos;
        pos = circle->Position();
        pos.SetYDirection(gp_Dir(val.x, val.y, val.z));
        circle->SetPosition(pos);
    }
    catch (Standard_Failure) {
        throw Py::Exception("cannot set Y axis");
    }
}