cadquery icon indicating copy to clipboard operation
cadquery copied to clipboard

PerpendicularDirSelector doesn't work with curved surfaces

Open just-georgeb opened this issue 3 years ago • 0 comments

I had some issues with PerpendicularDirSelector and from a bit of digging found it is currently limited to faces of type PLANE only. I was trying to select gear teeth surfaces which are perpendicular Z but are splines and so are not selected.

It's limited in BaseDirSelector if isinstance(o, Face) and o.geomType() == "PLANE": with the comment:

a face is only parallel to a direction if it is a plane, and its normal is parallel to the dir

which isn't really relevant to checking perpendicularity.

I think this is left over from the original implementation that assumed perpendicular = not parallel (so all direction selectors worked from this base parallel check), but this was fixed in #882. It works as expected if I remove and o.geomType() == "PLANE": image

I assume all faces have a normal defined so can't see an issue with this, but I don't know if there are other reasons to keep this check? Happy to open a PR if this can be done!

Minimum example to test:

p = (cq.Workplane('XY')
    .circle(10)
    .extrude(20)
    .faces('#Z')
    )
print(p.vals()) # -> []
# Should include the cylindrical surface

(gears created with cq_gears plugin)

just-georgeb avatar Mar 01 '22 20:03 just-georgeb