mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Implement IFC element inspector interface, useful for training and teaching OpenBIM
This commit is contained in:
@@ -208,6 +208,8 @@ if bpy is not None:
|
||||
operator.CopyPropertyToSelection,
|
||||
operator.CreateShapeFromStepId,
|
||||
operator.SelectHighPolygonMeshes,
|
||||
operator.InspectFromStepId,
|
||||
operator.InspectFromObject,
|
||||
operator.RefreshDrawingList,
|
||||
operator.GetRepresentationIfcParameters,
|
||||
operator.UpdateIfcRepresentation,
|
||||
@@ -241,6 +243,7 @@ if bpy is not None:
|
||||
prop.BcfTopicDocumentReference,
|
||||
prop.BcfTopicRelatedTopic,
|
||||
prop.Subcontext,
|
||||
prop.Attribute,
|
||||
prop.BIMProperties,
|
||||
prop.BIMDebugProperties,
|
||||
prop.BCFProperties,
|
||||
@@ -248,7 +251,6 @@ if bpy is not None:
|
||||
prop.BIMLibrary,
|
||||
prop.MapConversion,
|
||||
prop.TargetCRS,
|
||||
prop.Attribute,
|
||||
prop.IfcParameter,
|
||||
prop.BoundaryCondition,
|
||||
prop.PsetQto,
|
||||
|
||||
@@ -4341,6 +4341,49 @@ class SelectHighPolygonMeshes(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class InspectFromStepId(bpy.types.Operator):
|
||||
bl_idname = "bim.inspect_from_step_id"
|
||||
bl_label = "Inspect From STEP ID"
|
||||
step_id: bpy.props.IntProperty()
|
||||
guid: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = ifc.IfcStore.get_file()
|
||||
if self.step_id:
|
||||
bpy.context.scene.BIMDebugProperties.active_step_id = self.step_id
|
||||
element = self.file.by_id(self.step_id)
|
||||
else:
|
||||
pass
|
||||
while len(bpy.context.scene.BIMDebugProperties.attributes) > 0:
|
||||
bpy.context.scene.BIMDebugProperties.attributes.remove(0)
|
||||
while len(bpy.context.scene.BIMDebugProperties.inverse_attributes) > 0:
|
||||
bpy.context.scene.BIMDebugProperties.inverse_attributes.remove(0)
|
||||
for key, value in element.get_info().items():
|
||||
new = bpy.context.scene.BIMDebugProperties.attributes.add()
|
||||
new.name = key
|
||||
new.string_value = str(value)
|
||||
if isinstance(value, ifcopenshell.entity_instance):
|
||||
new.int_value = int(value.id())
|
||||
|
||||
for key in dir(element):
|
||||
if not key[0].isalpha() or key[0] != key[0].upper() or key in element.get_info() or not getattr(element, key):
|
||||
continue
|
||||
new = bpy.context.scene.BIMDebugProperties.inverse_attributes.add()
|
||||
new.name = key
|
||||
new.string_value = str(getattr(element, key))
|
||||
if isinstance(value, ifcopenshell.entity_instance):
|
||||
new.int_value = int(value.id())
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class InspectFromObject(bpy.types.Operator):
|
||||
bl_idname = "bim.inspect_from_object"
|
||||
bl_label = "Inspect From Object"
|
||||
|
||||
def execute(self, context):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RefreshDrawingList(bpy.types.Operator):
|
||||
bl_idname = "bim.refresh_drawing_list"
|
||||
bl_label = "Refresh Drawing List"
|
||||
|
||||
@@ -1668,6 +1668,10 @@ class BIMObjectProperties(PropertyGroup):
|
||||
class BIMDebugProperties(PropertyGroup):
|
||||
step_id: IntProperty(name="STEP ID")
|
||||
number_of_polygons: IntProperty(name="Number of Polygons")
|
||||
active_step_id: IntProperty(name="STEP ID")
|
||||
step_id_breadcrumb: CollectionProperty(name="STEP ID Breadcrumb", type=StrProperty)
|
||||
attributes: CollectionProperty(name="Attributes", type=Attribute)
|
||||
inverse_attributes: CollectionProperty(name="Inverse Attributes", type=Attribute)
|
||||
|
||||
|
||||
class BIMMaterialProperties(PropertyGroup):
|
||||
|
||||
@@ -2228,19 +2228,46 @@ class BIM_PT_debug(Panel):
|
||||
layout = self.layout
|
||||
|
||||
scene = context.scene
|
||||
bim_props = scene.BIMProperties
|
||||
debug_props = scene.BIMDebugProperties
|
||||
props = scene.BIMDebugProperties
|
||||
|
||||
row = layout.row()
|
||||
row.prop(debug_props, "step_id", text="")
|
||||
row.prop(props, "step_id", text="")
|
||||
row = layout.row()
|
||||
row.operator("bim.create_shape_from_step_id")
|
||||
|
||||
row = layout.row()
|
||||
row.prop(debug_props, "number_of_polygons", text="")
|
||||
row.prop(props, "number_of_polygons", text="")
|
||||
row = layout.row()
|
||||
row.operator("bim.select_high_polygon_meshes")
|
||||
|
||||
layout.label(text="Inspector:")
|
||||
|
||||
row = layout.row()
|
||||
row.prop(props, "active_step_id", text="")
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.inspect_from_step_id").step_id = bpy.context.scene.BIMDebugProperties.active_step_id
|
||||
row.operator("bim.inspect_from_object")
|
||||
|
||||
if props.attributes:
|
||||
layout.label(text="Direct attributes:")
|
||||
|
||||
for index, attribute in enumerate(props.attributes):
|
||||
row = layout.row(align=True)
|
||||
row.prop(attribute, "name", text="")
|
||||
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
|
||||
|
||||
if props.inverse_attributes:
|
||||
layout.label(text="Inverse attributes:")
|
||||
|
||||
for index, attribute in enumerate(props.inverse_attributes):
|
||||
row = layout.row(align=True)
|
||||
row.prop(attribute, "name", text="")
|
||||
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
|
||||
|
||||
|
||||
def ifc_units(self, context):
|
||||
scene = context.scene
|
||||
|
||||
Reference in New Issue
Block a user