Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for using a lambda inside ShapeList.filter_by #711

Open
CarpeNecopinum opened this issue Sep 24, 2024 · 2 comments
Open

Example for using a lambda inside ShapeList.filter_by #711

CarpeNecopinum opened this issue Sep 24, 2024 · 2 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@CarpeNecopinum
Copy link

CarpeNecopinum commented Sep 24, 2024

Question that came up in the Discord server was how to filter faces by being parallel to a given axis, as there is no built-in filter for it:

part.faces().filter_by(lambda f: abs(f.normal_at(None).dot(axis)) < 1e-6)

Jern noted that there are no examples showing this feature (lambda as filter), so we should probably add one / a few.

@jdegenstein
Copy link
Collaborator

Thank you! Would be good to add this to page https://build123d.readthedocs.io/en/latest/key_concepts.html#custom-sorting-and-filtering

@gumyr
Copy link
Owner

gumyr commented Sep 28, 2024

shape = Box(1, 1, 1)
f_parallel = shape.faces().filter_by(lambda f: abs(f.normal_at().dot(Axis.X.direction)) < 1e-6)
f_perpendicular = shape.faces().filter_by(Axis.X)

Might want to clarify that the dot method expects a Vector and not an Axis.

@gumyr gumyr added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 28, 2024
@gumyr gumyr added this to the Not Gating Release 1.0.0 milestone Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants