mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
The type of mapped representations is now shown in the interface, with an asterisk denoting it is mapped.
This commit is contained in:
@@ -24,6 +24,41 @@ from mathutils import Vector
|
||||
|
||||
def refresh():
|
||||
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:
|
||||
|
||||
@@ -18,9 +18,8 @@
|
||||
|
||||
import bpy
|
||||
from bpy.types import Panel
|
||||
from ifcopenshell.api.geometry.data import Data
|
||||
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):
|
||||
@@ -40,33 +39,31 @@ class BIM_PT_representations(Panel):
|
||||
return IfcStore.get_file()
|
||||
|
||||
def draw(self, context):
|
||||
if not RepresentationsData.is_loaded:
|
||||
RepresentationsData.load()
|
||||
|
||||
layout = self.layout
|
||||
props = context.active_object.BIMObjectProperties
|
||||
|
||||
if props.ifc_definition_id not in Data.products:
|
||||
Data.load(IfcStore.get_file(), props.ifc_definition_id)
|
||||
|
||||
representations = Data.products[props.ifc_definition_id]
|
||||
if not representations:
|
||||
if not RepresentationsData.data["representations"]:
|
||||
layout.label(text="No representations found")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(context.scene.BIMProperties, "contexts", text="")
|
||||
row.operator("bim.add_representation", icon="ADD", text="")
|
||||
|
||||
for ifc_definition_id in representations:
|
||||
representation = Data.representations[ifc_definition_id]
|
||||
for representation in RepresentationsData.data["representations"]:
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text=representation["ContextOfItems"]["ContextType"])
|
||||
row.label(text=representation["ContextOfItems"]["ContextIdentifier"])
|
||||
row.label(text=representation["ContextOfItems"]["TargetView"])
|
||||
row.label(text=representation["ContextType"])
|
||||
row.label(text=representation["ContextIdentifier"])
|
||||
row.label(text=representation["TargetView"])
|
||||
row.label(text=representation["RepresentationType"])
|
||||
op = row.operator("bim.switch_representation", icon="OUTLINER_DATA_MESH", text="")
|
||||
op.should_switch_all_meshes = True
|
||||
op.should_reload = True
|
||||
op.ifc_definition_id = ifc_definition_id
|
||||
op.ifc_definition_id = representation["id"]
|
||||
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):
|
||||
|
||||
@@ -80,7 +80,7 @@ class VIEW3D_MT_PIE_bim(bpy.types.Menu):
|
||||
def draw(self, context):
|
||||
pie = self.layout.menu_pie()
|
||||
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_update_container")
|
||||
pie.operator("bim.open_pie_class", text="Assign IFC Class")
|
||||
|
||||
Reference in New Issue
Block a user