Skip to content

Commit

Permalink
topology.py -> disable Shape.__deepcopy__
Browse files Browse the repository at this point in the history
  • Loading branch information
jdegenstein authored Apr 2, 2024
1 parent d9ef5b0 commit 796669d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/build123d/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -2300,21 +2300,21 @@ def scale(self, factor: float) -> Self:

return self._apply_transform(transformation)

def __deepcopy__(self, memo) -> Self:
"""Return deepcopy of self"""
# The wrapped object is a OCCT TopoDS_Shape which can't be pickled or copied
# with the standard python copy/deepcopy, so create a deepcopy 'memo' with this
# value already copied which causes deepcopy to skip it.
cls = self.__class__
result = cls.__new__(cls)
memo[id(self)] = result
memo[id(self.wrapped)] = downcast(BRepBuilderAPI_Copy(self.wrapped).Shape())
for key, value in self.__dict__.items():
setattr(result, key, copy.deepcopy(value, memo))
if key == "joints":
for joint in result.joints.values():
joint.parent = result
return result
# def __deepcopy__(self, memo) -> Self:
# """Return deepcopy of self"""
# # The wrapped object is a OCCT TopoDS_Shape which can't be pickled or copied
# # with the standard python copy/deepcopy, so create a deepcopy 'memo' with this
# # value already copied which causes deepcopy to skip it.
# cls = self.__class__
# result = cls.__new__(cls)
# memo[id(self)] = result
# memo[id(self.wrapped)] = downcast(BRepBuilderAPI_Copy(self.wrapped).Shape())
# for key, value in self.__dict__.items():
# setattr(result, key, copy.deepcopy(value, memo))
# if key == "joints":
# for joint in result.joints.values():
# joint.parent = result
# return result

def __copy__(self) -> Self:
"""Return shallow copy or reference of self
Expand Down

0 comments on commit 796669d

Please sign in to comment.