Edit other representation item attributes besides IfcSweptSolid depth

Examples:
- https://imgchest.com/p/qb4zjgbklyj
- https://imgchest.com/p/lqye68r2k4d

Added this feature in a very experiment way, I'm sure it will break very soon and we'll be able to refine it.
This commit is contained in:
Andrej730
2024-11-06 17:50:27 +05:00
parent 9a77222017
commit bbca07d535
3 changed files with 21 additions and 10 deletions
@@ -2582,11 +2582,7 @@ class UpdateItemAttributes(bpy.types.Operator, tool.Ifc.Operator):
def _execute(self, context):
obj = context.active_object
props = obj.data.BIMMeshProperties
item = tool.Ifc.get().by_id(props.ifc_definition_id)
for attribute in props.item_attributes:
if attribute.name == "Depth":
item.Depth = attribute.float_value
tool.Geometry.update_item_attributes(obj)
tool.Geometry.reload_representation(bpy.context.scene.BIMGeometryProperties.representation_obj)
tool.Geometry.import_item(obj)
tool.Root.reload_item_decorator()
@@ -24,7 +24,7 @@ import bonsai.bim
import bonsai.tool as tool
import bonsai.core.model as core
from bonsai.bim.module.model.wall import DumbWallJoiner
from bonsai.bim.helper import prop_with_search
from bonsai.bim.helper import prop_with_search, draw_attribute
from bpy.types import WorkSpaceTool, Menu
from bonsai.bim.module.model.data import AuthoringData, ItemData
from bonsai.bim.module.system.data import PortData
@@ -278,7 +278,7 @@ class EditItemUI:
assert obj
for item_attribute in obj.data.BIMMeshProperties.item_attributes:
row = cls.layout.row()
row.prop(item_attribute, item_attribute.get_value_name(display_only=True), text=item_attribute.name)
draw_attribute(item_attribute, cls.layout)
if len(obj.data.BIMMeshProperties.item_attributes):
row = cls.layout.row()
row.operator("bim.update_item_attributes", icon="FILE_REFRESH", text="")
+18 -3
View File
@@ -1539,12 +1539,27 @@ class Geometry(bonsai.core.tool.Geometry):
props = obj.data.BIMMeshProperties
props.item_attributes.clear()
item = tool.Ifc.get().by_id(props.ifc_definition_id)
if item.is_a("IfcExtrudedAreaSolid"):
attributes = item.wrapped_data.declaration().as_entity().all_attributes()
for attribute in attributes:
if not attribute.type_of_attribute()._is("IfcLengthMeasure"):
continue
new: Attribute = props.item_attributes.add()
new.name = "Depth"
attr_name = attribute.name()
new.name = attr_name
new.data_type = "float"
new.special_type = "LENGTH"
new.float_value = item.Depth
value = getattr(item, attr_name)
is_null = value is None
new.is_null = is_null
new.float_value = 0.0 if is_null else value
new.is_optional = attribute.optional()
@classmethod
def update_item_attributes(cls, obj: bpy.types.Object) -> None:
props = obj.data.BIMMeshProperties
item = tool.Ifc.get().by_id(props.ifc_definition_id)
for attribute in props.item_attributes:
setattr(item, attribute.name, attribute.get_value())
@classmethod
def import_item(cls, obj: bpy.types.Object) -> None: