CadQuery / CadQuery/cadquery

Selectors for cylindrical faces

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

Description

I can select for cylindrical faces in general with `.faces("%CYLINDER")` but there is no way of filtering those cylinders by a certain direction (both `.faces("%CYLINDER and |Z")` and `.faces("%CYLINDER and #Z")` filter out all cylindric faces already, as do basically all of the included selectors...

(my use case is that I want to design a mount for a piece I have a .step file of and it has screw holes that are the only cylindric faces along the z-axis, which I'd like to detect with a selector)

I already have a prototype of what I'd want that filter to look like:
```py
class CylinderDirSelector(BaseDirSelector):
def __init__(self, vector: Vector, tolerance: float = 0.0001):
self.direction = vector
self.tolerance = tolerance

def filter(self, objectList: Sequence[Shape]) -> List[Shape]:
r = []
for o in objectList:
# no really good way to avoid a switch here, edges and faces are simply different!
if isinstance(o, Face) and o.geomType() == "CYLINDER":
ax = o._geomAdaptor().Axis().Direction()
if self.direction.cross(Vector(ax)).Length < self.tolerance:
r.append(o)
return r
```
(I'm convinced that there massively better ways to do this, it's more of a visualization of what I'm looking for.)

Since finding screw holes on existing pieces feels like a task that more people than just me might be interest in, I'd like to kick off some discussion on if and how it should provided to/with cadquery.

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.