mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 21:59:59 +00:00
Usecase to Unassign object aggregation in the ifcopenshell.api
This commit is contained in:
@@ -44,6 +44,7 @@ class EditWorkPlan(bpy.types.Operator):
|
|||||||
**{"work_plan": self.file.by_id(props.active_work_plan_id), "attributes": attributes},
|
**{"work_plan": self.file.by_id(props.active_work_plan_id), "attributes": attributes},
|
||||||
)
|
)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
|
bpy.ops.bim.disable_editing_work_plan()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
|
class Usecase:
|
||||||
|
def __init__(self, file, **settings):
|
||||||
|
self.file = file
|
||||||
|
self.settings = {
|
||||||
|
"relating_object": None,
|
||||||
|
"product": None,
|
||||||
|
}
|
||||||
|
for key, value in settings.items():
|
||||||
|
self.settings[key] = value
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
for rel in self.settings["product"].Decomposes or []:
|
||||||
|
if not rel.is_a("IfcRelAggregates") or rel.RelatingObject != self.settings["relating_object"]:
|
||||||
|
continue
|
||||||
|
if len(rel.RelatedObjects) == 1:
|
||||||
|
return self.file.remove(rel)
|
||||||
|
related_objects = list(rel.RelatedObjects)
|
||||||
|
related_objects.remove(self.settings["product"])
|
||||||
|
rel.RelatedObjects = related_objects
|
||||||
|
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||||
|
return rel
|
||||||
Reference in New Issue
Block a user