|
30 | 30 | from ansys.api.dbu.v0.dbumodels_pb2 import EntityIdentifier
|
31 | 31 | from ansys.api.geometry.v0.commands_pb2 import (
|
32 | 32 | ChamferRequest,
|
| 33 | + CreateAlignTangentOrientGearConditionRequest, |
33 | 34 | CreateCircularPatternRequest,
|
34 | 35 | CreateFillPatternRequest,
|
35 | 36 | CreateLinearPatternRequest,
|
|
61 | 62 | point3d_to_grpc_point,
|
62 | 63 | unit_vector_to_grpc_direction,
|
63 | 64 | )
|
| 65 | +from ansys.geometry.core.designer.mating_conditions import ( |
| 66 | + AlignCondition, |
| 67 | + OrientCondition, |
| 68 | + TangentCondition, |
| 69 | +) |
64 | 70 | from ansys.geometry.core.designer.selection import NamedSelection
|
65 | 71 | from ansys.geometry.core.errors import protect_grpc
|
66 | 72 | from ansys.geometry.core.math.plane import Plane
|
|
69 | 75 | from ansys.geometry.core.misc.auxiliary import (
|
70 | 76 | get_bodies_from_ids,
|
71 | 77 | get_design_from_body,
|
| 78 | + get_design_from_component, |
72 | 79 | get_design_from_edge,
|
73 | 80 | get_design_from_face,
|
74 | 81 | )
|
@@ -1450,3 +1457,180 @@ def offset_faces_set_radius(
|
1450 | 1457 | )
|
1451 | 1458 |
|
1452 | 1459 | return result.success
|
| 1460 | + |
| 1461 | + @protect_grpc |
| 1462 | + @min_backend_version(26, 1, 0) |
| 1463 | + def create_align_condition( |
| 1464 | + self, |
| 1465 | + parent_component: "Component", |
| 1466 | + geometry_a: Union["Body", "Face", "Edge"], |
| 1467 | + geometry_b: Union["Body", "Face", "Edge"], |
| 1468 | + ) -> AlignCondition: |
| 1469 | + """Create an align condition between two geometry objects. |
| 1470 | +
|
| 1471 | + This will move the objects to be aligned with each other. |
| 1472 | +
|
| 1473 | + Parameters |
| 1474 | + ---------- |
| 1475 | + parent_component : Component |
| 1476 | + The common ancestor component of the two geometry objects. |
| 1477 | + geometry_a : Body | Face | Edge |
| 1478 | + The first geometry object to align to the second. |
| 1479 | + geometry_b : Body | Face | Edge |
| 1480 | + The geometry object to be aligned to. |
| 1481 | +
|
| 1482 | + Returns |
| 1483 | + ------- |
| 1484 | + AlignCondition |
| 1485 | + The persistent align condition that was created. |
| 1486 | +
|
| 1487 | + Warnings |
| 1488 | + -------- |
| 1489 | + This method is only available starting on Ansys release 26R1. |
| 1490 | + """ |
| 1491 | + from ansys.geometry.core.designer.body import Body |
| 1492 | + from ansys.geometry.core.designer.component import Component |
| 1493 | + from ansys.geometry.core.designer.edge import Edge |
| 1494 | + from ansys.geometry.core.designer.face import Face |
| 1495 | + |
| 1496 | + check_type(parent_component, Component) |
| 1497 | + check_type(geometry_a, (Body, Face, Edge)) |
| 1498 | + check_type(geometry_b, (Body, Face, Edge)) |
| 1499 | + |
| 1500 | + result = self._commands_stub.CreateAlignCondition( |
| 1501 | + CreateAlignTangentOrientGearConditionRequest( |
| 1502 | + parent=parent_component._grpc_id, |
| 1503 | + geometric_a=geometry_a._grpc_id, |
| 1504 | + geometric_b=geometry_b._grpc_id, |
| 1505 | + ) |
| 1506 | + ) |
| 1507 | + |
| 1508 | + get_design_from_component(parent_component)._update_design_inplace() |
| 1509 | + |
| 1510 | + return AlignCondition( |
| 1511 | + result.condition.moniker, |
| 1512 | + result.condition.is_deleted, |
| 1513 | + result.condition.is_enabled, |
| 1514 | + result.condition.is_satisfied, |
| 1515 | + result.offset, |
| 1516 | + result.is_reversed, |
| 1517 | + result.is_valid, |
| 1518 | + ) |
| 1519 | + |
| 1520 | + @protect_grpc |
| 1521 | + @min_backend_version(26, 1, 0) |
| 1522 | + def create_tangent_condition( |
| 1523 | + self, |
| 1524 | + parent_component: "Component", |
| 1525 | + geometry_a: Union["Body", "Face", "Edge"], |
| 1526 | + geometry_b: Union["Body", "Face", "Edge"], |
| 1527 | + ) -> TangentCondition: |
| 1528 | + """Create a tangent condition between two geometry objects. |
| 1529 | +
|
| 1530 | + This aligns the objects so that they are tangent. |
| 1531 | +
|
| 1532 | + Parameters |
| 1533 | + ---------- |
| 1534 | + parent_component : Component |
| 1535 | + The common ancestor component of the two geometry objects. |
| 1536 | + geometry_a : Body | Face | Edge |
| 1537 | + The first geometry object to tangent the second. |
| 1538 | + geometry_b : Body | Face | Edge |
| 1539 | + The geometry object to be tangent with. |
| 1540 | +
|
| 1541 | + Returns |
| 1542 | + ------- |
| 1543 | + TangentCondition |
| 1544 | + The persistent tangent condition that was created. |
| 1545 | +
|
| 1546 | + Warnings |
| 1547 | + -------- |
| 1548 | + This method is only available starting on Ansys release 26R1. |
| 1549 | + """ |
| 1550 | + from ansys.geometry.core.designer.body import Body |
| 1551 | + from ansys.geometry.core.designer.component import Component |
| 1552 | + from ansys.geometry.core.designer.edge import Edge |
| 1553 | + from ansys.geometry.core.designer.face import Face |
| 1554 | + |
| 1555 | + check_type(parent_component, Component) |
| 1556 | + check_type(geometry_a, (Body, Face, Edge)) |
| 1557 | + check_type(geometry_b, (Body, Face, Edge)) |
| 1558 | + |
| 1559 | + result = self._commands_stub.CreateTangentCondition( |
| 1560 | + CreateAlignTangentOrientGearConditionRequest( |
| 1561 | + parent=parent_component._grpc_id, |
| 1562 | + geometric_a=geometry_a._grpc_id, |
| 1563 | + geometric_b=geometry_b._grpc_id, |
| 1564 | + ) |
| 1565 | + ) |
| 1566 | + |
| 1567 | + get_design_from_component(parent_component)._update_design_inplace() |
| 1568 | + |
| 1569 | + return TangentCondition( |
| 1570 | + result.condition.moniker, |
| 1571 | + result.condition.is_deleted, |
| 1572 | + result.condition.is_enabled, |
| 1573 | + result.condition.is_satisfied, |
| 1574 | + result.offset, |
| 1575 | + result.is_reversed, |
| 1576 | + result.is_valid, |
| 1577 | + ) |
| 1578 | + |
| 1579 | + @protect_grpc |
| 1580 | + @min_backend_version(26, 1, 0) |
| 1581 | + def create_orient_condition( |
| 1582 | + self, |
| 1583 | + parent_component: "Component", |
| 1584 | + geometry_a: Union["Body", "Face", "Edge"], |
| 1585 | + geometry_b: Union["Body", "Face", "Edge"], |
| 1586 | + ) -> OrientCondition: |
| 1587 | + """Create an orient condition between two geometry objects. |
| 1588 | +
|
| 1589 | + This rotates the objects so that they are oriented in the same direction. |
| 1590 | +
|
| 1591 | + Parameters |
| 1592 | + ---------- |
| 1593 | + parent_component : Component |
| 1594 | + The common ancestor component of the two geometry objects. |
| 1595 | + geometry_a : Body | Face | Edge |
| 1596 | + The first geometry object to orient with the second. |
| 1597 | + geometry_b : Body | Face | Edge |
| 1598 | + The geometry object to be oriented with. |
| 1599 | +
|
| 1600 | + Returns |
| 1601 | + ------- |
| 1602 | + OrientCondition |
| 1603 | + The persistent orient condition that was created. |
| 1604 | +
|
| 1605 | + Warnings |
| 1606 | + -------- |
| 1607 | + This method is only available starting on Ansys release 26R1. |
| 1608 | + """ |
| 1609 | + from ansys.geometry.core.designer.body import Body |
| 1610 | + from ansys.geometry.core.designer.component import Component |
| 1611 | + from ansys.geometry.core.designer.edge import Edge |
| 1612 | + from ansys.geometry.core.designer.face import Face |
| 1613 | + |
| 1614 | + check_type(parent_component, Component) |
| 1615 | + check_type(geometry_a, (Body, Face, Edge)) |
| 1616 | + check_type(geometry_b, (Body, Face, Edge)) |
| 1617 | + |
| 1618 | + result = self._commands_stub.CreateOrientCondition( |
| 1619 | + CreateAlignTangentOrientGearConditionRequest( |
| 1620 | + parent=parent_component._grpc_id, |
| 1621 | + geometric_a=geometry_a._grpc_id, |
| 1622 | + geometric_b=geometry_b._grpc_id, |
| 1623 | + ) |
| 1624 | + ) |
| 1625 | + |
| 1626 | + get_design_from_component(parent_component)._update_design_inplace() |
| 1627 | + |
| 1628 | + return OrientCondition( |
| 1629 | + result.condition.moniker, |
| 1630 | + result.condition.is_deleted, |
| 1631 | + result.condition.is_enabled, |
| 1632 | + result.condition.is_satisfied, |
| 1633 | + result.offset, |
| 1634 | + result.is_reversed, |
| 1635 | + result.is_valid, |
| 1636 | + ) |
0 commit comments