Hide assign class panel for representation items

This commit is contained in:
Andrej730
2024-11-06 16:26:53 +05:00
parent ecdbcff1aa
commit 5c33a66548
3 changed files with 17 additions and 9 deletions
+8 -8
View File
@@ -74,6 +74,7 @@ class AuthoringData:
cls.data["has_visible_boundaries"] = cls.has_visible_boundaries()
cls.data["active_class"] = cls.active_class()
cls.data["active_material_usage"] = cls.active_material_usage()
cls.data["is_representation_item_active"] = cls.is_representation_item_active()
cls.data["active_representation_type"] = cls.active_representation_type()
cls.data["boundary_class"] = cls.boundary_class()
cls.data["selected_material_usages"] = cls.selected_material_usages()
@@ -192,6 +193,13 @@ class AuthoringData:
if element:
return tool.Model.get_usage_type(element)
@classmethod
def is_representation_item_active(cls) -> bool:
object = bpy.context.active_object
if not object:
return False
return tool.Geometry.is_representation_item(object)
@classmethod
def active_representation_type(cls):
if active_object := tool.Blender.get_active_object():
@@ -555,7 +563,6 @@ class ItemData:
cls.data = {}
cls.data["representation_identifier"] = cls.representation_identifier()
cls.data["representation_type"] = cls.representation_type()
cls.data["is_representation_item_active"] = cls.is_representation_item_active()
@classmethod
def representation_identifier(cls):
@@ -568,10 +575,3 @@ class ItemData:
props = bpy.context.scene.BIMGeometryProperties
rep = tool.Geometry.get_active_representation(props.representation_obj)
return rep.RepresentationType
@classmethod
def is_representation_item_active(cls) -> bool:
object = bpy.context.active_object
if not object:
return False
return tool.Geometry.is_representation_item(object)
@@ -261,6 +261,8 @@ class EditItemUI:
def draw(cls, context: bpy.types.Context, layout: bpy.types.UILayout):
if not ItemData.is_loaded:
ItemData.load()
if not AuthoringData.is_loaded:
AuthoringData.load()
cls.layout = layout
row = cls.layout.row()
@@ -270,7 +272,7 @@ class EditItemUI:
row = cls.layout.row()
row.label(text="Type: " + ItemData.data["representation_type"], icon="OUTLINER_OB_MESH")
cls.layout.menu("BIM_MT_add_representation_item", icon="ADD")
if not ItemData.data["is_representation_item_active"]:
if not AuthoringData.data["is_representation_item_active"]:
return
obj = context.active_object
assert obj
+6
View File
@@ -22,6 +22,7 @@ from bpy.types import Panel
from bonsai.bim.ifc import IfcStore
from bonsai.bim.helper import prop_with_search
from bonsai.bim.module.root.data import IfcClassData
from bonsai.bim.module.model.data import AuthoringData
class BIM_PT_class(Panel):
@@ -72,6 +73,11 @@ class BIM_PT_class(Panel):
if IfcClassData.data["can_reassign_class"]:
row.operator("bim.enable_reassign_class", icon="GREASEPENCIL", text="")
else:
if not AuthoringData.is_loaded:
AuthoringData.load()
if AuthoringData.data["is_representation_item_active"]:
return
ifc_predefined_types = root_prop.get_ifc_predefined_types(context.scene.BIMRootProperties, context)
self.draw_class_dropdowns(context, ifc_predefined_types)
row = self.layout.row(align=True)