|
34 | 34 | CreateCircularPatternRequest, |
35 | 35 | CreateFillPatternRequest, |
36 | 36 | CreateLinearPatternRequest, |
| 37 | + DraftFacesRequest, |
37 | 38 | ExtrudeEdgesRequest, |
38 | 39 | ExtrudeEdgesUpToRequest, |
39 | 40 | ExtrudeFacesRequest, |
|
42 | 43 | FullFilletRequest, |
43 | 44 | ModifyCircularPatternRequest, |
44 | 45 | ModifyLinearPatternRequest, |
| 46 | + MoveImprintEdgesRequest, |
45 | 47 | MoveRotateRequest, |
46 | 48 | MoveTranslateRequest, |
| 49 | + OffsetEdgesRequest, |
47 | 50 | OffsetFacesSetRadiusRequest, |
48 | 51 | PatternRequest, |
49 | 52 | RenameObjectRequest, |
|
53 | 56 | RevolveFacesUpToRequest, |
54 | 57 | RoundInfoRequest, |
55 | 58 | SplitBodyRequest, |
| 59 | + ThickenFacesRequest, |
56 | 60 | ) |
57 | 61 | from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub |
58 | 62 | from ansys.geometry.core.connection.client import GrpcClient |
|
79 | 83 | get_design_from_component, |
80 | 84 | get_design_from_edge, |
81 | 85 | get_design_from_face, |
| 86 | + get_faces_from_ids, |
82 | 87 | ) |
83 | 88 | from ansys.geometry.core.misc.checks import ( |
84 | 89 | check_is_float_int, |
@@ -128,6 +133,16 @@ class FillPatternType(Enum): |
128 | 133 | SKEWED = 2 |
129 | 134 |
|
130 | 135 |
|
| 136 | +@unique |
| 137 | +class DraftSide(Enum): |
| 138 | + """Provides values for draft sides.""" |
| 139 | + |
| 140 | + NO_SPLIT = 0 |
| 141 | + THIS = 1 |
| 142 | + OTHER = 2 |
| 143 | + BACK = 3 |
| 144 | + |
| 145 | + |
131 | 146 | class GeometryCommands: |
132 | 147 | """Provides geometry commands for PyAnsys Geometry. |
133 | 148 |
|
@@ -1666,3 +1681,178 @@ def create_orient_condition( |
1666 | 1681 | result.is_reversed, |
1667 | 1682 | result.is_valid, |
1668 | 1683 | ) |
| 1684 | + |
| 1685 | + @protect_grpc |
| 1686 | + @min_backend_version(26, 1, 0) |
| 1687 | + def move_imprint_edges( |
| 1688 | + self, edges: list["Edge"], direction: UnitVector3D, distance: Distance | Quantity | Real |
| 1689 | + ) -> bool: |
| 1690 | + """Move the imprint edges in the specified direction by the specified distance. |
| 1691 | +
|
| 1692 | + Parameters |
| 1693 | + ---------- |
| 1694 | + edges : list[Edge] |
| 1695 | + The edges to move. |
| 1696 | + direction : UnitVector3D |
| 1697 | + The direction to move the edges. |
| 1698 | + distance : Distance |
| 1699 | + The distance to move the edges. |
| 1700 | +
|
| 1701 | + Returns |
| 1702 | + ------- |
| 1703 | + bool |
| 1704 | + Returns True if the edges were moved successfully, False otherwise. |
| 1705 | + """ |
| 1706 | + # Convert the distance object |
| 1707 | + distance = distance if isinstance(distance, Distance) else Distance(distance) |
| 1708 | + move_magnitude = distance.value.m_as(DEFAULT_UNITS.SERVER_LENGTH) |
| 1709 | + |
| 1710 | + # Create the request object |
| 1711 | + request = MoveImprintEdgesRequest( |
| 1712 | + edges=[edge._grpc_id for edge in edges], |
| 1713 | + direction=unit_vector_to_grpc_direction(direction), |
| 1714 | + distance=move_magnitude, |
| 1715 | + ) |
| 1716 | + |
| 1717 | + # Call the gRPC service |
| 1718 | + response = self._commands_stub.MoveImprintEdges(request) |
| 1719 | + |
| 1720 | + # Return success flag |
| 1721 | + return response.result.success |
| 1722 | + |
| 1723 | + @protect_grpc |
| 1724 | + @min_backend_version(26, 1, 0) |
| 1725 | + def offset_edges(self, edges: list["Edge"], offset: Distance | Quantity | Real) -> bool: |
| 1726 | + """Offset the specified edges with the specified distance. |
| 1727 | +
|
| 1728 | + Parameters |
| 1729 | + ---------- |
| 1730 | + edges : list[Edge] |
| 1731 | + The edges to offset. |
| 1732 | + offset : Distance |
| 1733 | + The distance to offset the edges. |
| 1734 | +
|
| 1735 | + Returns |
| 1736 | + ------- |
| 1737 | + bool |
| 1738 | + Returns True if the edges were offset successfully, False otherwise. |
| 1739 | + """ |
| 1740 | + # Convert the distance object |
| 1741 | + offset = offset if isinstance(offset, Distance) else Distance(offset) |
| 1742 | + offset_magnitude = offset.value.m_as(DEFAULT_UNITS.SERVER_LENGTH) |
| 1743 | + |
| 1744 | + # Create the request object |
| 1745 | + request = OffsetEdgesRequest( |
| 1746 | + edges=[edge._grpc_id for edge in edges], |
| 1747 | + value=offset_magnitude, |
| 1748 | + ) |
| 1749 | + |
| 1750 | + # Call the gRPC service |
| 1751 | + response = self._commands_stub.OffsetEdges(request) |
| 1752 | + |
| 1753 | + # Return success flag |
| 1754 | + return response.success |
| 1755 | + |
| 1756 | + @protect_grpc |
| 1757 | + @min_backend_version(26, 1, 0) |
| 1758 | + def draft_faces( |
| 1759 | + self, |
| 1760 | + faces: list["Face"], |
| 1761 | + reference_faces: list["Face"], |
| 1762 | + draft_side: DraftSide, |
| 1763 | + angle: Angle | Quantity | Real, |
| 1764 | + extrude_type: ExtrudeType, |
| 1765 | + ) -> list["Face"]: |
| 1766 | + """Draft the specified faces in the specified direction by the specified angle. |
| 1767 | +
|
| 1768 | + Parameters |
| 1769 | + ---------- |
| 1770 | + faces : list[Face] |
| 1771 | + The faces to draft. |
| 1772 | + reference_faces : list[Face] |
| 1773 | + The reference faces to use for the draft. |
| 1774 | + draft_side : DraftSide |
| 1775 | + The side to draft. |
| 1776 | + angle : Angle | Quantity | Real |
| 1777 | + The angle to draft the faces. |
| 1778 | + extrude_type : ExtrudeType |
| 1779 | + The type of extrusion to use. |
| 1780 | +
|
| 1781 | + Returns |
| 1782 | + ------- |
| 1783 | + list[Face] |
| 1784 | + The faces created by the draft operation. |
| 1785 | + """ |
| 1786 | + # Convert the angle object |
| 1787 | + angle = angle if isinstance(angle, Angle) else Angle(angle) |
| 1788 | + angle_magnitude = angle.value.m_as(DEFAULT_UNITS.SERVER_ANGLE) |
| 1789 | + |
| 1790 | + # Create the request object |
| 1791 | + request = DraftFacesRequest( |
| 1792 | + faces=[face._grpc_id for face in faces], |
| 1793 | + reference_faces=[face._grpc_id for face in reference_faces], |
| 1794 | + draft_side=draft_side.value, |
| 1795 | + draft_angle=angle_magnitude, |
| 1796 | + extrude_type=extrude_type.value, |
| 1797 | + ) |
| 1798 | + |
| 1799 | + # Call the gRPC server |
| 1800 | + response = self._commands_stub.DraftFaces(request) |
| 1801 | + |
| 1802 | + # Return the drafted faces |
| 1803 | + design = get_design_from_face(faces[0]) |
| 1804 | + return get_faces_from_ids(design, [face.id for face in response.created_faces]) |
| 1805 | + |
| 1806 | + @protect_grpc |
| 1807 | + @min_backend_version(26, 1, 0) |
| 1808 | + def thicken_faces( |
| 1809 | + self, |
| 1810 | + faces: list["Face"], |
| 1811 | + direction: UnitVector3D, |
| 1812 | + thickness: Real, |
| 1813 | + extrude_type: ExtrudeType, |
| 1814 | + pull_symmetric: bool, |
| 1815 | + select_direction: bool, |
| 1816 | + ) -> bool: |
| 1817 | + """Thicken the specified faces by the specified thickness in the specified direction. |
| 1818 | +
|
| 1819 | + Parameters |
| 1820 | + ---------- |
| 1821 | + faces : list[Face] |
| 1822 | + The faces to thicken. |
| 1823 | + direction : UnitVector3D |
| 1824 | + The direction to thicken the faces. |
| 1825 | + thickness : Real |
| 1826 | + The thickness to apply to the faces. |
| 1827 | + extrude_type : ExtrudeType |
| 1828 | + The type of extrusion to use. |
| 1829 | + pull_symmetric : bool |
| 1830 | + Whether to pull the faces symmetrically. |
| 1831 | + select_direction : bool |
| 1832 | + Whether to select the direction. |
| 1833 | +
|
| 1834 | + Returns |
| 1835 | + ------- |
| 1836 | + bool |
| 1837 | + Returns True if the faces were thickened successfully, False otherwise. |
| 1838 | + """ |
| 1839 | + # Create the request object |
| 1840 | + request = ThickenFacesRequest( |
| 1841 | + faces=[face._grpc_id for face in faces], |
| 1842 | + direction=unit_vector_to_grpc_direction(direction), |
| 1843 | + value=thickness, |
| 1844 | + extrude_type=extrude_type.value, |
| 1845 | + pull_symmetric=pull_symmetric, |
| 1846 | + select_direction=select_direction, |
| 1847 | + ) |
| 1848 | + |
| 1849 | + # Call the gRPC service |
| 1850 | + response = self._commands_stub.ThickenFaces(request) |
| 1851 | + |
| 1852 | + # Update design |
| 1853 | + design = get_design_from_face(faces[0]) |
| 1854 | + if response.success: |
| 1855 | + design._update_design_inplace() |
| 1856 | + |
| 1857 | + # Return success flag |
| 1858 | + return response.success |
0 commit comments