CadQuery / CadQuery/cadquery

allow face selectors to be relative to workplane ?

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

Description

```
# testcase
wp = cq.Workplane("XY")

degree = 89

x = wp.transformed(rotate=(degree,0,0)) \
.circle(3, forConstruction = True).toPending() \
.workplane(offset=10) \
.circle(3, forConstruction = True).toPending() \
.loft() \
.faces(">Z") \
.workplane() \
.circle(2, forConstruction = True).toPending() \
.workplane(offset=10) \
.circle(2, forConstruction = True).toPending() \
.loft() \

from typing import Callable, Tuple
def waterfall(wp: cq.Workplane, fs: list[Callable[[cq.Workplane], Tuple[cq.Workplane, cq.Workplane]]]) -> cq.Workplane:
w1, w2 = wp, wp;
for f in fs:
w1, w2 = f(w2)
return w1

def trapez_cone(height, d1, d2 = None):
""" nur nach oben in Z Richtung wegen > Z"""
if d2 == None:
d2 = d1
def f(wp: cq.Workplane):
wp = wp.circle(d1, forConstruction = True).toPending() \
.workplane(offset=height) \
.circle(d2, forConstruction = True).toPending() \
.loft()
return (wp, wp.faces(">Z").workplane())

return f

b = waterfall(cq.Workplane("XY").transformed(rotate=(0,degree,0)),[
trapez_cone(10, 2, 2),
trapez_cone(10, 4, 4),
])
```

If you change degree to > 90 the hole in the middle is closed. So it would be nice if >Z would be relative to workplane Z direction not global Z direction or if z (lower case or such) would have this different behavior to not break code. or >wz (w meaning workplane) or whatever. The waterfall implementation basically is the same but allowing pyright to type the abstraction which it can't if you extend workplane

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.