WIP implement presentation layers. Nicer UI. See #1222.

This commit is contained in:
Dion Moult
2021-01-25 18:10:18 +11:00
parent 911ff4484f
commit 20ab036016
17 changed files with 403 additions and 332 deletions
@@ -25,6 +25,7 @@ if bpy is not None:
"document": None,
"geometry": None,
"georeference": None,
"layer": None,
"material": None,
"model": None,
"owner": None,
@@ -62,15 +63,6 @@ if bpy is not None:
operator.SelectSweptSolidExtrusion,
operator.AddMaterialPset,
operator.RemoveMaterialPset,
operator.AddMaterialLayer,
operator.RemoveMaterialLayer,
operator.MoveMaterialLayer,
operator.AddMaterialConstituent,
operator.RemoveMaterialConstituent,
operator.MoveMaterialConstituent,
operator.AddMaterialProfile,
operator.RemoveMaterialProfile,
operator.MoveMaterialProfile,
operator.AddMaterialAttribute,
operator.RemoveMaterialAttribute,
operator.FetchLibraryInformation,
@@ -126,11 +118,6 @@ if bpy is not None:
operator.BuildSchedule,
operator.AddScheduleToSheet,
operator.SetViewportShadowFromSun,
operator.AddPresentationLayer,
operator.AssignPresentationLayer,
operator.UnassignPresentationLayer,
operator.RemovePresentationLayer,
operator.UpdatePresentationLayer,
operator.AddDrawingStyleAttribute,
operator.RemoveDrawingStyleAttribute,
operator.CopyPropertyToSelection,
@@ -154,7 +141,6 @@ if bpy is not None:
prop.Schedule,
prop.DrawingStyle,
prop.Sheet,
prop.PresentationLayer,
prop.BIMProperties,
prop.DocProperties,
prop.BIMLibrary,
@@ -176,8 +162,6 @@ if bpy is not None:
ui.BIM_PT_sheets,
ui.BIM_PT_ifcclash,
ui.BIM_PT_library,
ui.BIM_PT_presentation_layers,
ui.BIM_PT_presentation_layer_data,
ui.BIM_PT_object_structural,
ui.BIM_PT_camera,
ui.BIM_PT_text,
@@ -372,8 +372,6 @@ class IfcImporter:
):
self.merge_materials_by_colour()
self.profile_code("Merging by colour")
self.create_presentation_layers()
self.profile_code("Create presentation layers")
self.add_project_to_scene()
self.profile_code("Add project to scene")
if self.ifc_import_settings.should_clean_mesh and len(self.file.by_type("IfcElement")) < 1000:
@@ -1051,31 +1049,6 @@ class IfcImporter:
project_collection.children[self.opening_collection.name].hide_viewport = True
project_collection.children[self.type_collection.name].hide_viewport = True
def create_presentation_layers(self):
for assignment in self.file.by_type("IfcPresentationLayerAssignment"):
layer = bpy.context.scene.BIMProperties.presentation_layers.add()
layer_index = len(bpy.context.scene.BIMProperties.presentation_layers) - 1
layer.name = assignment.Name
layer.description = assignment.Description or ""
layer.identifier = assignment.Identifier or ""
if assignment.is_a() == "IfcPresentationLayerWithStyle":
layer.layer_on = assignment.LayerOn if assignment.LayerOn is not None else True
layer.layer_frozen = assignment.LayerFrozen if assignment.LayerFrozen is not None else False
layer.layer_blocked = assignment.LayerBlocked if assignment.LayerBlocked is not None else False
for item in assignment.AssignedItems:
# TODO: This is a simplified implementation of assigning presentation layers that ignores assigned
# representation items, does not consider mapped representations, and assumes a Body context. See #1109.
if not hasattr(item, "OfProductRepresentation") or item.RepresentationIdentifier != "Body":
continue
for product_representation in item.OfProductRepresentation:
for product in product_representation.ShapeOfProduct:
try:
obj = self.added_data[product.GlobalId]
obj.data.BIMMeshProperties.presentation_layer_index = layer_index
except:
pass # Occurs for example in opening elements or exclusions
def clean_mesh(self):
obj = None
last_obj = None
@@ -16,13 +16,17 @@ class LoadInformation(bpy.types.Operator):
bl_label = "Load Information"
def execute(self, context):
self.file = IfcStore.get_file()
props = context.scene.BIMDocumentProperties
while len(props.documents) > 0:
props.documents.remove(0)
for information_id, information in Data.information.items():
new = props.documents.add()
new.name = information["Name"] or "Unnamed"
new.identification = information["Identification"] or "*"
if self.file.schema == "IFC2X3":
new.identification = information["DocumentId"] or "*"
else:
new.identification = information["Identification"] or "*"
new.ifc_definition_id = information_id
props.is_editing = "information"
bpy.ops.bim.disable_editing_document()
@@ -34,13 +38,17 @@ class LoadDocumentReferences(bpy.types.Operator):
bl_label = "Load Document References"
def execute(self, context):
self.file = IfcStore.get_file()
props = context.scene.BIMDocumentProperties
while len(props.documents) > 0:
props.documents.remove(0)
for reference_id, reference in Data.references.items():
new = props.documents.add()
new.name = reference["Name"] or "Unnamed"
new.identification = reference["Identification"] or "*"
if self.file.schema == "IFC2X3":
new.identification = reference["ItemReference"] or "*"
else:
new.identification = reference["Identification"] or "*"
new.ifc_definition_id = reference_id
props.is_editing = "reference"
bpy.ops.bim.disable_editing_document()
@@ -25,19 +25,19 @@ class BIM_PT_documents(Panel):
row = self.layout.row(align=True)
row.label(text="{} Documents Found".format(len(Data.information)), icon="FILE")
if self.props.is_editing == "information":
row.operator("bim.disable_document_editing_ui", text="", icon="CHECKMARK")
row.operator("bim.add_information", text="", icon="ADD")
row.operator("bim.disable_document_editing_ui", text="", icon="X")
else:
row.operator("bim.load_information", text="", icon="GREASEPENCIL")
row.operator("bim.load_information", text="", icon="IMPORT")
if not self.props.is_editing or self.props.is_editing == "reference":
row = self.layout.row(align=True)
row.label(text="{} References Found".format(len(Data.references)), icon="FILE_HIDDEN")
if self.props.is_editing == "reference":
row.operator("bim.disable_document_editing_ui", text="", icon="CHECKMARK")
row.operator("bim.add_document_reference", text="", icon="ADD")
row.operator("bim.disable_document_editing_ui", text="", icon="X")
else:
row.operator("bim.load_document_references", text="", icon="GREASEPENCIL")
row.operator("bim.load_document_references", text="", icon="IMPORT")
if self.props.is_editing:
self.layout.template_list(
@@ -51,7 +51,6 @@ class BIM_PT_documents(Panel):
if self.props.active_document_id:
self.draw_editable_ui(context)
return
def draw_editable_ui(self, context):
for attribute in self.props.document_attributes:
@@ -0,0 +1,26 @@
import bpy
from . import ui, prop, operator
classes = (
operator.LoadLayers,
operator.DisableLayerEditingUI,
operator.EnableEditingLayer,
operator.DisableEditingLayer,
operator.AddPresentationLayer,
operator.EditPresentationLayer,
operator.RemovePresentationLayer,
operator.AssignPresentationLayer,
operator.UnassignPresentationLayer,
prop.Layer,
prop.BIMLayerProperties,
ui.BIM_PT_layers,
ui.BIM_UL_layers,
)
def register():
bpy.types.Scene.BIMLayerProperties = bpy.props.PointerProperty(type=prop.BIMLayerProperties)
def unregister():
del bpy.types.Scene.BIMLayerProperties
@@ -0,0 +1,13 @@
import ifcopenshell
class Usecase:
def __init__(self, file, settings={}):
self.file = file
self.settings = {}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
return self.file.create_entity("IfcPresentationLayerAssignment", **{
"Name": "Unnamed"
})
@@ -0,0 +1,17 @@
import ifcopenshell
class Usecase:
def __init__(self, file, settings=None):
self.file = file
self.settings = {
"item": None,
"layer": None,
}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
assigned_items = set(self.settings["layer"].AssignedItems) or set()
assigned_items.add(self.settings["item"])
self.settings["layer"].AssignedItems = list(assigned_items)
@@ -0,0 +1,30 @@
import ifcopenshell
import ifcopenshell.util.date
from blenderbim.bim.ifc import IfcStore
from datetime import datetime
class Data:
is_loaded = False
items = {}
layers = {}
@classmethod
def load(cls, item_id=None):
cls._file = IfcStore.get_file()
if not cls._file:
return
cls.load_layers()
cls.is_loaded = True
@classmethod
def load_layers(cls):
cls.layers = {}
cls.items = {}
for layer in cls._file.by_type("IfcPresentationLayerAssignment"):
data = layer.get_info()
if layer.AssignedItems:
for item in layer.AssignedItems:
cls.items.setdefault(item.id(), []).append(layer.id())
del data["AssignedItems"]
cls.layers[layer.id()] = data
@@ -0,0 +1,13 @@
class Usecase:
def __init__(self, file, settings=None):
self.file = file
self.settings = {
"layer": None,
"attributes": {}
}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
for name, value in self.settings["attributes"].items():
setattr(self.settings["layer"], name, value)
@@ -0,0 +1,151 @@
import bpy
import json
import blenderbim.bim.module.layer.add_layer as add_layer
import blenderbim.bim.module.layer.edit_layer as edit_layer
import blenderbim.bim.module.layer.remove_layer as remove_layer
import blenderbim.bim.module.layer.assign_layer as assign_layer
import blenderbim.bim.module.layer.unassign_layer as unassign_layer
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.layer.data import Data
class LoadLayers(bpy.types.Operator):
bl_idname = "bim.load_layers"
bl_label = "Load Layers"
def execute(self, context):
self.file = IfcStore.get_file()
props = context.scene.BIMLayerProperties
while len(props.layers) > 0:
props.layers.remove(0)
for layer_id, layer in Data.layers.items():
new = props.layers.add()
new.name = layer["Name"] or "Unnamed"
new.ifc_definition_id = layer_id
props.is_editing = True
bpy.ops.bim.disable_editing_layer()
return {"FINISHED"}
class DisableLayerEditingUI(bpy.types.Operator):
bl_idname = "bim.disable_layer_editing_ui"
bl_label = "Disable Layer Editing UI"
def execute(self, context):
context.scene.BIMLayerProperties.is_editing = False
return {"FINISHED"}
class EnableEditingLayer(bpy.types.Operator):
bl_idname = "bim.enable_editing_layer"
bl_label = "Enable Editing Layer"
layer: bpy.props.IntProperty()
def execute(self, context):
props = context.scene.BIMLayerProperties
while len(props.layer_attributes) > 0:
props.layer_attributes.remove(0)
data = Data.layers[self.layer]
for attribute in IfcStore.get_schema().declaration_by_name("IfcPresentationLayerAssignment").all_attributes():
data_type = str(attribute.type_of_attribute)
if "<entity" in data_type:
continue
new = props.layer_attributes.add()
new.name = attribute.name()
new.is_null = data[attribute.name()] is None
new.is_optional = attribute.optional()
new.string_value = "" if new.is_null else data[attribute.name()]
props.active_layer_id = self.layer
return {"FINISHED"}
class DisableEditingLayer(bpy.types.Operator):
bl_idname = "bim.disable_editing_layer"
bl_label = "Disable Editing Layer"
def execute(self, context):
context.scene.BIMLayerProperties.active_layer_id = 0
return {"FINISHED"}
class AddPresentationLayer(bpy.types.Operator):
bl_idname = "bim.add_presentation_layer"
bl_label = "Add Layer"
def execute(self, context):
result = add_layer.Usecase(IfcStore.get_file()).execute()
Data.load()
bpy.ops.bim.load_layers()
bpy.ops.bim.enable_editing_layer(layer=result.id())
return {"FINISHED"}
class EditPresentationLayer(bpy.types.Operator):
bl_idname = "bim.edit_presentation_layer"
bl_label = "Edit Layer"
def execute(self, context):
props = context.scene.BIMLayerProperties
attributes = {}
for attribute in props.layer_attributes:
if attribute.is_null:
attributes[attribute.name] = None
else:
attributes[attribute.name] = attribute.string_value
self.file = IfcStore.get_file()
edit_layer.Usecase(
self.file, {"layer": self.file.by_id(props.active_layer_id), "attributes": attributes}
).execute()
Data.load()
bpy.ops.bim.load_layers()
return {"FINISHED"}
class RemovePresentationLayer(bpy.types.Operator):
bl_idname = "bim.remove_presentation_layer"
bl_label = "Remove Presentation Layer"
layer: bpy.props.IntProperty()
def execute(self, context):
props = context.scene.BIMLayerProperties
self.file = IfcStore.get_file()
remove_layer.Usecase(self.file, {"layer": self.file.by_id(self.layer)}).execute()
Data.load()
bpy.ops.bim.load_layers()
return {"FINISHED"}
class AssignPresentationLayer(bpy.types.Operator):
bl_idname = "bim.assign_presentation_layer"
bl_label = "Assign Presentation Layer"
item: bpy.props.StringProperty()
layer: bpy.props.IntProperty()
def execute(self, context):
item = bpy.data.meshes.get(self.item) if self.item else context.active_object.data
self.file = IfcStore.get_file()
assign_layer.Usecase(self.file, {
"item": self.file.by_id(item.BIMMeshProperties.ifc_definition_id),
"layer": self.file.by_id(self.layer)
}).execute()
Data.load()
return {"FINISHED"}
class UnassignPresentationLayer(bpy.types.Operator):
bl_idname = "bim.unassign_presentation_layer"
bl_label = "Unassign Presentation Layer"
item: bpy.props.StringProperty()
layer: bpy.props.IntProperty()
def execute(self, context):
item = bpy.data.meshes.get(self.item) if self.item else context.active_object.data
self.file = IfcStore.get_file()
unassign_layer.Usecase(self.file, {
"item": self.file.by_id(item.BIMMeshProperties.ifc_definition_id),
"layer": self.file.by_id(self.layer)
}).execute()
Data.load()
return {"FINISHED"}
@@ -0,0 +1,26 @@
import bpy
from blenderbim.bim.prop import StrProperty, Attribute
from bpy.types import PropertyGroup
from bpy.props import (
PointerProperty,
StringProperty,
EnumProperty,
BoolProperty,
IntProperty,
FloatProperty,
FloatVectorProperty,
CollectionProperty,
)
class Layer(PropertyGroup):
name: StringProperty(name="Name")
ifc_definition_id: IntProperty(name="IFC Definition ID")
class BIMLayerProperties(PropertyGroup):
layer_attributes: CollectionProperty(name="Layer Attributes", type=Attribute)
active_layer_id: IntProperty(name="Active Layer Id")
layers: CollectionProperty(name="Layers", type=Layer)
active_layer_index: IntProperty(name="Active Layer Index")
is_editing: BoolProperty(name="Is Editing", default=False)
@@ -0,0 +1,9 @@
class Usecase:
def __init__(self, file, settings=None):
self.file = file
self.settings = {"layer": None}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
self.file.remove(self.settings["layer"])
@@ -0,0 +1,86 @@
from bpy.types import Panel, UIList, Mesh
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.layer.data import Data
class BIM_PT_layers(Panel):
bl_label = "IFC Presentation Layers"
bl_idname = "BIM_PT_layers"
bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
@classmethod
def poll(cls, context):
return IfcStore.get_file()
def draw(self, context):
if not Data.is_loaded:
Data.load()
self.props = context.scene.BIMLayerProperties
if Data.layers:
row = self.layout.row(align=True)
row.label(text="{} Layers Found".format(len(Data.layers.keys())))
if self.props.is_editing:
row.operator("bim.add_presentation_layer", text="", icon="ADD")
row.operator("bim.disable_layer_editing_ui", text="", icon="X")
else:
row.operator("bim.load_layers", text="", icon="IMPORT")
else:
row = self.layout.row(align=True)
row.label(text="No Layers")
if self.props.is_editing:
self.layout.template_list(
"BIM_UL_layers",
"",
self.props,
"layers",
self.props,
"active_layer_index",
)
if self.props.active_layer_id:
self.draw_editable_ui(context)
def draw_editable_ui(self, context):
for attribute in self.props.layer_attributes:
row = self.layout.row(align=True)
row.prop(attribute, "string_value", text=attribute.name)
if attribute.is_optional:
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
class BIM_UL_layers(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
if item:
row = layout.row(align=True)
row.label(text=item.name)
if context.active_object and isinstance(context.active_object.data, Mesh):
mprops = context.active_object.data.BIMMeshProperties
if (
mprops.ifc_definition_id in Data.items
and item.ifc_definition_id in Data.items[mprops.ifc_definition_id]
):
op = row.operator("bim.unassign_presentation_layer", text="", icon="KEYFRAME_HLT", emboss=False)
op.layer = item.ifc_definition_id
else:
op = row.operator("bim.assign_presentation_layer", text="", icon="KEYFRAME", emboss=False)
op.layer = item.ifc_definition_id
row.operator("bim.disable_editing_layer", text="", icon="HIDE_OFF", emboss=False)
row.operator("bim.disable_editing_layer", text="", icon="FREEZE", emboss=False)
if context.scene.BIMLayerProperties.active_layer_id == item.ifc_definition_id:
row.operator("bim.edit_presentation_layer", text="", icon="CHECKMARK")
row.operator("bim.disable_editing_layer", text="", icon="X")
elif context.scene.BIMLayerProperties.active_layer_id:
row.operator("bim.remove_presentation_layer", text="", icon="X").layer = item.ifc_definition_id
else:
op = row.operator("bim.enable_editing_layer", text="", icon="GREASEPENCIL")
op.layer = item.ifc_definition_id
row.operator("bim.remove_presentation_layer", text="", icon="X").layer = item.ifc_definition_id
@@ -0,0 +1,17 @@
import ifcopenshell
class Usecase:
def __init__(self, file, settings=None):
self.file = file
self.settings = {
"item": None,
"layer": None,
}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
assigned_items = set(self.settings["layer"].AssignedItems) or set()
assigned_items.remove(self.settings["item"])
self.settings["layer"].AssignedItems = list(assigned_items)
@@ -1986,120 +1986,6 @@ class RemoveSchedule(bpy.types.Operator):
return {"FINISHED"}
class AddMaterialLayer(bpy.types.Operator):
bl_idname = "bim.add_material_layer"
bl_label = "Add Material Layer"
def execute(self, context):
new = bpy.context.active_object.BIMObjectProperties.material_set.material_layers.add()
new.material = bpy.data.materials[0]
new.name = "Material Layer"
return {"FINISHED"}
class RemoveMaterialLayer(bpy.types.Operator):
bl_idname = "bim.remove_material_layer"
bl_label = "Remove Material Layer"
index: bpy.props.IntProperty()
def execute(self, context):
bpy.context.active_object.BIMObjectProperties.material_set.material_layers.remove(self.index)
return {"FINISHED"}
class MoveMaterialLayer(bpy.types.Operator):
bl_idname = "bim.move_material_layer"
bl_label = "Move Material Layer"
direction: bpy.props.StringProperty()
def execute(self, context):
props = bpy.context.active_object.BIMObjectProperties.material_set
index = props.active_material_layer_index
if self.direction == "UP" and index - 1 >= 0:
props.material_layers.move(index, index - 1)
props.active_material_layer_index = index - 1
elif self.direction == "DOWN" and index + 1 < len(props.material_layers):
props.material_layers.move(index, index + 1)
props.active_material_layer_index = index + 1
return {"FINISHED"}
class AddMaterialConstituent(bpy.types.Operator):
bl_idname = "bim.add_material_constituent"
bl_label = "Add Material Constituent"
def execute(self, context):
new = bpy.context.active_object.BIMObjectProperties.material_set.material_constituents.add()
new.material = bpy.data.materials[0]
new.name = "Material Constituent"
return {"FINISHED"}
class RemoveMaterialConstituent(bpy.types.Operator):
bl_idname = "bim.remove_material_constituent"
bl_label = "Remove Material Constituent"
index: bpy.props.IntProperty()
def execute(self, context):
bpy.context.active_object.BIMObjectProperties.material_set.material_constituents.remove(self.index)
return {"FINISHED"}
class MoveMaterialConstituent(bpy.types.Operator):
bl_idname = "bim.move_material_constituent"
bl_label = "Move Material Constituent"
direction: bpy.props.StringProperty()
def execute(self, context):
props = bpy.context.active_object.BIMObjectProperties.material_set
index = props.active_material_constituent_index
if self.direction == "UP" and index - 1 >= 0:
props.material_constituents.move(index, index - 1)
props.active_material_constituent_index = index - 1
elif self.direction == "DOWN" and index + 1 < len(props.material_constituents):
props.material_constituents.move(index, index + 1)
props.active_material_constituent_index = index + 1
return {"FINISHED"}
class AddMaterialProfile(bpy.types.Operator):
bl_idname = "bim.add_material_profile"
bl_label = "Add Material Profile"
def execute(self, context):
new = bpy.context.active_object.BIMObjectProperties.material_set.material_profiles.add()
new.material = bpy.data.materials[0]
new.name = "Material Profile"
return {"FINISHED"}
class RemoveMaterialProfile(bpy.types.Operator):
bl_idname = "bim.remove_material_profile"
bl_label = "Remove Material Profile"
index: bpy.props.IntProperty()
def execute(self, context):
bpy.context.active_object.BIMObjectProperties.material_set.material_profiles.remove(self.index)
return {"FINISHED"}
class MoveMaterialProfile(bpy.types.Operator):
bl_idname = "bim.move_material_profile"
bl_label = "Move Material Profile"
direction: bpy.props.StringProperty()
def execute(self, context):
props = bpy.context.active_object.BIMObjectProperties.material_set
index = props.active_material_profile_index
if self.direction == "UP" and index - 1 >= 0:
props.material_profiles.move(index, index - 1)
props.active_material_profile_index = index - 1
elif self.direction == "DOWN" and index + 1 < len(props.material_profiles):
props.material_profiles.move(index, index + 1)
props.active_material_profile_index = index + 1
return {"FINISHED"}
class SelectScheduleFile(bpy.types.Operator):
bl_idname = "bim.select_schedule_file"
bl_label = "Select Documentation IFC File"
@@ -2158,71 +2044,6 @@ class SetViewportShadowFromSun(bpy.types.Operator):
return {"FINISHED"}
class AssignPresentationLayer(bpy.types.Operator):
bl_idname = "bim.assign_presentation_layer"
bl_label = "Assign Presentation Layer"
index: bpy.props.IntProperty()
def execute(self, context):
layer = bpy.context.scene.BIMProperties.presentation_layers[self.index]
for obj in bpy.context.selected_objects:
if not obj.data or not hasattr(obj.data, "BIMMeshProperties"):
continue
obj.data.BIMMeshProperties.presentation_layer_index = self.index
obj.hide_set(not layer.layer_on)
return {"FINISHED"}
class UnassignPresentationLayer(bpy.types.Operator):
bl_idname = "bim.unassign_presentation_layer"
bl_label = "Unassign Presentation Layer"
def execute(self, context):
for obj in bpy.context.selected_objects:
if not obj.data or not hasattr(obj.data, "BIMMeshProperties"):
continue
obj.data.BIMMeshProperties.presentation_layer_index = -1
return {"FINISHED"}
class AddPresentationLayer(bpy.types.Operator):
bl_idname = "bim.add_presentation_layer"
bl_label = "Add Presentation Layer"
def execute(self, context):
new = bpy.context.scene.BIMProperties.presentation_layers.add()
new.name = "New Presentation Layer"
new.layer_on = True
new.layer_frozen = False
new.layer_blocked = False
return {"FINISHED"}
class RemovePresentationLayer(bpy.types.Operator):
bl_idname = "bim.remove_presentation_layer"
bl_label = "Remove Presentation Layer"
index: bpy.props.IntProperty()
def execute(self, context):
bpy.context.scene.BIMProperties.presentation_layers.remove(self.index)
return {"FINISHED"}
class UpdatePresentationLayer(bpy.types.Operator):
bl_idname = "bim.update_presentation_layer"
bl_label = "Hide/Show selected Presentation Layer"
index: bpy.props.IntProperty()
def execute(self, context):
for obj in bpy.context.scene.objects:
if not obj.data or not hasattr(obj.data, "BIMMeshProperties"):
continue
if obj.data.BIMMeshProperties.presentation_layer_index == self.index:
set_status = obj.hide_get()
obj.hide_set(not obj.hide_get())
return {"FINISHED"}
class AddDrawingStyleAttribute(bpy.types.Operator):
bl_idname = "bim.add_drawing_style_attribute"
bl_label = "Add Drawing Style Attribute"
@@ -475,14 +475,6 @@ class ClashSet(PropertyGroup):
b: CollectionProperty(name="Group B", type=ClashSource)
class PresentationLayer(PropertyGroup):
name: StringProperty(name="Name")
description: StringProperty(name="Description")
identifier: StringProperty(name="Identifier")
layer_on: BoolProperty(name="LayerOn", default=True)
layer_frozen: BoolProperty(name="LayerFrozen", default=False)
layer_blocked: BoolProperty(name="LayerBlocked", default=False)
class SmartClashGroup(PropertyGroup):
number: StringProperty(name="Number")
global_ids: CollectionProperty(name="GlobalIDs", type=StrProperty)
@@ -558,8 +550,6 @@ class BIMProperties(PropertyGroup):
override_colour: FloatVectorProperty(
name="Override Colour", subtype="COLOR", default=(1, 0, 0, 1), min=0.0, max=1.0, size=4
)
active_presentation_layer_index: IntProperty(name="Active Presentation Layer Index")
presentation_layers: CollectionProperty(name="Presentation Layers", type=PresentationLayer)
class BIMLibrary(PropertyGroup):
@@ -652,6 +642,4 @@ class BIMMeshProperties(PropertyGroup):
is_parametric: BoolProperty(name="Is Parametric", default=False)
ifc_definition: StringProperty(name="IFC Definition")
ifc_parameters: CollectionProperty(name="IFC Parameters", type=IfcParameter)
active_representation_item_index: IntProperty(name="Active Representation Item Index")
presentation_layer_index: IntProperty(name="Presentation Layer Index", default=-1)
ifc_item_ids: CollectionProperty(name="IFC Item IDs", type=ItemSlotMap)
-90
View File
@@ -37,96 +37,6 @@ class BIM_PT_object_structural(Panel):
row.prop(props, "structural_member_connection")
class BIM_PT_presentation_layer_data(Panel):
bl_label = "IFC Presentation Layers"
bl_idname = "BIM_PT_presentation"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "data"
@classmethod
def poll(cls, context):
return (
context.active_object is not None
and context.active_object.type == "MESH"
and hasattr(context.active_object.data, "BIMMeshProperties")
)
def draw(self, context):
if not context.active_object.data:
return
layout = self.layout
props = context.active_object.data.BIMMeshProperties
scene_props = context.scene.BIMProperties
if props.presentation_layer_index != -1:
layer = scene_props.presentation_layers[props.presentation_layer_index]
layout.label(text=f"Assigned to: {layer.name}")
layout.row().operator("bim.unassign_presentation_layer")
return
if not scene_props.presentation_layers:
layout.label(text=f"No presentation layers are available")
return
layout.template_list(
"BIM_UL_generic",
"",
scene_props,
"presentation_layers",
scene_props,
"active_presentation_layer_index",
)
if scene_props.active_presentation_layer_index < len(scene_props.presentation_layers):
op = layout.row().operator("bim.assign_presentation_layer")
op.index = scene_props.active_presentation_layer_index
class BIM_PT_presentation_layers(Panel):
bl_label = "IFC Presentation Layers"
bl_idname = "BIM_PT_presentation_layer"
bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
def draw(self, context):
layout = self.layout
layout.use_property_split = True
props = context.scene.BIMProperties
layout.row().operator("bim.add_presentation_layer")
if not props.presentation_layers:
return
layout.template_list(
"BIM_UL_generic", "", props, "presentation_layers", props, "active_presentation_layer_index"
)
if props.active_presentation_layer_index < len(props.presentation_layers):
layer = props.presentation_layers[props.active_presentation_layer_index]
row = layout.row(align=True)
row.prop(layer, "name")
row.operator(
"bim.remove_presentation_layer", icon="X", text=""
).index = props.active_presentation_layer_index
row = layout.row()
row.prop(layer, "description")
row = layout.row()
row.prop(layer, "identifier")
row = layout.row()
row.prop(layer, "layer_on")
row = layout.row()
row.prop(layer, "layer_frozen")
row = layout.row()
row.prop(layer, "layer_blocked")
op = layout.row().operator("bim.update_presentation_layer")
op.index = props.active_presentation_layer_index
class BIM_PT_drawings(Panel):
bl_label = "SVG Drawings"
bl_idname = "BIM_PT_drawings"