CadQuery / cadquery

A python parametric CAD scripting framework based on OCCT
https://cadquery.readthedocs.io
Other
3.24k stars 294 forks source link

makeTorus has a plane surface inside when angleDegrees2 is set #725

Open roipoussiere opened 3 years ago

roipoussiere commented 3 years ago

In the following code, I expect CQ to draw a torus with a 350° angle:

cq.Solid.makeTorus(5, 1, angleDegrees2=350)

But instead I get a full torus with a plane surface inside:

image

fedorkotov commented 3 years ago

makeTorus(...) is based on Open CASCADE function BRepPrimAPI_MakeTorus(...).

[...] The resulting shape is composed of.

  • a lateral toroidal face,
  • two conical faces (defined by the equation v = angle1 and v = angle2) if the sphere is truncated in the v parametric direction (they may be cylindrical faces in some particular conditions), and in case of a portion of torus, two planar faces to close the shape.(in the planes u = 0 and u = angle) [...]

I'm not sure if I understand this description correctly but I think what you get is the expected result. For definitive answer you will have to wait for an explanation from more knowledgeable people.

Meanwhile I advice you to build the torus manually with revolve. Something like

result = cq.Workplane("YZ").moveTo(5).circle(1).revolve()

image

"Built in" solids seem to be more prone to bugs and unexpected behavior (see #698 for problems with box() for example). Manually extruded or revolved bodies seem to be more "robust" in my limited experience.