mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix #3974. Bug where orphaned histories would be left in API remove operations.
This commit is contained in:
@@ -109,7 +109,10 @@ class Usecase:
|
||||
decomposes.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": decomposes})
|
||||
else:
|
||||
history = decomposes.OwnerHistory
|
||||
self.file.remove(decomposes)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
if is_decomposed_by:
|
||||
related_objects = set(is_decomposed_by.RelatedObjects)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -65,7 +66,11 @@ class Usecase:
|
||||
if not rel.is_a("IfcRelAggregates"):
|
||||
continue
|
||||
if len(rel.RelatedObjects) == 1:
|
||||
return self.file.remove(rel)
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
return
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(self.settings["product"])
|
||||
rel.RelatedObjects = related_objects
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, classification=None):
|
||||
@@ -48,7 +51,10 @@ class Usecase:
|
||||
self.file.remove(self.settings["classification"])
|
||||
for rel in self.file.by_type("IfcRelAssociatesClassification"):
|
||||
if not rel.RelatingClassification:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
for rel in self.file.by_type("IfcExternalReferenceRelationship"):
|
||||
if not rel.RelatingReference:
|
||||
self.file.remove(rel)
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, reference=None, product=None):
|
||||
@@ -59,7 +62,10 @@ class Usecase:
|
||||
if len(related_objects):
|
||||
rel.RelatedObjects = related_objects
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
else:
|
||||
for rel in self.file.by_type("IfcExternalReferenceRelationship"):
|
||||
if rel.RelatingReference == self.settings["reference"] and rel.RelatedResourceObjects:
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, constraint=None):
|
||||
@@ -46,4 +49,7 @@ class Usecase:
|
||||
self.file.remove(self.settings["constraint"])
|
||||
for rel in self.file.by_type("IfcRelAssociatesConstraint"):
|
||||
if not rel.RelatingConstraint:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -50,7 +50,10 @@ class Usecase:
|
||||
self.file.remove(self.settings["metric"])
|
||||
for rel in self.file.by_type("IfcRelAssociatesConstraint"):
|
||||
if not rel.RelatingConstraint:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
for resource_rel in self.file.by_type("IfcResourceConstraintRelationship"):
|
||||
if not resource_rel.RelatingConstraint:
|
||||
self.file.remove(resource_rel)
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, product=None, constraint=None):
|
||||
@@ -40,4 +43,7 @@ class Usecase:
|
||||
def execute(self):
|
||||
for rel in self.settings["product"].HasAssociations:
|
||||
if rel.is_a("IfcRelAssociatesConstraint") and rel.RelatingConstraint == self.settings["constraint"]:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -61,7 +62,11 @@ class Usecase:
|
||||
if not rel.is_a("IfcRelAssignsToControl") or rel.RelatingControl != self.settings["relating_control"]:
|
||||
continue
|
||||
if len(rel.RelatedObjects) == 1:
|
||||
return self.file.remove(rel)
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
return
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(self.settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -51,7 +53,16 @@ class Usecase:
|
||||
for related_object in inverse.RelatedObjects:
|
||||
ifcopenshell.api.run("cost.remove_cost_item", self.file, cost_item=related_object)
|
||||
elif inverse.RelatedObjects == tuple(self.settings["cost_item"]):
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
elif inverse.is_a("IfcRelAssignsToControl"):
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
history = self.settings["cost_item"].OwnerHistory
|
||||
self.file.remove(self.settings["cost_item"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -53,4 +55,7 @@ class Usecase:
|
||||
for related_object in inverse.RelatedObjects
|
||||
if related_object.is_a("IfcCostItem")
|
||||
]
|
||||
history = self.settings["cost_schedule"].OwnerHistory
|
||||
self.file.remove(self.settings["cost_schedule"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -55,6 +55,7 @@ class Usecase:
|
||||
|
||||
for rel in self.settings["information"].IsPointedTo or []:
|
||||
if rel.RelatedDocuments == (self.settings["information"],):
|
||||
# This relationship is non-rooted
|
||||
self.file.remove(rel)
|
||||
|
||||
for rel in self.settings["information"].DocumentInfoForObjects or []:
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, reference=None):
|
||||
@@ -41,5 +44,8 @@ class Usecase:
|
||||
|
||||
def execute(self):
|
||||
for rel in self.settings["reference"].DocumentRefForObjects or []:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
self.file.remove(self.settings["reference"])
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -59,6 +60,9 @@ class Usecase:
|
||||
for rel in self.settings["product"].HasAssociations:
|
||||
if rel.is_a("IfcRelAssociatesDocument") and rel.RelatingDocument == self.settings["document"]:
|
||||
if len(rel.RelatedObjects) == 1:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
else:
|
||||
rel.RelatedObjects = [o for o in rel.RelatedObjects if o != self.settings["product"]]
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -44,7 +45,10 @@ class Usecase:
|
||||
|
||||
if incompatible_connections:
|
||||
for connection in set(incompatible_connections):
|
||||
history = connection.OwnerHistory
|
||||
self.file.remove(connection)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
for rel in self.settings["relating_element"].ConnectedTo:
|
||||
if rel.is_a() == "IfcRelConnectsElements" and rel.RelatedElement == self.settings["related_element"]:
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -77,7 +78,10 @@ class Usecase:
|
||||
|
||||
if incompatible_connections:
|
||||
for connection in set(incompatible_connections):
|
||||
history = connection.OwnerHistory
|
||||
self.file.remove(connection)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
return self.file.createIfcRelConnectsPathElements(
|
||||
ifcopenshell.guid.new(),
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
@@ -48,4 +51,7 @@ class Usecase:
|
||||
|
||||
if incompatible_connections:
|
||||
for connection in set(incompatible_connections):
|
||||
history = connection.OwnerHistory
|
||||
self.file.remove(connection)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -51,4 +52,7 @@ class Usecase:
|
||||
]
|
||||
|
||||
for connection in set(connections):
|
||||
history = connection.OwnerHistory
|
||||
self.file.remove(connection)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -60,4 +61,7 @@ class Usecase:
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, library=None):
|
||||
@@ -45,4 +48,7 @@ class Usecase:
|
||||
self.file.remove(self.settings["library"])
|
||||
for rel in self.file.by_type("IfcRelAssociatesLibrary"):
|
||||
if not rel.RelatingLibrary:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, reference=None):
|
||||
@@ -43,5 +46,8 @@ class Usecase:
|
||||
|
||||
def execute(self):
|
||||
for rel in self.settings["reference"].LibraryRefForObjects:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
self.file.remove(self.settings["reference"])
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, reference=None, product=None):
|
||||
@@ -62,7 +65,10 @@ class Usecase:
|
||||
for rel in rels:
|
||||
if self.settings["product"] in rel.RelatedObjects:
|
||||
if len(rel.RelatedObjects) == 1:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
continue
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(self.settings["product"])
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -115,7 +116,10 @@ class Usecase:
|
||||
nests.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": nests})
|
||||
else:
|
||||
history = nests.OwnerHistory
|
||||
self.file.remove(nests)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
if is_nested_by:
|
||||
related_objects = list(is_nested_by.RelatedObjects)
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, item=None, new_parent=None):
|
||||
@@ -35,5 +37,13 @@ class Usecase:
|
||||
nests.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": nests})
|
||||
else:
|
||||
history = nests.OwnerHistory
|
||||
self.file.remove(nests)
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_object=self.settings["item"], relating_object=self.settings["new_parent"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object",
|
||||
self.file,
|
||||
related_object=self.settings["item"],
|
||||
relating_object=self.settings["new_parent"],
|
||||
)
|
||||
|
||||
@@ -18,17 +18,18 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, related_object=None):
|
||||
"""Unassigns a related_object from its nest.
|
||||
|
||||
|
||||
An object (the whole within a decomposition) is Nested by zero or one more smaller objects.
|
||||
This function will remove this nesting relationship.
|
||||
|
||||
|
||||
If the object is not part of a nesting relationship, nothing will happen.
|
||||
|
||||
|
||||
:param related_object: The child of the nesting relationship, typically
|
||||
an IfcElement.
|
||||
:type related_object: ifcopenshell.entity_instance.entity_instance
|
||||
@@ -56,11 +57,13 @@ class Usecase:
|
||||
if not rel.is_a("IfcRelNests"):
|
||||
continue
|
||||
if len(rel.RelatedObjects) == 1:
|
||||
return self.file.remove(rel)
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
return
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(self.settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run(
|
||||
"owner.update_owner_history", self.file, **{"element": rel}
|
||||
)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||
return rel
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -65,7 +66,11 @@ class Usecase:
|
||||
if not rel.is_a("IfcRelAssignsToActor") or rel.RelatingActor != self.settings["relating_actor"]:
|
||||
continue
|
||||
if len(rel.RelatedObjects) == 1:
|
||||
return self.file.remove(rel)
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
return
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(self.settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -47,10 +49,16 @@ class Usecase:
|
||||
self.file,
|
||||
resource=related_object,
|
||||
)
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
elif inverse.is_a("IfcRelAssignsToControl"):
|
||||
if len(inverse.RelatedObjects) == 1:
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
else:
|
||||
related_objects = list(inverse.RelatedObjects)
|
||||
related_objects.remove(self.settings["resource"])
|
||||
@@ -65,7 +73,10 @@ class Usecase:
|
||||
resource=self.settings["resource"],
|
||||
)
|
||||
elif inverse.RelatedObjects == tuple(self.settings["resource"]):
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
if self.settings["resource"].Usage:
|
||||
self.file.remove(self.settings["resource"].Usage)
|
||||
if self.settings["resource"].BaseQuantity:
|
||||
@@ -74,4 +85,7 @@ class Usecase:
|
||||
self.file,
|
||||
resource=self.settings["resource"],
|
||||
)
|
||||
history = self.settings["resource"].OwnerHistory
|
||||
self.file.remove(self.settings["resource"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -69,7 +71,11 @@ class Usecase:
|
||||
):
|
||||
continue
|
||||
if len(rel.RelatedObjects) == 1:
|
||||
return self.file.remove(rel)
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
return
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(self.settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
|
||||
@@ -20,9 +20,7 @@ import ifcopenshell.util.date
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(
|
||||
self, file, rel_sequence=None, lag_value=None, duration_type="WORKTIME"
|
||||
):
|
||||
def __init__(self, file, rel_sequence=None, lag_value=None, duration_type="WORKTIME"):
|
||||
"""Assign a lag time to a sequence relationship between tasks
|
||||
|
||||
A task sequence (e.g. finish to start) may optionally have a lag time
|
||||
@@ -94,22 +92,15 @@ class Usecase:
|
||||
|
||||
def execute(self):
|
||||
lag_value = self.file.createIfcDuration(
|
||||
ifcopenshell.util.date.datetime2ifc(
|
||||
self.settings["lag_value"], "IfcDuration"
|
||||
)
|
||||
ifcopenshell.util.date.datetime2ifc(self.settings["lag_value"], "IfcDuration")
|
||||
)
|
||||
lag_time = self.file.create_entity(
|
||||
"IfcLagTime",
|
||||
**{
|
||||
"DurationType": self.settings["duration_type"],
|
||||
"LagValue": lag_value,
|
||||
}
|
||||
"IfcLagTime", DurationType=self.settings["duration_type"], LagValue=lag_value
|
||||
)
|
||||
if self.settings["rel_sequence"].is_a("IfcRelSequence"):
|
||||
if (
|
||||
self.settings["rel_sequence"].TimeLag
|
||||
and len(self.file.get_inverse(self.settings["rel_sequence"].TimeLag))
|
||||
== 1
|
||||
and len(self.file.get_inverse(self.settings["rel_sequence"].TimeLag)) == 1
|
||||
):
|
||||
self.file.remove(self.settings["rel_sequence"].TimeLag)
|
||||
self.settings["rel_sequence"].TimeLag = lag_time
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -67,15 +69,19 @@ class Usecase:
|
||||
self.file.remove(self.settings["task"].TaskTime)
|
||||
for inverse in self.file.get_inverse(self.settings["task"]):
|
||||
if inverse.is_a("IfcRelSequence"):
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
elif inverse.is_a("IfcRelNests"):
|
||||
if inverse.RelatingObject == self.settings["task"]:
|
||||
for related_object in inverse.RelatedObjects:
|
||||
ifcopenshell.api.run(
|
||||
"sequence.remove_task", self.file, task=related_object
|
||||
)
|
||||
ifcopenshell.api.run("sequence.remove_task", self.file, task=related_object)
|
||||
elif not inverse.RelatedObjects:
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
elif self.settings["task"] in inverse.RelatedObjects:
|
||||
related_objects = list(inverse.RelatedObjects)
|
||||
related_objects.remove(self.settings["task"])
|
||||
@@ -84,17 +90,16 @@ class Usecase:
|
||||
else:
|
||||
inverse.RelatedObjects = related_objects
|
||||
elif inverse.is_a("IfcRelAssignsToControl"):
|
||||
if (
|
||||
inverse.RelatingControl == self.settings["task"]
|
||||
or len(inverse.RelatedObjects) == 1
|
||||
):
|
||||
if inverse.RelatingControl == self.settings["task"] or len(inverse.RelatedObjects) == 1:
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
else:
|
||||
related_objects = list(inverse.RelatedObjects)
|
||||
related_objects.remove(self.settings["task"])
|
||||
inverse.RelatedObjects = related_objects
|
||||
elif inverse.is_a("IfcRelDefinesByProperties"):
|
||||
print(inverse.RelatingPropertyDefinition.Name)
|
||||
ifcopenshell.api.run(
|
||||
"pset.remove_pset",
|
||||
self.file,
|
||||
@@ -102,32 +107,38 @@ class Usecase:
|
||||
pset=inverse.RelatingPropertyDefinition,
|
||||
)
|
||||
elif inverse.is_a("IfcRelAssignsToProcess"):
|
||||
if (
|
||||
inverse.RelatingProcess == self.settings["task"]
|
||||
or len(inverse.RelatedObjects) == 1
|
||||
):
|
||||
if inverse.RelatingProcess == self.settings["task"] or len(inverse.RelatedObjects) == 1:
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
elif inverse.is_a("IfcRelAssignsToProduct"):
|
||||
if (
|
||||
inverse.RelatingProduct == self.settings["task"]
|
||||
or len(inverse.RelatedObjects) == 1
|
||||
):
|
||||
if inverse.RelatingProduct == self.settings["task"] or len(inverse.RelatedObjects) == 1:
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
else:
|
||||
related_objects = list(inverse.RelatedObjects)
|
||||
related_objects.remove(self.settings["task"])
|
||||
inverse.RelatedObjects = related_objects
|
||||
elif inverse.is_a("IfcRelAssignsToObject"):
|
||||
if (
|
||||
inverse.RelatingObject == self.settings["task"]
|
||||
or len(inverse.RelatedObjects) == 1
|
||||
):
|
||||
if inverse.RelatingObject == self.settings["task"] or len(inverse.RelatedObjects) == 1:
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
else:
|
||||
related_objects = list(inverse.RelatedObjects)
|
||||
related_objects.remove(self.settings["task"])
|
||||
inverse.RelatedObjects = related_objects
|
||||
elif inverse.is_a("IfcRelAssignsToProcess"):
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
history = self.settings["task"].OwnerHistory
|
||||
self.file.remove(self.settings["task"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -52,4 +53,7 @@ class Usecase:
|
||||
definition=self.settings["work_plan"],
|
||||
relating_context=self.file.by_type("IfcContext")[0],
|
||||
)
|
||||
history = self.settings["work_plan"].OwnerHistory
|
||||
self.file.remove(self.settings["work_plan"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -65,22 +67,23 @@ class Usecase:
|
||||
)
|
||||
for inverse in self.file.get_inverse(self.settings["work_schedule"]):
|
||||
if inverse.is_a("IfcRelDefinesByObject"):
|
||||
if (
|
||||
inverse.RelatingObject == self.settings["work_schedule"]
|
||||
or len(inverse.RelatedObjects) == 1
|
||||
):
|
||||
if inverse.RelatingObject == self.settings["work_schedule"] or len(inverse.RelatedObjects) == 1:
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
else:
|
||||
related_objects = list(inverse.RelatedObjects)
|
||||
related_objects.remove(self.settings["work_schedule"])
|
||||
inverse.RelatedObjects = related_objects
|
||||
elif inverse.is_a("IfcRelAssignsToControl"):
|
||||
[
|
||||
ifcopenshell.api.run(
|
||||
"sequence.remove_task", self.file, task=related_object
|
||||
)
|
||||
ifcopenshell.api.run("sequence.remove_task", self.file, task=related_object)
|
||||
for related_object in inverse.RelatedObjects
|
||||
if related_object.is_a("IfcTask")
|
||||
]
|
||||
|
||||
history = self.settings["work_schedule"].OwnerHistory
|
||||
self.file.remove(self.settings["work_schedule"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -63,17 +64,16 @@ class Usecase:
|
||||
|
||||
def execute(self):
|
||||
for rel in self.settings["related_object"].HasAssignments or []:
|
||||
if (
|
||||
not rel.is_a("IfcRelAssignsToProcess")
|
||||
or rel.RelatingProcess != self.settings["relating_process"]
|
||||
):
|
||||
if not rel.is_a("IfcRelAssignsToProcess") or rel.RelatingProcess != self.settings["relating_process"]:
|
||||
continue
|
||||
if len(rel.RelatedObjects) == 1:
|
||||
return self.file.remove(rel)
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
return
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(self.settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run(
|
||||
"owner.update_owner_history", self.file, **{"element": rel}
|
||||
)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, element=rel)
|
||||
return rel
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -63,17 +64,16 @@ class Usecase:
|
||||
|
||||
def execute(self):
|
||||
for rel in self.settings["related_object"].HasAssignments or []:
|
||||
if (
|
||||
not rel.is_a("IfcRelAssignsToProduct")
|
||||
or rel.RelatingProduct != self.settings["relating_product"]
|
||||
):
|
||||
if not rel.is_a("IfcRelAssignsToProduct") or rel.RelatingProduct != self.settings["relating_product"]:
|
||||
continue
|
||||
if len(rel.RelatedObjects) == 1:
|
||||
return self.file.remove(rel)
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
return
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(self.settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run(
|
||||
"owner.update_owner_history", self.file, **{"element": rel}
|
||||
)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, element=rel)
|
||||
return rel
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, recurrence_pattern=None):
|
||||
@@ -53,4 +51,6 @@ class Usecase:
|
||||
self.settings = {"recurrence_pattern": recurrence_pattern}
|
||||
|
||||
def execute(self):
|
||||
for time_period in self.settings["recurrence_pattern"].TimePeriods or []:
|
||||
self.file.remove(time_period)
|
||||
self.file.remove(self.settings["recurrence_pattern"])
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -65,9 +66,8 @@ class Usecase:
|
||||
def execute(self):
|
||||
for rel in self.settings["related_process"].IsSuccessorFrom or []:
|
||||
if rel.RelatingProcess == self.settings["relating_process"]:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
ifcopenshell.api.run(
|
||||
"sequence.cascade_schedule",
|
||||
self.file,
|
||||
task=self.settings["related_process"],
|
||||
)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=self.settings["related_process"])
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.placement
|
||||
|
||||
|
||||
@@ -120,7 +121,10 @@ class Usecase:
|
||||
contained_in_structure[0].RelatedElements = related_elements
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": contained_in_structure[0]})
|
||||
else:
|
||||
history = contained_in_structure[0].OwnerHistory
|
||||
self.file.remove(contained_in_structure[0])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
if contains_elements:
|
||||
related_elements = list(contains_elements[0].RelatedElements)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -77,4 +78,7 @@ class Usecase:
|
||||
rel.RelatedElements = related_elements
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -70,4 +71,7 @@ class Usecase:
|
||||
contained_in_structure[0].RelatedElements = related_elements
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": contained_in_structure[0]})
|
||||
else:
|
||||
history = contained_in_structure[0].OwnerHistory
|
||||
self.file.remove(contained_in_structure[0])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -67,4 +68,7 @@ class Usecase:
|
||||
rel.RelatedElements = related_elements
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, element=rel)
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
+9
@@ -16,6 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, structural_analysis_model=None):
|
||||
@@ -34,5 +37,11 @@ class Usecase:
|
||||
|
||||
def execute(self):
|
||||
for rel in self.settings["structural_analysis_model"].IsGroupedBy or []:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
history = self.settings["structural_analysis_model"].OwnerHistory
|
||||
self.file.remove(self.settings["structural_analysis_model"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
+6
-1
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -38,6 +40,9 @@ class Usecase:
|
||||
ifcopenshell.api.run(
|
||||
"structural.remove_structural_boundary_condition",
|
||||
self.file,
|
||||
**{"connection": self.settings["relation"].RelatedStructuralConnection}
|
||||
connection=self.settings["relation"].RelatedStructuralConnection
|
||||
)
|
||||
history = self.settings["relation"].OwnerHistory
|
||||
self.file.remove(self.settings["relation"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -34,5 +36,10 @@ class Usecase:
|
||||
def execute(self):
|
||||
# TODO: do a deep purge
|
||||
for rel in self.settings["load_case"].IsGroupedBy or []:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
history = self.settings["load_case"].OwnerHistory
|
||||
self.file.remove(self.settings["load_case"])
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -35,5 +37,11 @@ class Usecase:
|
||||
# TODO: do a deep purge
|
||||
for inverse in self.file.get_inverse(self.settings["load_group"]):
|
||||
if inverse.is_a("IfcRelAssignsToGroup") and len(inverse.RelatedObjects) == 1:
|
||||
history = inverse.OwnerHistory
|
||||
self.file.remove(inverse)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
history = self.settings["load_group"].OwnerHistory
|
||||
self.file.remove(self.settings["load_group"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
+4
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -48,4 +49,7 @@ class Usecase:
|
||||
rel.RelatedObjects = list(related_objects)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||
else:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -108,13 +109,14 @@ class Usecase:
|
||||
if fills_voids:
|
||||
if fills_voids[0].RelatingOpeningElement == self.settings["opening"]:
|
||||
return
|
||||
history = fills_voids[0].OwnerHistory
|
||||
self.file.remove(fills_voids[0])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
self.file.create_entity(
|
||||
"IfcRelFillsElement",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"RelatingOpeningElement": self.settings["opening"],
|
||||
"RelatedBuildingElement": self.settings["element"],
|
||||
}
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
RelatingOpeningElement=self.settings["opening"],
|
||||
RelatedBuildingElement=self.settings["element"],
|
||||
)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.placement
|
||||
|
||||
|
||||
@@ -108,7 +109,10 @@ class Usecase:
|
||||
if voids_elements:
|
||||
if voids_elements[0].RelatingBuildingElement == self.settings["element"]:
|
||||
return
|
||||
history = voids_elements[0].OwnerHistory
|
||||
self.file.remove(voids_elements[0])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
self.file.create_entity(
|
||||
"IfcRelVoidsElement",
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, element=None):
|
||||
@@ -56,5 +59,8 @@ class Usecase:
|
||||
def execute(self):
|
||||
for rel in self.file.by_type("IfcRelFillsElement"):
|
||||
if rel.RelatedBuildingElement == self.settings["element"]:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
break
|
||||
|
||||
@@ -49,8 +49,14 @@ class Usecase:
|
||||
|
||||
def execute(self):
|
||||
for rel in self.settings["opening"].VoidsElements:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
if self.settings["opening"].is_a("IfcOpeningElement"):
|
||||
for rel in self.settings["opening"].HasFillings:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=self.settings["opening"])
|
||||
|
||||
Reference in New Issue
Block a user