CadQuery / CadQuery/cadquery

Selecting an inner face with ">>Z[1]" raises an unhelpful `GeomAPI_ProjectPointOnSurf::LowerDistanceParameters` exception

Open
#1,484 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5.8k
Forks
541
Avg merge
3d 2h
Merged PRs (30d)
5

Description

When running the following code, cadquery raises an exception:

```
import cadquery as cq

test = (
cq.Workplane("XY")
.circle(10)
.extrude(20)
.faces(">Z")
.workplane()
.hole(15, 5)
.faces(">>Z[1]")
.workplane()
.hole(10, 5)
)
```

Exception:
```
Traceback (most recent call last):
File "/Users/jez/Code/test/./test.py", line 12, in
.workplane()
File "/opt/homebrew/Caskroom/mambaforge/base/envs/test/lib/python3.10/site-packages/cadquery/cq.py", line 622, in workplane
normal = obj.normalAt(center)
File "/opt/homebrew/Caskroom/mambaforge/base/envs/test/lib/python3.10/site-packages/cadquery/occ_impl/shapes.py", line 2386, in normalAt
u, v = projector.LowerDistanceParameters()
OCP.Standard.Standard_Failure: GeomAPI_ProjectPointOnSurf::LowerDistanceParameters
```

The mistake here is that the face being selected is the curved inside face of the cylinder, which of course cannot make a workplane. The fix I needed was to use ">Z[1]" instead of ">>Z[1]", to only filter faces normal to Z. However, it took far too long to reach this conclusion because the error message is not clear.

Expected output: a more user friendly error that clearly states what the problem is. For example: `FaceError: The selected face is curved, a workplane cannot be created from a curved face.`

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.