The type of mapped representations is now shown in the interface, with an asterisk denoting it is mapped.

This commit is contained in:
Dion Moult
2021-10-21 19:16:15 +11:00
parent 525e6debd5
commit a99df36351
3 changed files with 47 additions and 15 deletions
@@ -24,6 +24,41 @@ from mathutils import Vector
def refresh(): def refresh():
DerivedPlacementsData.is_loaded = False DerivedPlacementsData.is_loaded = False
RepresentationsData.is_loaded = False
class RepresentationsData:
data = {}
is_loaded = False
@classmethod
def load(cls):
cls.data = {"representations": cls.representations()}
cls.is_loaded = True
@classmethod
def representations(cls):
results = []
element = tool.Ifc.get_entity(bpy.context.active_object)
if element.is_a("IfcProduct") and element.Representation:
representations = element.Representation.Representations
elif element.is_a("IfcTypeProduct"):
representations = [rm.MappedRepresentation for rm in element.RepresentationMaps or []]
for representation in representations:
representation_type = representation.RepresentationType
if representation_type == "MappedRepresentation":
representation_type = representation.Items[0].MappingSource.MappedRepresentation.RepresentationType
representation_type += "*"
results.append(
{
"id": representation.id(),
"ContextType": representation.ContextOfItems.ContextType,
"ContextIdentifier": representation.ContextOfItems.ContextIdentifier,
"TargetView": representation.ContextOfItems.TargetView,
"RepresentationType": representation_type,
}
)
return results
class DerivedPlacementsData: class DerivedPlacementsData:
@@ -18,9 +18,8 @@
import bpy import bpy
from bpy.types import Panel from bpy.types import Panel
from ifcopenshell.api.geometry.data import Data
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.geometry.data import DerivedPlacementsData from blenderbim.bim.module.geometry.data import RepresentationsData, DerivedPlacementsData
class BIM_PT_representations(Panel): class BIM_PT_representations(Panel):
@@ -40,33 +39,31 @@ class BIM_PT_representations(Panel):
return IfcStore.get_file() return IfcStore.get_file()
def draw(self, context): def draw(self, context):
if not RepresentationsData.is_loaded:
RepresentationsData.load()
layout = self.layout layout = self.layout
props = context.active_object.BIMObjectProperties props = context.active_object.BIMObjectProperties
if props.ifc_definition_id not in Data.products: if not RepresentationsData.data["representations"]:
Data.load(IfcStore.get_file(), props.ifc_definition_id)
representations = Data.products[props.ifc_definition_id]
if not representations:
layout.label(text="No representations found") layout.label(text="No representations found")
row = layout.row(align=True) row = layout.row(align=True)
row.prop(context.scene.BIMProperties, "contexts", text="") row.prop(context.scene.BIMProperties, "contexts", text="")
row.operator("bim.add_representation", icon="ADD", text="") row.operator("bim.add_representation", icon="ADD", text="")
for ifc_definition_id in representations: for representation in RepresentationsData.data["representations"]:
representation = Data.representations[ifc_definition_id]
row = self.layout.row(align=True) row = self.layout.row(align=True)
row.label(text=representation["ContextOfItems"]["ContextType"]) row.label(text=representation["ContextType"])
row.label(text=representation["ContextOfItems"]["ContextIdentifier"]) row.label(text=representation["ContextIdentifier"])
row.label(text=representation["ContextOfItems"]["TargetView"]) row.label(text=representation["TargetView"])
row.label(text=representation["RepresentationType"]) row.label(text=representation["RepresentationType"])
op = row.operator("bim.switch_representation", icon="OUTLINER_DATA_MESH", text="") op = row.operator("bim.switch_representation", icon="OUTLINER_DATA_MESH", text="")
op.should_switch_all_meshes = True op.should_switch_all_meshes = True
op.should_reload = True op.should_reload = True
op.ifc_definition_id = ifc_definition_id op.ifc_definition_id = representation["id"]
op.disable_opening_subtractions = False op.disable_opening_subtractions = False
row.operator("bim.remove_representation", icon="X", text="").representation_id = ifc_definition_id row.operator("bim.remove_representation", icon="X", text="").representation_id = representation["id"]
class BIM_PT_mesh(Panel): class BIM_PT_mesh(Panel):
@@ -80,7 +80,7 @@ class VIEW3D_MT_PIE_bim(bpy.types.Menu):
def draw(self, context): def draw(self, context):
pie = self.layout.menu_pie() pie = self.layout.menu_pie()
pie.operator("bim.edit_object_placement") pie.operator("bim.edit_object_placement")
pie.operator("bim.update_representation") pie.operator("bim.update_representation").ifc_representation_class = ""
pie.operator("bim.pie_add_opening") pie.operator("bim.pie_add_opening")
pie.operator("bim.pie_update_container") pie.operator("bim.pie_update_container")
pie.operator("bim.open_pie_class", text="Assign IFC Class") pie.operator("bim.open_pie_class", text="Assign IFC Class")