Skip to content

Commit

Permalink
Fix IfcOpenShell#3958. Bug where reassigning type class would incorre…
Browse files Browse the repository at this point in the history
…ctly assign occurrence classes.
  • Loading branch information
Moult committed Nov 1, 2023
1 parent 3b298d4 commit 19a3f56
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/blenderbim/blenderbim/bim/module/root/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)

def _execute(self, context):
objects = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
if self.obj:
objects = [bpy.data.objects.get(self.obj)]
else:
objects = set(context.selected_objects + [context.active_object])
self.file = IfcStore.get_file()
predefined_type = context.scene.BIMRootProperties.ifc_predefined_type
if predefined_type == "USERDEFINED":
Expand All @@ -101,11 +104,9 @@ def _execute(self, context):
product = ifcopenshell.api.run(
"root.reassign_class",
self.file,
**{
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
"ifc_class": context.scene.BIMRootProperties.ifc_class,
"predefined_type": predefined_type,
},
product=self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
ifc_class=context.scene.BIMRootProperties.ifc_class,
predefined_type=predefined_type,
)
obj.name = "{}/{}".format(product.is_a(), getattr(product, "Name", "None"))
tool.Ifc.link(product, obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ def execute(self):
element.ObjectType = self.settings["predefined_type"]
if element.is_a("IfcTypeProduct"):
for typed_element in ifcopenshell.util.element.get_types(element) or []:
ifc_class = self.settings["ifc_class"].removesuffix("Type").removesuffix("Style")
ifcopenshell.api.run(
"root.reassign_class",
self.file,
product=typed_element,
ifc_class=self.settings["ifc_class"].strip("Type"),
ifc_class=ifc_class,
predefined_type= self.settings["predefined_type"]
)
return element

0 comments on commit 19a3f56

Please sign in to comment.