Skip to content

Commit f58972a

Browse files
smereupyansys-ci-botpre-commit-ci[bot]RobPasMue
authored
fix: fix copy with occurrence (#2320)
Co-authored-by: PyAnsys CI Bot <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Roberto Pastor Muela <[email protected]>
1 parent 66e7ac2 commit f58972a

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

doc/changelog.d/2320.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix copy with occurrence

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

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,26 +1260,9 @@ def get_collision(self, body: "Body") -> CollisionType: # noqa: D102
12601260
return CollisionType(response.get("collision_type"))
12611261

12621262
def copy(self, 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(parent, Component)
1267-
copy_name = self.name if name is None else name
1268-
check_type(copy_name, str)
1269-
1270-
self._grpc_client.log.debug(f"Copying body {self.id}.")
1271-
response = self._grpc_client.services.bodies.copy(
1272-
id=self.id, parent_id=parent.id, name=copy_name
1273-
)
1274-
1275-
# Assign the new body to its specified parent (and return the new body)
1276-
tb = MasterBody(
1277-
response.get("master_id"), copy_name, self._grpc_client, is_surface=self.is_surface
1263+
raise NotImplementedError(
1264+
"Copy method is not implemented on the MasterBody. Call this method on a body instead."
12781265
)
1279-
parent._master_component.part.bodies.append(tb)
1280-
parent._clear_cached_bodies()
1281-
body_id = f"{parent.id}/{tb.id}" if parent.parent_component else tb.id
1282-
return Body(body_id, response.get("name"), parent, tb)
12831266

12841267
def get_raw_tessellation( # noqa: D102
12851268
self,
@@ -1848,7 +1831,29 @@ def get_collision(self, body: "Body") -> CollisionType: # noqa: D102
18481831

18491832
@ensure_design_is_active
18501833
def copy(self, parent: "Component", name: str = None) -> "Body": # noqa: D102
1851-
return self._template.copy(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"),
1849+
copy_name,
1850+
self._template._grpc_client,
1851+
is_surface=self.is_surface,
1852+
)
1853+
parent._master_component.part.bodies.append(tb)
1854+
parent._clear_cached_bodies()
1855+
body_id = f"{parent.id}/{tb.id}" if parent.parent_component else tb.id
1856+
return Body(body_id, response.get("name"), parent, tb)
18521857

18531858
@ensure_design_is_active
18541859
def get_raw_tessellation( # noqa: D102

0 commit comments

Comments
 (0)