CadQuery / CadQuery/cadquery

Issue with cutting a cylinder from a torus (revolved circle)

Open
#1,856 4 comments 0 reactions 0 assignees View on GitHub
bug OCC kernel issue ShapeUpgrade_UnifySameDomain
Dominant language
Python
Stars
5.8k
Forks
541
Avg merge
3d 2h
Merged PRs (30d)
5

Description

## To Reproduce

```python

import cadquery as cq
import pyvista as pv

#Initialize the assembly
model = cq.Assembly()

#Define the major and minor radii for the torus
R = 50.0
r = 20.0

#Create a circle in the XY plane with the minor radius r
torus_profile = cq.Workplane("XY").circle(r)

#Revolve the circle around Y-axis to generate the torus
torus = torus_profile.revolve(angleDegrees=360, axisStart=[R, 0, 0], axisEnd=[R, 1, 0])

#Define the radius and height of the cylinder
#cylinder_radius = r/5 # It works for this radius!
cylinder_radius = r/4

cylinder_height = 4*R # Ensure the height is enough to pierce through the torus

#Create the cylinder in the YZ plane, centered at the origin
cylinder = cq.Workplane("YZ").circle(cylinder_radius).extrude(cylinder_height)

#Move the cylinder to the center of the torus
cylinder = cylinder.translate((-R, 0, 0))

#Cut the cylinder from the torus
#pierced_torus = torus.add(cylinder)
pierced_torus = torus.cut(cylinder)

model.add(pierced_torus)

#Export/Show the result
model.toCompound().exportStl('cut_torus.stl') # .stl / .step / .glb are supported
#Export the assembly to a STEP file
cq.exporters.export(model.toCompound(), 'cut_torus.step')

#View model
pv_mesh = pv.read('cut_torus.stl')
pl = pv.Plotter()
pl.add_mesh(pv_mesh)
pl.show()
```

![Image](https://github.com/user-attachments/assets/2837cba0-b630-491d-8ebe-17dbfdbe7182)

## Backtrace

```
```

## Environment

OS:

Was CadQuery installed using Conda?:

Output of `conda list` from your active Conda environment:
```
```

Using:

Working on Win10; cadquery (2.5.2) is installed using pip; plus VSCode

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.