CadQuery / CadQuery/cadquery

Cut operation doesn't work

Open
#529 8 comments 0 reactions 0 assignees View on GitHub
complex geometry OCC kernel issue
Dominant language
Python
Stars
5.8k
Forks
541
Avg merge
3d 2h
Merged PRs (30d)
5

Description

_Tested with the latest CQ version provided on conda_

I'm working on a nut and the last cut operation fails, this is, there is no thread. The thing is that when using `union` instead of `cut` the operation is successfully performed. I cannot tell if it's my fault or a bug.

# The code

```python
import cadquery as cq
from math import sin, cos, tan, pi

# Parameters
d = 10
p = 1.50
da = 10.40
dw = 14.60
e = 17.77
m = 8.10
s = 16
angle = 30 * pi / 180

# Constant
H = 0.866 * p

# Gemetry
def cutting_hexagon():
points = [
(s/2, 0),
(e, 0),
(e, e * sin(angle))
]

a = (
cq.Workplane('YZ')
.polyline(points).close()
.revolve()
)

b = a.mirror('XY', (0, 0, m/2))

return a.union(b)

def internal_iso_thread():
# Helix
helix = cq.Workplane('XY').parametricCurve(
lambda t : (
d/2 * cos(t * 2 * pi),
d/2 * sin(t * 2 * pi),
p * t
),
start = 0,
stop = m/p
)

# Face
A = H/8 / tan(pi/3)
B = A * tan(pi/6)
C = A / cos(pi/6)
face = (
cq.Workplane('XZ')
.center(d/2, 0)
.moveTo(0, A)
.threePointArc((C-B, 0), (0, -A))
.lineTo(-7/8 * H, -H/2)
.lineTo(-7/8 * H, H/2)
.lineTo(0, A)
.close()
)

return face.sweep(helix, isFrenet=True)

def core():
def circumscribed(nSides, inscribedDiameter):
angle = 1/(nSides * 2) * 2 * pi
return inscribedDiameter / cos(angle)

return (
cq.Workplane('XY')
.polygon(6, circumscribed(6, s))
.circle(d / 2 - 3/8 * H)
.extrude(m)
)

result = (
core()
.cut(cutting_hexagon())
.cut(internal_iso_thread())
)

result.val().exportStep('bug.step')
```

# The result

![result](https://user-images.githubusercontent.com/51750948/100934915-b9904500-34ef-11eb-9662-786efef2fd1d.png)

# The issue

![cq_nut](https://user-images.githubusercontent.com/51750948/100935448-65d22b80-34f0-11eb-8fcc-527d1f413c13.PNG)

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.