mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
Show info message when trying to edit presentation layer and project has no layers #6051
Instead of the error. Also fix a bug with update callback was attached to the wrong prop.
This commit is contained in:
@@ -177,8 +177,15 @@ class ShapeAspect(PropertyGroup):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def update_is_editing_representation_layer(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> None:
|
def update_is_adding_representation_layer(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> None:
|
||||||
if self.is_adding_representation_layer:
|
if self.is_adding_representation_layer:
|
||||||
|
ifc_file = tool.Ifc.get()
|
||||||
|
if not ifc_file.by_type("IfcPresentationLayerAssignment"):
|
||||||
|
tool.Blender.show_info_message(
|
||||||
|
"Cannot edit presentation layer - no presentation layers found in the project."
|
||||||
|
)
|
||||||
|
del self["is_adding_representation_layer"]
|
||||||
|
return
|
||||||
return
|
return
|
||||||
|
|
||||||
if "representation_layer" in self:
|
if "representation_layer" in self:
|
||||||
@@ -189,12 +196,19 @@ def update_is_editing_representation_layer(self: "BIMObjectGeometryProperties",
|
|||||||
def update_is_editing_item_layer(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> None:
|
def update_is_editing_item_layer(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> None:
|
||||||
if self.is_editing_item_layer:
|
if self.is_editing_item_layer:
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
|
|
||||||
|
if not ifc_file.by_type("IfcPresentationLayerAssignment"):
|
||||||
|
tool.Blender.show_info_message(
|
||||||
|
"Cannot edit presentation layer - no presentation layers found in the project."
|
||||||
|
)
|
||||||
|
del self["is_editing_item_layer"]
|
||||||
|
return
|
||||||
|
|
||||||
active_ui_item = self.active_item
|
active_ui_item = self.active_item
|
||||||
assert active_ui_item
|
assert active_ui_item
|
||||||
item = ifc_file.by_id(active_ui_item.ifc_definition_id)
|
item = ifc_file.by_id(active_ui_item.ifc_definition_id)
|
||||||
if layer := next(iter(item.LayerAssignment), None):
|
if layer := next(iter(item.LayerAssignment), None):
|
||||||
self.representation_item_layer = str(layer.id())
|
self.representation_item_layer = str(layer.id())
|
||||||
return
|
|
||||||
|
|
||||||
if "representation_item_layer" in self:
|
if "representation_item_layer" in self:
|
||||||
del self["representation_item_layer"]
|
del self["representation_item_layer"]
|
||||||
@@ -208,12 +222,12 @@ class BIMObjectGeometryProperties(PropertyGroup):
|
|||||||
name="Is Adding Representation's Layer",
|
name="Is Adding Representation's Layer",
|
||||||
description="Toggle adding presentation layer for the representation.",
|
description="Toggle adding presentation layer for the representation.",
|
||||||
default=False,
|
default=False,
|
||||||
|
update=update_is_adding_representation_layer,
|
||||||
)
|
)
|
||||||
representation_layer: EnumProperty(
|
representation_layer: EnumProperty(
|
||||||
items=get_layers_no_active,
|
items=get_layers_no_active,
|
||||||
name="Representation's Presentation Layer",
|
name="Representation's Presentation Layer",
|
||||||
description="Presentation layer to add.",
|
description="Presentation layer to add.",
|
||||||
update=update_is_editing_representation_layer,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Representation items UI.
|
# Representation items UI.
|
||||||
|
|||||||
Reference in New Issue
Block a user