Skip to content

Commit d1caa32

Browse files
Refactor to usecase as asked in IfcOpenShell#1881 (IfcOpenShell#1907)
1 parent 4f7bfec commit d1caa32

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/blenderbim/blenderbim/bim/module/boundary/operator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,12 @@ def execute(self, context):
257257
def _execute(self, context):
258258
bprops = context.active_object.bim_boundary_properties
259259
boundary = tool.Ifc.get_entity(context.active_object)
260+
attributes = dict()
260261
for ifc_attribute, blender_property in EDITABLE_ATTRIBUTES.items():
261-
if not hasattr(boundary, ifc_attribute):
262-
continue
263262
obj = getattr(bprops, blender_property, None)
264263
entity = tool.Ifc.get_entity(obj)
265-
setattr(boundary, ifc_attribute, entity)
264+
attributes[blender_property] = entity
265+
ifcopenshell.api.run("boundary.edit_attributes", tool.Ifc.get(), entity=boundary, **attributes)
266266
bpy.ops.bim.disable_editing_boundary()
267267
return {"FINISHED"}
268268

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Usecase:
2+
def __init__(self, file, **kwargs):
3+
"""location, axis and ref_direction defines the plane"""
4+
self.file = file
5+
self.entity: "IfcRelSpaceBoundary"
6+
self.relating_space: "IfcSpace | IfcExternalSpatialElement"
7+
self.related_building_element: "IfcElement"
8+
self.parent_boundary: "IfcRelSpaceBoundary" = None
9+
self.corresponding_boundary: "IfcRelSpaceBoundary" = None
10+
for key, value in kwargs.items():
11+
setattr(self, key, value)
12+
13+
def execute(self):
14+
self.entity.RelatingSpace = self.relating_space
15+
self.entity.RelatedBuildingElement = self.related_building_element
16+
if hasattr(self.entity, "ParentBoundary"):
17+
self.entity.ParentBoundary = self.parent_boundary
18+
if hasattr(self.entity, "CorrespondingBoundary"):
19+
self.entity.CorrespondingBoundary = self.corresponding_boundary

0 commit comments

Comments
 (0)