Fix bug where copying a class did not enforce mapped representations

This commit is contained in:
Dion Moult
2021-02-20 17:23:58 +11:00
parent 1b46f5c83a
commit 1892e9cc86
@@ -231,10 +231,11 @@ class CopyClass(bpy.types.Operator):
self.file, {"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)} self.file, {"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)}
).execute() ).execute()
IfcStore.link_element(result, obj) IfcStore.link_element(result, obj)
if obj.data and obj.data.users == 1: relating_type = ifcopenshell.util.element.get_type(result)
bpy.ops.bim.add_representation(obj=obj.name) if relating_type and relating_type.RepresentationMaps:
else:
bpy.ops.bim.map_representations( bpy.ops.bim.map_representations(
product_id=result.id(), type_product_id=ifcopenshell.util.element.get_type(result).id() product_id=result.id(), type_product_id=ifcopenshell.util.element.get_type(result).id()
) )
else:
bpy.ops.bim.add_representation(obj=obj.name)
return {"FINISHED"} return {"FINISHED"}