MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / makeBox

Method makeBox

src/Mod/Part/App/AppPartPy.cpp:1399–1445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1397 }
1398 }
1399 Py::Object makeBox(const Py::Tuple& args)
1400 {
1401 double length, width, height;
1402 PyObject *pPnt = nullptr, *pDir = nullptr;
1403 if (!PyArg_ParseTuple(
1404 args.ptr(),
1405 "ddd|O!O!",
1406 &length,
1407 &width,
1408 &height,
1409 &(Base::VectorPy::Type),
1410 &pPnt,
1411 &(Base::VectorPy::Type),
1412 &pDir
1413 )) {
1414 throw Py::Exception();
1415 }
1416
1417 if (length < Precision::Confusion()) {
1418 throw Py::ValueError("length of box too small");
1419 }
1420 if (width < Precision::Confusion()) {
1421 throw Py::ValueError("width of box too small");
1422 }
1423 if (height < Precision::Confusion()) {
1424 throw Py::ValueError("height of box too small");
1425 }
1426
1427 try {
1428 gp_Pnt p(0, 0, 0);
1429 gp_Dir d(0, 0, 1);
1430 if (pPnt) {
1431 Base::Vector3d pnt = static_cast<Base::VectorPy*>(pPnt)->value();
1432 p.SetCoord(pnt.x, pnt.y, pnt.z);
1433 }
1434 if (pDir) {
1435 Base::Vector3d vec = static_cast<Base::VectorPy*>(pDir)->value();
1436 d.SetCoord(vec.x, vec.y, vec.z);
1437 }
1438 BRepPrimAPI_MakeBox mkBox(gp_Ax2(p, d), length, width, height);
1439 TopoDS_Shape ResultShape = mkBox.Shape();
1440 return Py::asObject(new TopoShapeSolidPy(new TopoShape(ResultShape)));
1441 }
1442 catch (Standard_DomainError&) {
1443 throw Py::Exception(PartExceptionOCCDomainError, "creation of box failed");
1444 }
1445 }
1446 Py::Object makeWedge(const Py::Tuple& args)
1447 {
1448 double xmin, ymin, zmin, z2min, x2min, xmax, ymax, zmax, z2max, x2max;

Callers 15

minimal.pyFile · 0.80
exerciseFunction · 0.80
setupFunction · 0.80
testSubElementsMethod · 0.80
testPlacementMethod · 0.80
testShapeFix_SolidMethod · 0.80
setUpMethod · 0.80
test_OptimalBoxMethod · 0.80
executeMethod · 0.80
ActivatedMethod · 0.80

Calls 5

gp_Ax2Class · 0.70
ExceptionClass · 0.50
ptrMethod · 0.45
valueMethod · 0.45
ShapeMethod · 0.45

Tested by 15

testSubElementsMethod · 0.64
testPlacementMethod · 0.64
testShapeFix_SolidMethod · 0.64
setUpMethod · 0.64
test_OptimalBoxMethod · 0.64
testFinishingPassMethod · 0.64