Fix #2285. You can now get all the elements in a presentation layer.

This commit is contained in:
Dion Moult
2023-01-12 12:28:09 +11:00
parent d1a40d129f
commit ba7741fef5
5 changed files with 183 additions and 31 deletions
@@ -20,14 +20,15 @@ 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.DisableEditingLayer,
operator.DisableLayerEditingUI,
operator.EditPresentationLayer,
operator.EnableEditingLayer,
operator.LoadLayers,
operator.RemovePresentationLayer,
operator.SelectLayerProducts,
operator.UnassignPresentationLayer,
prop.Layer,
prop.BIMLayerProperties,
@@ -18,9 +18,11 @@
import bpy
import json
import ifcopenshell.util.attribute
import ifcopenshell.api
import ifcopenshell.util.element
import ifcopenshell.util.attribute
import blenderbim.bim.helper
import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.layer.data import Data
@@ -182,3 +184,19 @@ class UnassignPresentationLayer(bpy.types.Operator):
)
Data.load(IfcStore.get_file())
return {"FINISHED"}
class SelectLayerProducts(bpy.types.Operator):
bl_idname = "bim.select_layer_products"
bl_label = "Select Layer Products"
bl_options = {"REGISTER", "UNDO"}
layer: bpy.props.IntProperty()
def execute(self, context):
elements = ifcopenshell.util.element.get_elements_by_layer(tool.Ifc.get(), tool.Ifc.get().by_id(self.layer))
for obj in context.visible_objects:
obj.select_set(False)
element = tool.Ifc.get_entity(obj)
if element and element in elements:
obj.select_set(True)
return {"FINISHED"}
@@ -91,11 +91,17 @@ class BIM_UL_layers(UIList):
row.operator("bim.disable_editing_layer", text="", icon="FREEZE", emboss=False)
if context.scene.BIMLayerProperties.active_layer_id == item.ifc_definition_id:
op = row.operator("bim.select_layer_products", text="", icon="RESTRICT_SELECT_OFF")
op.layer = item.ifc_definition_id
row.operator("bim.edit_presentation_layer", text="", icon="CHECKMARK")
row.operator("bim.disable_editing_layer", text="", icon="CANCEL")
elif context.scene.BIMLayerProperties.active_layer_id:
op = row.operator("bim.select_layer_products", text="", icon="RESTRICT_SELECT_OFF")
op.layer = item.ifc_definition_id
row.operator("bim.remove_presentation_layer", text="", icon="X").layer = item.ifc_definition_id
else:
op = row.operator("bim.select_layer_products", text="", icon="RESTRICT_SELECT_OFF")
op.layer = item.ifc_definition_id
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