Fix #3974. Bug where orphaned histories would be left in API remove operations.

This commit is contained in:
Dion Moult
2023-11-28 10:45:49 +11:00
parent 58414777be
commit 6e932ec2fb
50 changed files with 314 additions and 86 deletions
@@ -17,6 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
import ifcopenshell.util.element
class Usecase:
@@ -54,13 +55,14 @@ class Usecase:
)
if self.settings["work_calendar"].Controls:
for rel in self.settings["work_calendar"].Controls:
for object in rel.RelatedObjects:
for related_object in rel.RelatedObjects:
ifcopenshell.api.run(
"control.unassign_control",
self.file,
**{
"relating_control": self.settings["work_calendar"],
"related_object": object,
}
relating_control=self.settings["work_calendar"],
related_object=related_object,
)
history = self.settings["work_calendar"].OwnerHistory
self.file.remove(self.settings["work_calendar"])
if history:
ifcopenshell.util.element.remove_deep2(self.file, history)