Also support changing profile for other sweptsolids

E.g. changing it for IfcRevolvedAreaSolid - https://imgur.com/a/jHOC8rt
This commit is contained in:
Andrej730
2025-01-21 17:53:12 +05:00
parent c72f17068c
commit 5ca615114f
3 changed files with 27 additions and 13 deletions
@@ -81,6 +81,9 @@ class AuthoringData:
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()
# After is_representation_item_active.
cls.data["is_representation_item_swept_solid"] = cls.is_representation_item_swept_solid()
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()
@@ -246,6 +249,13 @@ class AuthoringData:
return False
return tool.Geometry.is_representation_item(obj)
@classmethod
def is_representation_item_swept_solid(cls) -> bool:
if not cls.data["is_representation_item_active"]:
return False
assert (obj := bpy.context.active_object) and (item := tool.Geometry.get_representation_item(obj))
return item.is_a("IfcSweptAreaSolid")
@classmethod
def active_representation_type(cls):
if active_object := tool.Blender.get_active_object():
@@ -284,7 +284,9 @@ class EditItemUI:
assert obj
mesh_props = obj.data.BIMMeshProperties
if cls.get_item_object_class(obj) == "IfcExtrudedAreaSolid":
if AuthoringData.data["is_representation_item_swept_solid"]:
# TODO: support EndSweptArea for IfcRevolvedAreaSolidTapered,
# will need to add second attribute for this.
row = cls.layout.row(align=True)
row.prop(mesh_props, "item_profile")
if mesh_props.item_profile == "-":
@@ -294,14 +296,10 @@ class EditItemUI:
for item_attribute in obj.data.BIMMeshProperties.item_attributes:
row = cls.layout.row()
draw_attribute(item_attribute, cls.layout)
if len(obj.data.BIMMeshProperties.item_attributes):
if len(obj.data.BIMMeshProperties.item_attributes) or AuthoringData.data["is_representation_item_swept_solid"]:
row = cls.layout.row()
row.operator("bim.update_item_attributes", icon="FILE_REFRESH", text="")
@classmethod
def get_item_object_class(cls, obj: bpy.types.Object) -> str:
return obj.name.split("/")[1]
class BIM_MT_add_representation_item(Menu):
bl_idname = "BIM_MT_add_representation_item"
+13 -7
View File
@@ -971,13 +971,19 @@ class Geometry(bonsai.core.tool.Geometry):
)
@classmethod
def is_representation_item(cls, obj: bpy.types.Object) -> bool:
return bool(
(data := obj.data)
and isinstance(data, Geometry.TYPES_WITH_MESH_PROPERTIES)
def get_representation_item(cls, obj: bpy.types.Object) -> Union[ifcopenshell.entity_instance, None]:
data = obj.data
if (
isinstance(data, Geometry.TYPES_WITH_MESH_PROPERTIES)
and (ifc_id := data.BIMMeshProperties.ifc_definition_id)
and tool.Ifc.get().by_id(ifc_id).is_a("IfcRepresentationItem")
)
and ((item := tool.Ifc.get().by_id(ifc_id)).is_a("IfcRepresentationItem"))
):
return item
return None
@classmethod
def is_representation_item(cls, obj: bpy.types.Object) -> bool:
return bool(cls.get_representation_item(obj))
@classmethod
def get_active_or_representation_obj(cls) -> bpy.types.Object | None:
@@ -1677,7 +1683,7 @@ class Geometry(bonsai.core.tool.Geometry):
bonsai.bim.helper.import_attributes2(item, props.item_attributes, callback=callback)
profile = None
if item.is_a("IfcExtrudedAreaSolid"):
if item.is_a("IfcSweptAreaSolid"):
profile = item.SweptArea
if profile is None or profile.ProfileName is None:
item_profile = "-"