Finds the first solid object in the chain, searching from the current node backwards through parents until one is found. :param searchStack: should objects on the stack be searched first? :param searchParents: should parents be searched? :raises ValueError:
(
self, searchStack: bool = True, searchParents: bool = True
)
| 719 | return None |
| 720 | |
| 721 | def findSolid( |
| 722 | self, searchStack: bool = True, searchParents: bool = True |
| 723 | ) -> Union[Solid, Compound]: |
| 724 | """ |
| 725 | Finds the first solid object in the chain, searching from the current node |
| 726 | backwards through parents until one is found. |
| 727 | |
| 728 | :param searchStack: should objects on the stack be searched first? |
| 729 | :param searchParents: should parents be searched? |
| 730 | :raises ValueError: if no solid is found |
| 731 | |
| 732 | This function is very important for chains that are modifying a single parent object, |
| 733 | most often a solid. |
| 734 | |
| 735 | Most of the time, a chain defines or selects a solid, and then modifies it using workplanes |
| 736 | or other operations. |
| 737 | |
| 738 | Plugin Developers should make use of this method to find the solid that should be modified, |
| 739 | if the plugin implements a unary operation, or if the operation will automatically merge its |
| 740 | results with an object already on the stack. |
| 741 | """ |
| 742 | |
| 743 | found = self._findType((Solid,), searchStack, searchParents) |
| 744 | |
| 745 | if found is None: |
| 746 | message = "on the stack or " if searchStack else "" |
| 747 | raise ValueError( |
| 748 | "Cannot find a solid {}in the parent chain".format(message) |
| 749 | ) |
| 750 | |
| 751 | return found |
| 752 | |
| 753 | def _selectObjects( |
| 754 | self: T, |