mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Fix crash where IFCTester read directly from IFC in the UI
This commit is contained in:
@@ -131,7 +131,8 @@ class SelectRequirement(bpy.types.Operator):
|
||||
props.failed_entities.clear()
|
||||
for e in failed_entities:
|
||||
new_entity = props.failed_entities.add()
|
||||
new_entity.element = e["element"]
|
||||
new_entity.ifc_id = e["id"]
|
||||
new_entity.element = f'{e["class"]}/{e["name"]}'
|
||||
new_entity.reason = e["reason"]
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -41,8 +41,9 @@ class Specification(PropertyGroup):
|
||||
|
||||
|
||||
class FailedEntities(PropertyGroup):
|
||||
reason: StringProperty(name="Reason")
|
||||
ifc_id: IntProperty(name="IFC ID")
|
||||
element: StringProperty(name="Element")
|
||||
reason: StringProperty(name="Reason")
|
||||
|
||||
|
||||
class IfcTesterProperties(PropertyGroup):
|
||||
|
||||
@@ -115,17 +115,9 @@ class BIM_UL_tester_failed_entities(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
props = context.scene.IfcTesterProperties
|
||||
if item:
|
||||
if props.should_load_from_memory:
|
||||
ifc_file = tool.Ifc.get()
|
||||
ifc_id = int(item.element[1 : item.element.find("=")])
|
||||
entity = ifc_file.by_id(ifc_id)
|
||||
report_entity = f"[#{ifc_id}][{entity.is_a()}] {entity.Name}"
|
||||
else:
|
||||
report_entity = item.element
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.label(text=report_entity)
|
||||
row.label(text=item.element)
|
||||
row.label(text=item.reason)
|
||||
if props.should_load_from_memory:
|
||||
op = row.operator("bim.select_entity", text="", icon="RESTRICT_SELECT_OFF")
|
||||
op.ifc_id = entity.id()
|
||||
op.ifc_id = item.ifc_id
|
||||
|
||||
@@ -34,12 +34,13 @@ class TestFormat():
|
||||
assert subject.format('title(\"fOo\")') == "Foo"
|
||||
assert subject.format('concat(\"fOo\", \"bar\")') == "fOobar"
|
||||
assert subject.format('upper(concat(\"fOo\", \"bar\"))') == "FOOBAR"
|
||||
assert subject.format('substr(\"foobar\", 3)') == "bar"
|
||||
assert subject.format('substr(\"foobar\", 1, 2)') == "o"
|
||||
assert subject.format('substr(\"foobar\", 1, -1)') == "ooba"
|
||||
|
||||
def test_number_formatting(self):
|
||||
assert subject.format("round(123, 5)") == "125.0"
|
||||
assert subject.format('round(\"123\", 5)') == "125.0"
|
||||
assert subject.format("round(123, 5)") == "125"
|
||||
assert subject.format('round(\"123\", 5)') == "125"
|
||||
assert subject.format('metric_length(123, 5, 2)') == "125.00"
|
||||
assert subject.format('metric_length(123.123, 0.1, 2)') == "123.10"
|
||||
assert subject.format('metric_length(\"123\", 5, 2)') == "125.00"
|
||||
|
||||
@@ -436,13 +436,16 @@ class Bcf(Json):
|
||||
continue
|
||||
for failure in requirement["failed_entities"]:
|
||||
element = failure["element"]
|
||||
title_components = [
|
||||
title_components = []
|
||||
for title_component in [
|
||||
element.is_a(),
|
||||
getattr(element, "Name", None) or "Unnamed",
|
||||
getattr(element, "Name", "") or "Unnamed",
|
||||
failure.get("reason", "No reason"),
|
||||
getattr(element, "GlobalId", ""),
|
||||
getattr(element, "Tag", ""),
|
||||
]
|
||||
]:
|
||||
if title_component:
|
||||
title_components.append(title_component)
|
||||
title = " - ".join(title_components)
|
||||
description = f'{specification["name"]} - {requirement["description"]}'
|
||||
topic = bcfxml.add_topic(title, description, "IfcTester")
|
||||
|
||||
Reference in New Issue
Block a user