mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix #5921. Bug when parsing IDS XML of facets with no attributes.
This commit is contained in:
@@ -257,7 +257,7 @@ class Specification:
|
|||||||
facets = [facets]
|
facets = [facets]
|
||||||
for facet_xml in facets:
|
for facet_xml in facets:
|
||||||
name_capitalised = name[0].upper() + name[1:]
|
name_capitalised = name[0].upper() + name[1:]
|
||||||
facet = globals()[name_capitalised]().parse(facet_xml)
|
facet = globals()[name_capitalised]().parse(facet_xml or {})
|
||||||
results.append(facet)
|
results.append(facet)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|||||||
@@ -242,6 +242,29 @@ class TestIds:
|
|||||||
assert spec.requirements[0].failures[0]["element"] == wall
|
assert spec.requirements[0].failures[0]["element"] == wall
|
||||||
assert spec2.requirements[0].failures[0]["element"] == wall
|
assert spec2.requirements[0].failures[0]["element"] == wall
|
||||||
|
|
||||||
|
def test_parsing_entities_with_no_attributes(self):
|
||||||
|
model = ifcopenshell.file()
|
||||||
|
wall1 = model.createIfcWall(Name="Waldo")
|
||||||
|
wall2 = model.createIfcWall(Name="Wally")
|
||||||
|
model.createIfcWall(Name="Walter")
|
||||||
|
material = model.createIfcMaterial()
|
||||||
|
ifcopenshell.api.material.assign_material(model, products=[wall1, wall2], material=material)
|
||||||
|
specs = ids.Ids(title="Title")
|
||||||
|
spec = ids.Specification(name="Name")
|
||||||
|
spec.applicability.append(ids.Material())
|
||||||
|
spec.requirements.append(ids.Attribute(name="Name", value="Waldo"))
|
||||||
|
specs.specifications.append(spec)
|
||||||
|
xml = specs.to_string()
|
||||||
|
specs = ids.from_string(xml)
|
||||||
|
run(
|
||||||
|
"The material facet with no attributes selects elements with a material",
|
||||||
|
specs,
|
||||||
|
model,
|
||||||
|
False,
|
||||||
|
[wall1, wall2],
|
||||||
|
[wall2],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestSpecification:
|
class TestSpecification:
|
||||||
def test_create_specification_with_minimal_information(self):
|
def test_create_specification_with_minimal_information(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user