The IFC Debug inspector now also shows inverse references, great for debugging IFC2X3 or style relationships

This commit is contained in:
Dion Moult
2021-03-13 22:21:44 +11:00
parent 5961253c29
commit 5604db8072
3 changed files with 18 additions and 0 deletions
@@ -121,6 +121,8 @@ class InspectFromStepId(bpy.types.Operator):
bpy.context.scene.BIMDebugProperties.attributes.remove(0)
while len(bpy.context.scene.BIMDebugProperties.inverse_attributes) > 0:
bpy.context.scene.BIMDebugProperties.inverse_attributes.remove(0)
while len(bpy.context.scene.BIMDebugProperties.inverse_references) > 0:
bpy.context.scene.BIMDebugProperties.inverse_references.remove(0)
for key, value in element.get_info().items():
self.add_attribute(bpy.context.scene.BIMDebugProperties.attributes, key, value)
for key in dir(element):
@@ -132,6 +134,10 @@ class InspectFromStepId(bpy.types.Operator):
):
continue
self.add_attribute(bpy.context.scene.BIMDebugProperties.inverse_attributes, key, getattr(element, key))
for inverse in self.file.get_inverse(element):
new = bpy.context.scene.BIMDebugProperties.inverse_references.add()
new.string_value = str(inverse)
new.int_value = inverse.id()
return {"FINISHED"}
def add_attribute(self, prop, key, value):
@@ -19,3 +19,4 @@ class BIMDebugProperties(PropertyGroup):
step_id_breadcrumb: CollectionProperty(name="STEP ID Breadcrumb", type=StrProperty)
attributes: CollectionProperty(name="Attributes", type=Attribute)
inverse_attributes: CollectionProperty(name="Inverse Attributes", type=Attribute)
inverse_references: CollectionProperty(name="Inverse References", type=Attribute)
@@ -69,3 +69,14 @@ class BIM_PT_debug(Panel):
row.operator(
"bim.inspect_from_step_id", icon="DISCLOSURE_TRI_RIGHT", text=""
).step_id = attribute.int_value
if props.inverse_references:
layout.label(text="Inverse references:")
for index, attribute in enumerate(props.inverse_references):
row = layout.row(align=True)
row.prop(attribute, "string_value", text="")
if attribute.int_value:
row.operator(
"bim.inspect_from_step_id", icon="DISCLOSURE_TRI_RIGHT", text=""
).step_id = attribute.int_value