mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Hide Edit Profile for material sets without profiles #6103
This commit is contained in:
@@ -82,6 +82,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["has_extrusion"] = cls.has_extrusion()
|
||||
cls.data["is_representation_item_active"] = cls.is_representation_item_active()
|
||||
# After is_representation_item_active.
|
||||
cls.data["is_representation_item_swept_solid"] = cls.is_representation_item_swept_solid()
|
||||
@@ -247,6 +248,19 @@ class AuthoringData:
|
||||
if (obj := tool.Blender.get_active_object()) and (element := tool.Ifc.get_entity(obj)):
|
||||
return tool.Model.get_usage_type(element)
|
||||
|
||||
@classmethod
|
||||
def has_extrusion(cls) -> bool:
|
||||
if not (obj := tool.Blender.get_active_object()) or not (
|
||||
representation := tool.Geometry.get_active_representation(obj)
|
||||
):
|
||||
return False
|
||||
|
||||
# Skip representation items.
|
||||
if not representation.is_a("IfcShapeRepresentation"):
|
||||
return False
|
||||
|
||||
return bool(tool.Model.get_extrusion(representation))
|
||||
|
||||
@classmethod
|
||||
def is_representation_item_active(cls) -> bool:
|
||||
if not (obj := tool.Blender.get_active_object()):
|
||||
|
||||
@@ -1053,7 +1053,7 @@ class EditObjectUI:
|
||||
row.label(text="Mode") if ui_context != "TOOL_HEADER" else row
|
||||
|
||||
if AuthoringData.data["active_material_usage"] == "LAYER3":
|
||||
if len(context.selected_objects) == 1:
|
||||
if len(context.selected_objects) == 1 and AuthoringData.data["has_extrusion"]:
|
||||
row = cls.layout.row(align=True) if ui_context != "TOOL_HEADER" else row
|
||||
add_layout_hotkey_operator(row, "Edit Profile", "S_E", "", ui_context)
|
||||
elif (
|
||||
@@ -1242,7 +1242,11 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
if self.active_material_usage == "LAYER3":
|
||||
# Edit LAYER3 profile
|
||||
if bpy.context.active_object and bpy.context.active_object.mode == "OBJECT":
|
||||
if (
|
||||
active_object.mode == "OBJECT"
|
||||
and (representation := tool.Geometry.get_active_representation(active_object))
|
||||
and tool.Model.get_extrusion(representation)
|
||||
):
|
||||
bpy.ops.bim.enable_editing_extrusion_profile()
|
||||
elif self.active_material_usage == "LAYER2":
|
||||
# Extend LAYER2 to cursor
|
||||
|
||||
@@ -484,7 +484,7 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
|
||||
@classmethod
|
||||
def get_active_representation(cls, obj: bpy.types.Object) -> Union[ifcopenshell.entity_instance, None]:
|
||||
"""< IfcShapeRepresentation or None"""
|
||||
""":return: IfcRepresentation/IfcRepresentationItem or None"""
|
||||
if obj.data and hasattr(obj.data, "BIMMeshProperties") and obj.data.BIMMeshProperties.ifc_definition_id:
|
||||
return tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user