mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Add select entities (2023_07_17)
This commit is contained in:
@@ -24,6 +24,7 @@ classes = (
|
||||
operator.SelectSpecs,
|
||||
operator.SelectIfcTesterIfcFile,
|
||||
operator.SelectRequirement,
|
||||
operator.SelectEntity,
|
||||
prop.FailedEntities,
|
||||
prop.Specification,
|
||||
prop.IfcTesterProperties,
|
||||
|
||||
@@ -54,6 +54,7 @@ class ExecuteIfcTester(bpy.types.Operator):
|
||||
print("Finished loading:", time.time() - start)
|
||||
start = time.time()
|
||||
specs.validate(ifc)
|
||||
print(specs)
|
||||
|
||||
print("Finished validating:", time.time() - start)
|
||||
start = time.time()
|
||||
@@ -127,9 +128,22 @@ class SelectRequirement(bpy.types.Operator):
|
||||
failed_entities = report[self.spec_index]['requirements'] [self.req_index]['failed_entities']
|
||||
print(failed_entities)
|
||||
for e in failed_entities:
|
||||
new_entity = props.failed_entities.add()
|
||||
new_entity.reason = e['reason']
|
||||
new_entity = props.failed_entities.add()
|
||||
new_entity.element = e['element']
|
||||
new_entity.reason = e['reason']
|
||||
return {"FINISHED"}
|
||||
|
||||
class SelectEntity(bpy.types.Operator):
|
||||
bl_idname = "bim.select_entity"
|
||||
bl_label = "Select Entity"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
ifc_id: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
for obj in context.scene.objects:
|
||||
if obj.BIMObjectProperties.ifc_definition_id == self.ifc_id:
|
||||
obj.select_set(True)
|
||||
bpy.context.view_layer.objects.active = obj
|
||||
return {"FINISHED"}
|
||||
|
||||
return {"FINISHED"}
|
||||
@@ -83,14 +83,16 @@ class BIM_PT_tester(Panel):
|
||||
row = box.row(align=True)
|
||||
row.label(text=f" {c}. {req['description']}")
|
||||
if req['status']:
|
||||
row.label(text="PASS")
|
||||
row.label(text="PASS", icon="CHECKMARK")
|
||||
else:
|
||||
row.label(text="FAIL")
|
||||
op = row.operator("bim.select_requirement", text="", icon="RESTRICT_SELECT_OFF")
|
||||
op.spec_index = i
|
||||
op.req_index = c - 1
|
||||
row.label(text="FAIL", icon="CANCEL")
|
||||
op = row.operator("bim.select_requirement", text="", icon="LONGDISPLAY")
|
||||
op.spec_index = i
|
||||
op.req_index = c - 1
|
||||
c += 1
|
||||
if props.has_entities:
|
||||
row = self.layout.row()
|
||||
row.label(text = "Failed entities :")
|
||||
self.layout.template_list(
|
||||
"BIM_UL_tester_failed_entities",
|
||||
"",
|
||||
@@ -116,9 +118,15 @@ class BIM_UL_tester_specifications(UIList):
|
||||
class BIM_UL_tester_failed_entities(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
props = context.scene.IfcTesterProperties
|
||||
ifc_file = tool.Ifc.get()
|
||||
if item:
|
||||
icon = "WORDWRAP_ON"
|
||||
row = layout.row(align=True)
|
||||
ifc_id = int(item.element[1:item.element.find('=')])
|
||||
entity = ifc_file.by_id(ifc_id)
|
||||
row = layout.row(align=True)
|
||||
row.label(text=f'{entity.Name} [{entity.is_a()}]')
|
||||
row.label(text=item.reason)
|
||||
row.label(text=eval(item.element).Name)
|
||||
op = row.operator("bim.select_entity", text="", icon="RESTRICT_SELECT_OFF")
|
||||
op.ifc_id = entity.id()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user