Rename to Topology Selection and Exploration, add section on new_edges, elaborate on GroupBy
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
BIN
docs/assets/topology_selection/selectors_new_edges.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
|
@ -113,8 +113,8 @@ Table Of Contents
|
||||||
introductory_examples.rst
|
introductory_examples.rst
|
||||||
tutorials.rst
|
tutorials.rst
|
||||||
objects.rst
|
objects.rst
|
||||||
selectors_operators.rst
|
|
||||||
operations.rst
|
operations.rst
|
||||||
|
topology_selection.rst
|
||||||
builders.rst
|
builders.rst
|
||||||
joints.rst
|
joints.rst
|
||||||
assemblies.rst
|
assemblies.rst
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
#######################
|
#####################################
|
||||||
Selectors and Operators
|
Topology Selection and Exploration
|
||||||
#######################
|
#####################################
|
||||||
|
|
||||||
Selectors and operators are powerful methods to select and organize CAD objects for
|
:ref:`topology` is the structure of build123d geometric features and traversing the
|
||||||
|
topology of a part is often required to specify objects for an operation or to locate a
|
||||||
|
CAD feature. :ref:`selectors` allow selection of topology objects into a |ShapeList|.
|
||||||
|
:ref:`operators` are powerful methods further explore and refine a |ShapeList| for
|
||||||
subsequent operations.
|
subsequent operations.
|
||||||
|
|
||||||
.. _selectors:
|
.. _selectors:
|
||||||
|
|
@ -13,7 +16,7 @@ Selectors
|
||||||
|
|
||||||
Selectors provide methods to extract all or a subset of a feature type in the referenced
|
Selectors provide methods to extract all or a subset of a feature type in the referenced
|
||||||
object. These methods select Edges, Faces, Solids, Vertices, or Wires in Builder objects
|
object. These methods select Edges, Faces, Solids, Vertices, or Wires in Builder objects
|
||||||
or from Shape objects themselves. All of these methods return a :class:`~topology.ShapeList`,
|
or from Shape objects themselves. All of these methods return a |ShapeList|,
|
||||||
which is a subclass of ``list`` and may be sorted, grouped, or filtered by
|
which is a subclass of ``list`` and may be sorted, grouped, or filtered by
|
||||||
:ref:`operators`.
|
:ref:`operators`.
|
||||||
|
|
||||||
|
|
@ -53,10 +56,10 @@ a feature as long as they can contain the feature being selected.
|
||||||
# Create sketch out of context
|
# Create sketch out of context
|
||||||
Rectangle(1, 1).edges()
|
Rectangle(1, 1).edges()
|
||||||
|
|
||||||
Select In Build Objects
|
Select In Build Context
|
||||||
========================
|
========================
|
||||||
|
|
||||||
Build objects track the last operation and their selector methods can take
|
Build contexts track the last operation and their selector methods can take
|
||||||
:class:`~build_enums.Select` as criteria to specify a subset of
|
:class:`~build_enums.Select` as criteria to specify a subset of
|
||||||
features to extract. By default, a selector will select ``ALL`` of a feature, while
|
features to extract. By default, a selector will select ``ALL`` of a feature, while
|
||||||
``LAST`` selects features created or altered by the most recent operation. |edges| can
|
``LAST`` selects features created or altered by the most recent operation. |edges| can
|
||||||
|
|
@ -97,7 +100,7 @@ Create a simple part to demonstrate selectors. Select using the default criteria
|
||||||
part.edges(Select.ALL)
|
part.edges(Select.ALL)
|
||||||
part.faces(Select.ALL)
|
part.faces(Select.ALL)
|
||||||
|
|
||||||
.. figure:: assets/selectors_operators/selectors_select_all.png
|
.. figure:: assets/topology_selection/selectors_select_all.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
The default ``Select.ALL`` features
|
The default ``Select.ALL`` features
|
||||||
|
|
@ -114,7 +117,7 @@ Select features changed in the last operation with criteria ``Select.LAST``.
|
||||||
part.edges(Select.LAST)
|
part.edges(Select.LAST)
|
||||||
part.faces(Select.LAST)
|
part.faces(Select.LAST)
|
||||||
|
|
||||||
.. figure:: assets/selectors_operators/selectors_select_last.png
|
.. figure:: assets/topology_selection/selectors_select_last.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
``Select.LAST`` features
|
``Select.LAST`` features
|
||||||
|
|
@ -130,7 +133,7 @@ available for a ``ShapeList`` of edges!
|
||||||
|
|
||||||
part.edges(Select.NEW)
|
part.edges(Select.NEW)
|
||||||
|
|
||||||
.. figure:: assets/selectors_operators/selectors_select_new.png
|
.. figure:: assets/topology_selection/selectors_select_new.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
``Select.NEW`` edges where box and cylinder intersect
|
``Select.NEW`` edges where box and cylinder intersect
|
||||||
|
|
@ -147,7 +150,7 @@ edges are reused?
|
||||||
|
|
||||||
part.edges(Select.NEW)
|
part.edges(Select.NEW)
|
||||||
|
|
||||||
.. figure:: assets/selectors_operators/selectors_select_new_none.png
|
.. figure:: assets/topology_selection/selectors_select_new_none.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
``Select.NEW`` edges when box and cylinder don't intersect
|
``Select.NEW`` edges when box and cylinder don't intersect
|
||||||
|
|
@ -158,7 +161,8 @@ only completely new edges created by the operation.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Chamfer and fillet modify the current object, but do not have new edges.
|
Chamfer and fillet modify the current object, but do not have new edges via
|
||||||
|
``Select.NEW``.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
|
@ -170,11 +174,44 @@ only completely new edges created by the operation.
|
||||||
|
|
||||||
part.edges(Select.NEW)
|
part.edges(Select.NEW)
|
||||||
|
|
||||||
.. figure:: assets/selectors_operators/selectors_select_new_fillet.png
|
.. figure:: assets/topology_selection/selectors_select_new_fillet.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
Left, ``Select.NEW`` returns no edges after fillet. Right, ``Select.LAST``
|
Left, ``Select.NEW`` returns no edges after fillet. Right, ``Select.LAST``
|
||||||
|
|
||||||
|
Select New Edges In Algebra Mode
|
||||||
|
================================
|
||||||
|
|
||||||
|
The utility method ``new_edges`` compares one or more shape objects to a
|
||||||
|
another "combined" shape object and returns the edges new to the combined shape.
|
||||||
|
``new_edges`` is available both Algebra mode or Builder mode, but is necessary in
|
||||||
|
Algebra Mode where ``Select.NEW`` is unavailable
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
box = Box(5, 5, 1)
|
||||||
|
circle = Cylinder(2, 5)
|
||||||
|
part = box + circle
|
||||||
|
edges = new_edges(box, circle, combined=part)
|
||||||
|
|
||||||
|
.. figure:: assets/topology_selection/selectors_new_edges.png
|
||||||
|
:align: center
|
||||||
|
|
||||||
|
``new_edges`` can also find edges created during a chamfer or fillet operation by
|
||||||
|
comparing the object before the operation to the "combined" object.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
box = Box(5, 5, 1)
|
||||||
|
circle = Cylinder(2, 5)
|
||||||
|
part_before = box + circle
|
||||||
|
edges = part_before.edges().filter_by(lambda a: a.length == 1)
|
||||||
|
part = fillet(edges, 1)
|
||||||
|
edges = new_edges(part_before, combined=part)
|
||||||
|
|
||||||
|
.. figure:: assets/topology_selection/operators_group_area.png
|
||||||
|
:align: center
|
||||||
|
|
||||||
.. _operators:
|
.. _operators:
|
||||||
|
|
||||||
*********
|
*********
|
||||||
|
|
@ -230,7 +267,7 @@ subclass of ``list``, so any list slice can be used.
|
||||||
|
|
||||||
part.vertices().sort_by(Axis.X)[-4:]
|
part.vertices().sort_by(Axis.X)[-4:]
|
||||||
|
|
||||||
.. figure:: assets/selectors_operators/operators_sort_x.png
|
.. figure:: assets/topology_selection/operators_sort_x.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -242,28 +279,28 @@ Examples
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
:hidden:
|
:hidden:
|
||||||
|
|
||||||
selectors_operators/sort_examples
|
topology_selection/sort_examples
|
||||||
|
|
||||||
.. grid:: 3
|
.. grid:: 3
|
||||||
:gutter: 3
|
:gutter: 3
|
||||||
|
|
||||||
.. grid-item-card:: SortBy
|
.. grid-item-card:: SortBy
|
||||||
:img-top: assets/selectors_operators/thumb_sort_sortby.png
|
:img-top: assets/topology_selection/thumb_sort_sortby.png
|
||||||
:link: sort_sortby
|
:link: sort_sortby
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
.. grid-item-card:: Along Wire
|
.. grid-item-card:: Along Wire
|
||||||
:img-top: assets/selectors_operators/thumb_sort_along_wire.png
|
:img-top: assets/topology_selection/thumb_sort_along_wire.png
|
||||||
:link: sort_along_wire
|
:link: sort_along_wire
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
.. grid-item-card:: Axis
|
.. grid-item-card:: Axis
|
||||||
:img-top: assets/selectors_operators/thumb_sort_axis.png
|
:img-top: assets/topology_selection/thumb_sort_axis.png
|
||||||
:link: sort_axis
|
:link: sort_axis
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
.. grid-item-card:: Distance From
|
.. grid-item-card:: Distance From
|
||||||
:img-top: assets/selectors_operators/thumb_sort_distance.png
|
:img-top: assets/topology_selection/thumb_sort_distance.png
|
||||||
:link: sort_distance_from
|
:link: sort_distance_from
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
|
|
@ -272,10 +309,11 @@ Group
|
||||||
|
|
||||||
A ShapeList can be grouped and sorted with the |group_by| method based on a grouping
|
A ShapeList can be grouped and sorted with the |group_by| method based on a grouping
|
||||||
criteria. Grouping can be a great way to organize features without knowing the values of
|
criteria. Grouping can be a great way to organize features without knowing the values of
|
||||||
specific feature properties. Rather than returning a ``Shapelist``, |group_by| returns
|
specific feature properties. Rather than returning a ``ShapeList``, |group_by| returns
|
||||||
a ``GroupBy`` which can be indexed to retrieve a ``Shapelist`` for further operations.
|
a ``GroupBy``, a list of ``ShapeList`` objects sorted by the grouping criteria.
|
||||||
``GroupBy`` groups can also be accessed using a key with the ``group`` method. If the
|
``GroupBy`` can be printed to view the members of each group, indexed like a list to
|
||||||
keys are unknown they can be discovered with ``key_to_group_index``.
|
retrieve a ``ShapeList``, and be accessed using a key with the ``group`` method. If the
|
||||||
|
group keys are unknown they can be discovered with ``key_to_group_index``.
|
||||||
|
|
||||||
If we want only the edges from the smallest faces by area we can get the faces, then
|
If we want only the edges from the smallest faces by area we can get the faces, then
|
||||||
group by ``SortBy.AREA``. The ``ShapeList`` of smallest faces is available from the first
|
group by ``SortBy.AREA``. The ``ShapeList`` of smallest faces is available from the first
|
||||||
|
|
@ -286,7 +324,7 @@ return a new list of all edges in the previous list.
|
||||||
|
|
||||||
part.faces().group_by(SortBy.AREA)[0].edges())
|
part.faces().group_by(SortBy.AREA)[0].edges())
|
||||||
|
|
||||||
.. figure:: assets/selectors_operators/operators_group_area.png
|
.. figure:: assets/topology_selection/operators_group_area.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -298,23 +336,23 @@ Examples
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
:hidden:
|
:hidden:
|
||||||
|
|
||||||
selectors_operators/group_examples
|
topology_selection/group_examples
|
||||||
|
|
||||||
.. grid:: 3
|
.. grid:: 3
|
||||||
:gutter: 3
|
:gutter: 3
|
||||||
|
|
||||||
.. grid-item-card:: Axis and Length
|
.. grid-item-card:: Axis and Length
|
||||||
:img-top: assets/selectors_operators/thumb_group_axis.png
|
:img-top: assets/topology_selection/thumb_group_axis.png
|
||||||
:link: group_axis
|
:link: group_axis
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
.. grid-item-card:: Hole Area
|
.. grid-item-card:: Hole Area
|
||||||
:img-top: assets/selectors_operators/thumb_group_hole_area.png
|
:img-top: assets/topology_selection/thumb_group_hole_area.png
|
||||||
:link: group_hole_area
|
:link: group_hole_area
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
.. grid-item-card:: Properties with Keys
|
.. grid-item-card:: Properties with Keys
|
||||||
:img-top: assets/selectors_operators/thumb_group_properties_with_keys.png
|
:img-top: assets/topology_selection/thumb_group_properties_with_keys.png
|
||||||
:link: group_properties_with_keys
|
:link: group_properties_with_keys
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
|
|
@ -334,7 +372,7 @@ each face can be checked against a vector direction and filtered accordingly.
|
||||||
|
|
||||||
part.faces().filter_by(lambda f: f.normal_at() == Vector(0, 0, 1))
|
part.faces().filter_by(lambda f: f.normal_at() == Vector(0, 0, 1))
|
||||||
|
|
||||||
.. figure:: assets/selectors_operators/operators_filter_z_normal.png
|
.. figure:: assets/topology_selection/operators_filter_z_normal.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -346,38 +384,38 @@ Examples
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
:hidden:
|
:hidden:
|
||||||
|
|
||||||
selectors_operators/filter_examples
|
topology_selection/filter_examples
|
||||||
|
|
||||||
.. grid:: 3
|
.. grid:: 3
|
||||||
:gutter: 3
|
:gutter: 3
|
||||||
|
|
||||||
.. grid-item-card:: GeomType
|
.. grid-item-card:: GeomType
|
||||||
:img-top: assets/selectors_operators/thumb_filter_geomtype.png
|
:img-top: assets/topology_selection/thumb_filter_geomtype.png
|
||||||
:link: filter_geomtype
|
:link: filter_geomtype
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
.. grid-item-card:: All Edges Circle
|
.. grid-item-card:: All Edges Circle
|
||||||
:img-top: assets/selectors_operators/thumb_filter_all_edges_circle.png
|
:img-top: assets/topology_selection/thumb_filter_all_edges_circle.png
|
||||||
:link: filter_all_edges_circle
|
:link: filter_all_edges_circle
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
.. grid-item-card:: Axis and Plane
|
.. grid-item-card:: Axis and Plane
|
||||||
:img-top: assets/selectors_operators/thumb_filter_axisplane.png
|
:img-top: assets/topology_selection/thumb_filter_axisplane.png
|
||||||
:link: filter_axis_plane
|
:link: filter_axis_plane
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
.. grid-item-card:: Inner Wire Count
|
.. grid-item-card:: Inner Wire Count
|
||||||
:img-top: assets/selectors_operators/thumb_filter_inner_wire_count.png
|
:img-top: assets/topology_selection/thumb_filter_inner_wire_count.png
|
||||||
:link: filter_inner_wire_count
|
:link: filter_inner_wire_count
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
.. grid-item-card:: Nested Filters
|
.. grid-item-card:: Nested Filters
|
||||||
:img-top: assets/selectors_operators/thumb_filter_nested.png
|
:img-top: assets/topology_selection/thumb_filter_nested.png
|
||||||
:link: filter_nested
|
:link: filter_nested
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
.. grid-item-card:: Shape Properties
|
.. grid-item-card:: Shape Properties
|
||||||
:img-top: assets/selectors_operators/thumb_filter_shape_properties.png
|
:img-top: assets/topology_selection/thumb_filter_shape_properties.png
|
||||||
:link: filter_shape_properties
|
:link: filter_shape_properties
|
||||||
:link-type: ref
|
:link-type: ref
|
||||||
|
|
||||||
|
|
@ -391,3 +429,4 @@ Examples
|
||||||
.. |group_by| replace:: :meth:`~topology.ShapeList.group_by`
|
.. |group_by| replace:: :meth:`~topology.ShapeList.group_by`
|
||||||
.. |filter_by| replace:: :meth:`~topology.ShapeList.filter_by`
|
.. |filter_by| replace:: :meth:`~topology.ShapeList.filter_by`
|
||||||
.. |filter_by_position| replace:: :meth:`~topology.ShapeList.filter_by_position`
|
.. |filter_by_position| replace:: :meth:`~topology.ShapeList.filter_by_position`
|
||||||
|
.. |ShapeList| replace:: :class:`~topology.ShapeList`
|
||||||
|
|
@ -4,7 +4,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
with BuildPart() as part:
|
with BuildPart() as part:
|
||||||
with BuildSketch() as s:
|
with BuildSketch() as s:
|
||||||
|
|
@ -4,7 +4,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
axis = Axis.Z
|
axis = Axis.Z
|
||||||
plane = Plane.XY
|
plane = Plane.XY
|
||||||
|
|
@ -4,7 +4,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
with BuildPart() as part:
|
with BuildPart() as part:
|
||||||
Box(5, 5, 1)
|
Box(5, 5, 1)
|
||||||
|
|
@ -5,7 +5,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
bracket = import_step(os.path.join(working_path, "nema-17-bracket.step"))
|
bracket = import_step(os.path.join(working_path, "nema-17-bracket.step"))
|
||||||
faces = bracket.faces()
|
faces = bracket.faces()
|
||||||
|
|
@ -5,7 +5,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
with BuildPart() as part:
|
with BuildPart() as part:
|
||||||
Cylinder(15, 2, align=(Align.CENTER, Align.CENTER, Align.MIN))
|
Cylinder(15, 2, align=(Align.CENTER, Align.CENTER, Align.MIN))
|
||||||
|
|
@ -4,7 +4,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
with BuildPart() as open_box_builder:
|
with BuildPart() as open_box_builder:
|
||||||
Box(20, 20, 5)
|
Box(20, 20, 5)
|
||||||
|
|
@ -5,7 +5,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
with BuildPart() as fins:
|
with BuildPart() as fins:
|
||||||
with GridLocations(4, 6, 4, 4):
|
with GridLocations(4, 6, 4, 4):
|
||||||
|
|
@ -5,7 +5,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
with BuildPart() as part:
|
with BuildPart() as part:
|
||||||
Cylinder(10, 30, rotation=(90, 0, 0))
|
Cylinder(10, 30, rotation=(90, 0, 0))
|
||||||
|
|
@ -5,7 +5,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
with BuildPart() as part:
|
with BuildPart() as part:
|
||||||
with BuildSketch(Plane.XZ) as sketch:
|
with BuildSketch(Plane.XZ) as sketch:
|
||||||
|
|
@ -5,7 +5,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
selectors = [solids, vertices, edges, faces]
|
selectors = [solids, vertices, edges, faces]
|
||||||
line = Line((-9, -9), (9, 9))
|
line = Line((-9, -9), (9, 9))
|
||||||
|
|
@ -91,3 +91,10 @@ save_screenshot(os.path.join(filedir, "operators_group_area.png"))
|
||||||
faces = part.faces().filter_by(lambda f: f.normal_at() == Vector(0, 0, 1))
|
faces = part.faces().filter_by(lambda f: f.normal_at() == Vector(0, 0, 1))
|
||||||
show(part, [f.translate(f.normal_at() * 0.01) for f in faces])
|
show(part, [f.translate(f.normal_at() * 0.01) for f in faces])
|
||||||
save_screenshot(os.path.join(filedir, "operators_filter_z_normal.png"))
|
save_screenshot(os.path.join(filedir, "operators_filter_z_normal.png"))
|
||||||
|
|
||||||
|
box = Box(5, 5, 1)
|
||||||
|
circle = Cylinder(2, 5)
|
||||||
|
part = box + circle
|
||||||
|
edges = new_edges(box, circle, combined=part)
|
||||||
|
show(part, edges)
|
||||||
|
save_screenshot(os.path.join(filedir, "selectors_new_edges.png"))
|
||||||
|
|
@ -4,7 +4,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
with BuildSketch() as along_wire:
|
with BuildSketch() as along_wire:
|
||||||
Rectangle(48, 16, align=Align.MIN)
|
Rectangle(48, 16, align=Align.MIN)
|
||||||
|
|
@ -5,7 +5,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
with BuildPart() as part:
|
with BuildPart() as part:
|
||||||
with BuildSketch(Plane.YZ) as profile:
|
with BuildSketch(Plane.YZ) as profile:
|
||||||
|
|
@ -5,7 +5,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
boxes = ShapeList(
|
boxes = ShapeList(
|
||||||
Box(1, 1, 1).scale(0.75 if (i, j) == (1, 2) else 0.25).translate((i, j, 0))
|
Box(1, 1, 1).scale(0.75 if (i, j) == (1, 2) else 0.25).translate((i, j, 0))
|
||||||
|
|
@ -4,7 +4,7 @@ from build123d import *
|
||||||
from ocp_vscode import *
|
from ocp_vscode import *
|
||||||
|
|
||||||
working_path = os.path.dirname(os.path.abspath(__file__))
|
working_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
filedir = os.path.join(working_path, "..", "..", "assets", "selectors_operators")
|
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
|
||||||
|
|
||||||
with BuildPart() as part:
|
with BuildPart() as part:
|
||||||
Box(5, 5, 1)
|
Box(5, 5, 1)
|
||||||
|
|
@ -25,7 +25,7 @@ operations, and are sometimes necessary e.g. before sorting or filtering by radi
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 15
|
:lines: 15
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/filter_geomtype_line.png
|
.. figure:: ../assets/topology_selection/filter_geomtype_line.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ operations, and are sometimes necessary e.g. before sorting or filtering by radi
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 17
|
:lines: 17
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/filter_geomtype_cylinder.png
|
.. figure:: ../assets/topology_selection/filter_geomtype_cylinder.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ circular edges selects the counterbore faces that meet the joint criteria.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 43-47
|
:lines: 43-47
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/filter_all_edges_circle.png
|
.. figure:: ../assets/topology_selection/filter_all_edges_circle.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ Plane will select faces parallel to the plane.
|
||||||
part.faces().filter_by(Axis.Z)
|
part.faces().filter_by(Axis.Z)
|
||||||
part.faces().filter_by(Plane.XY)
|
part.faces().filter_by(Plane.XY)
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/filter_axisplane.png
|
.. figure:: ../assets/topology_selection/filter_axisplane.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ to 0. The result is faces parallel to the axis or perpendicular to the plane.
|
||||||
part.faces().filter_by(lambda f: abs(f.normal_at().dot(Axis.Z.direction) < 1e-6)
|
part.faces().filter_by(lambda f: abs(f.normal_at().dot(Axis.Z.direction) < 1e-6)
|
||||||
part.faces().filter_by(lambda f: abs(f.normal_at().dot(Plane.XY.z_dir)) < 1e-6)
|
part.faces().filter_by(lambda f: abs(f.normal_at().dot(Plane.XY.z_dir)) < 1e-6)
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/filter_dot_axisplane.png
|
.. figure:: ../assets/topology_selection/filter_dot_axisplane.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ and then filtering for the specific inner wire by radius.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 18-21
|
:lines: 18-21
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/filter_inner_wire_count.png
|
.. figure:: ../assets/topology_selection/filter_inner_wire_count.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ select the top face, and then filter for the circular edges of the inner wires.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 25-32
|
:lines: 25-32
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/filter_inner_wire_count_linear.png
|
.. figure:: ../assets/topology_selection/filter_inner_wire_count_linear.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ any line edges.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 26-32
|
:lines: 26-32
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/filter_nested.png
|
.. figure:: ../assets/topology_selection/filter_nested.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ to highlight the resulting fillets.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 3-4, 8-22
|
:lines: 3-4, 8-22
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/filter_shape_properties.png
|
.. figure:: ../assets/topology_selection/filter_shape_properties.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ result knowing how many edges to expect.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 4, 9-17
|
:lines: 4, 9-17
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/group_axis_without.png
|
.. figure:: ../assets/topology_selection/group_axis_without.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ group again by length. In both cases, you can select the desired edges from the
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 21-22
|
:lines: 21-22
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/group_axis_with.png
|
.. figure:: ../assets/topology_selection/group_axis_with.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ with the largest hole.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 21-24
|
:lines: 21-24
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/group_hole_area.png
|
.. figure:: ../assets/topology_selection/group_hole_area.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ then the desired groups are selected with the ``group`` method using the lengths
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 30, 31
|
:lines: 30, 31
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/group_length_key.png
|
.. figure:: ../assets/topology_selection/group_length_key.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ and then further specify only the edges the bearings and pins are installed from
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 47-50
|
:lines: 47-50
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/group_radius_key.png
|
.. figure:: ../assets/topology_selection/group_radius_key.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ be used with``group_by``.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 19-22
|
:lines: 19-22
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/sort_sortby_length.png
|
.. figure:: ../assets/topology_selection/sort_sortby_length.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ be used with``group_by``.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 24-27
|
:lines: 24-27
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/sort_sortby_distance.png
|
.. figure:: ../assets/topology_selection/sort_sortby_distance.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ the order is random.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 14-15
|
:lines: 14-15
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/sort_not_along_wire.png
|
.. figure:: ../assets/topology_selection/sort_not_along_wire.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ radii now increase in order.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 26-28
|
:lines: 26-28
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/sort_along_wire.png
|
.. figure:: ../assets/topology_selection/sort_along_wire.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ edge can be found sorting along y-axis.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 22-24
|
:lines: 22-24
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/sort_axis.png
|
.. figure:: ../assets/topology_selection/sort_axis.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ Here we are sorting the boxes by distance from the origin, using an empty ``Vert
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 15-16
|
:lines: 15-16
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/sort_distance_from_origin.png
|
.. figure:: ../assets/topology_selection/sort_distance_from_origin.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ their distance from the largest box.
|
||||||
:language: python
|
:language: python
|
||||||
:lines: 19-20
|
:lines: 19-20
|
||||||
|
|
||||||
.. figure:: ../assets/selectors_operators/sort_distance_from_largest.png
|
.. figure:: ../assets/topology_selection/sort_distance_from_largest.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
|
|
|
|
||||||