From d4b88fd42279c3d9c8c476aab14992124fface19 Mon Sep 17 00:00:00 2001 From: Totally a booplicate <53382877+Booplicate@users.noreply.github.com> Date: Sat, 3 Jun 2023 11:42:36 +0300 Subject: [PATCH] resolve TODO This is being fixed, we should always have a class to use --- .../ifcopenshell/api/pset/edit_pset.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py index 3269d6e8ab..513076efd1 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py @@ -256,7 +256,7 @@ class Usecase: ) else: - raise TypeError(f"'{value}' is not a valid property value for '{name}'") + raise ValueError(f"'{value}' is not a valid property value for '{name}'") # TODO-The following "elif" is temporary code, will need to refactor at some point - vulevukusej elif isinstance(value, (tuple, list)): @@ -267,19 +267,18 @@ class Usecase: continue if pset_template.TemplateType == "P_LISTVALUE": - # TODO: What class to pick if none was provided? We get an error otherwise: - # ValueError: invalid null reference in method 'new_IfcBaseClass', argument 2 of type 'std::string const &' ifc_class = getattr(pset_template, "PrimaryMeasureType", None) if ifc_class is None: - ifc_class = "IfcLabel" + raise ValueError(f"pset template '{pset_template.Name}' is missing PrimaryMeasureType") + properties.append( self.file.create_entity( - "IfcPropertyListValue", - Name=name, - ListValues=[ - self.file.create_entity(ifc_class, v) - for v in value - ] + "IfcPropertyListValue", + Name=name, + ListValues=[ + self.file.create_entity(ifc_class, v) + for v in value + ] ) ) break