|
37 | 37 | from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub
|
38 | 38 | from ansys.api.geometry.v0.components_pb2 import (
|
39 | 39 | CreateRequest,
|
| 40 | + ImportGroupsRequest, |
| 41 | + MakeIndependentRequest, |
40 | 42 | SetPlacementRequest,
|
41 | 43 | SetSharedTopologyRequest,
|
42 | 44 | )
|
|
70 | 72 | from ansys.geometry.core.math.matrix import Matrix44
|
71 | 73 | from ansys.geometry.core.math.point import Point3D
|
72 | 74 | from ansys.geometry.core.math.vector import UnitVector3D, Vector3D
|
| 75 | +from ansys.geometry.core.misc.auxiliary import get_design_from_component |
73 | 76 | from ansys.geometry.core.misc.checks import (
|
74 | 77 | ensure_design_is_active,
|
75 | 78 | graphics_required,
|
@@ -1876,3 +1879,43 @@ def build_parent_tree(comp: Component, parent_tree: str = "") -> str:
|
1876 | 1879 | lines.extend([f"|{'-' * (indent - 1)}(comp) {comp.name}" for comp in comps])
|
1877 | 1880 |
|
1878 | 1881 | return lines if return_list else print("\n".join(lines))
|
| 1882 | + |
| 1883 | + @protect_grpc |
| 1884 | + @min_backend_version(26, 1, 0) |
| 1885 | + def import_named_selections(self) -> None: |
| 1886 | + """Import named selections of a component. |
| 1887 | +
|
| 1888 | + When a design is inserted, it becomes a component. From 26R1 onwards, the named selections |
| 1889 | + of that component will be imported by default. If a file is opened that contains a |
| 1890 | + component that did not have its named selections imported, this method can be used to |
| 1891 | + import them. |
| 1892 | +
|
| 1893 | + Warnings |
| 1894 | + -------- |
| 1895 | + This method is only available starting on Ansys release 26R1. |
| 1896 | + """ |
| 1897 | + self._component_stub.ImportGroups(ImportGroupsRequest(id=self._grpc_id)) |
| 1898 | + |
| 1899 | + design = get_design_from_component(self) |
| 1900 | + design._update_design_inplace() |
| 1901 | + |
| 1902 | + @protect_grpc |
| 1903 | + @min_backend_version(26, 1, 0) |
| 1904 | + def make_independent(self, others: list["Component"] = None) -> None: |
| 1905 | + """Make a component independent if it is an instance. |
| 1906 | +
|
| 1907 | + If a component is an instance of another component, modifying one component modifies both. |
| 1908 | + When a component is made independent, it is no longer associated with other instances and |
| 1909 | + can be modified separately. |
| 1910 | +
|
| 1911 | + Parameters |
| 1912 | + ---------- |
| 1913 | + others : list[Component], default: None |
| 1914 | + Optionally include multiple components to make them all independent. |
| 1915 | +
|
| 1916 | + Warnings |
| 1917 | + -------- |
| 1918 | + This method is only available starting on Ansys release 26R1. |
| 1919 | + """ |
| 1920 | + ids = [self._grpc_id, *[o._grpc_id for o in others or []]] |
| 1921 | + self._component_stub.MakeIndependent(MakeIndependentRequest(ids=ids)) |
0 commit comments