diff --git a/src/ifccsv/ifccsv.py b/src/ifccsv/ifccsv.py index 08a4e3da58..d69f890df8 100755 --- a/src/ifccsv/ifccsv.py +++ b/src/ifccsv/ifccsv.py @@ -58,51 +58,25 @@ class IfcAttributeSetter: return element if "." not in key: return element - if key[0:3] == "Qto": - qto_name, prop = key.split(".", 1) - qto = IfcAttributeSetter.get_element_qto(element, qto_name) - if qto: - IfcAttributeSetter.set_qto_property(qto, prop, value) - return element pset_name, prop = key.split(".", 1) - pset = IfcAttributeSetter.get_element_pset(element, pset_name) + pset = ifcopenshell.util.element.get_pset(element, pset_name, should_inherit=True) if pset: - IfcAttributeSetter.set_pset_property(ifc_file, pset, prop, value) - return element + pset = ifc_file.by_id(pset["id"]) + if pset.is_a("IfcElementQuantity"): + IfcAttributeSetter.set_qto_property(pset, prop, value) + else: + IfcAttributeSetter.set_pset_property(ifc_file, pset, prop, value) return element - @staticmethod - def get_element_qto(element, name): - for relationship in element.IsDefinedBy: - if ( - relationship.is_a("IfcRelDefinesByProperties") - and relationship.RelatingPropertyDefinition.is_a("IfcElementQuantity") - and relationship.RelatingPropertyDefinition.Name == name - ): - return relationship.RelatingPropertyDefinition - @staticmethod def set_qto_property(qto, name, value): for prop in qto.Quantities: if prop.Name != name: continue - setattr(prop, prop.is_a()[len("IfcQuantity") :] + "Value", value) - - @staticmethod - def get_element_pset(element, name): - if element.is_a("IfcTypeObject"): - if element.HasPropertySets: - for pset in element.HasPropertySets: - if pset.is_a("IfcPropertySet") and pset.Name == name: - return pset - else: - for relationship in element.IsDefinedBy: - if ( - relationship.is_a("IfcRelDefinesByProperties") - and relationship.RelatingPropertyDefinition.is_a("IfcPropertySet") - and relationship.RelatingPropertyDefinition.Name == name - ): - return relationship.RelatingPropertyDefinition + try: + setattr(prop, prop.is_a()[len("IfcQuantity") :] + "Value", float(value)) + except: + pass @staticmethod def set_pset_property(ifc_file, pset, name, value):