Skip to content

Commit

Permalink
Added an example of filter_by with a lambda expression
Browse files Browse the repository at this point in the history
  • Loading branch information
gumyr committed Sep 6, 2023
1 parent cda4293 commit 3d32c14
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Binary file added docs/assets/custom_selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions docs/selectors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,16 @@ sorts and filters. Here is an example of a custom filters:
and -overall_width / 2 < v.X < overall_width / 2,
din.vertices(),
)
The :meth:`~topology.ShapeList.filter_by` method can take lambda expressions as part of a
fluent chain of operations which enables integration of custom filters into a larger change of
selectors as shown in this example:

.. code-block:: python
obj = Box(1, 1, 1) - Cylinder(0.2, 1)
faces_with_holes = obj.faces().filter_by(lambda f: f.inner_wires())
.. image:: assets/custom_selector.png

Here the two faces with "inner_wires" (i.e. holes) have been selected independent of orientation.

0 comments on commit 3d32c14

Please sign in to comment.