Skip to content

Commit 5a7eef7

Browse files
committed
Move copy command from Masterbody to body
1 parent 3168b0a commit 5a7eef7

File tree

1 file changed

+23
-22
lines changed
  • src/ansys/geometry/core/designer

1 file changed

+23
-22
lines changed

src/ansys/geometry/core/designer/body.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,28 +1259,10 @@ def get_collision(self, body: "Body") -> CollisionType: # noqa: D102
12591259
response = self._grpc_client.services.bodies.get_collision(id=self.id, other_id=body.id)
12601260
return CollisionType(response.get("collision_type"))
12611261

1262-
def copy(self, copy_id : str, parent: "Component", name: str = None) -> "Body": # noqa: D102
1263-
from ansys.geometry.core.designer.component import Component
1264-
1265-
# Check input types
1266-
check_type(copy_id, str)
1267-
check_type(parent, Component)
1268-
copy_name = self.name if name is None else name
1269-
check_type(copy_name, str)
1270-
1271-
self._grpc_client.log.debug(f"Copying body {self.id}.")
1272-
response = self._grpc_client.services.bodies.copy(
1273-
id=copy_id, parent_id=parent.id, name=copy_name
1274-
)
1275-
1276-
# Assign the new body to its specified parent (and return the new body)
1277-
tb = MasterBody(
1278-
response.get("master_id"), copy_name, self._grpc_client, is_surface=self.is_surface
1262+
def copy(self, parent: "Component", name: str = None) -> "Body": # noqa: D102
1263+
raise NotImplementedError(
1264+
'Copy method is not implemented on the MasterBody. Call this method on a body instead.'
12791265
)
1280-
parent._master_component.part.bodies.append(tb)
1281-
parent._clear_cached_bodies()
1282-
body_id = f"{parent.id}/{tb.id}" if parent.parent_component else tb.id
1283-
return Body(body_id, response.get("name"), parent, tb)
12841266

12851267
def get_raw_tessellation( # noqa: D102
12861268
self,
@@ -1849,7 +1831,26 @@ def get_collision(self, body: "Body") -> CollisionType: # noqa: D102
18491831

18501832
@ensure_design_is_active
18511833
def copy(self, parent: "Component", name: str = None) -> "Body": # noqa: D102
1852-
return self._template.copy(self.id, parent, name)
1834+
from ansys.geometry.core.designer.component import Component
1835+
1836+
# Check input types
1837+
check_type(parent, Component)
1838+
copy_name = self.name if name is None else name
1839+
check_type(copy_name, str)
1840+
1841+
self._template._grpc_client.log.debug(f"Copying body {self.id}.")
1842+
response = self._template._grpc_client.services.bodies.copy(
1843+
id=self.id, parent_id=parent.id, name=copy_name
1844+
)
1845+
1846+
# Assign the new body to its specified parent (and return the new body)
1847+
tb = MasterBody(
1848+
response.get("master_id"), copy_name, self._template._grpc_client, is_surface=self.is_surface
1849+
)
1850+
parent._master_component.part.bodies.append(tb)
1851+
parent._clear_cached_bodies()
1852+
body_id = f"{parent.id}/{tb.id}" if parent.parent_component else tb.id
1853+
return Body(body_id, response.get("name"), parent, tb)
18531854

18541855
@ensure_design_is_active
18551856
def get_raw_tessellation( # noqa: D102

0 commit comments

Comments
 (0)