mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-20 04:04:00 +00:00
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:
@@ -2582,11 +2582,7 @@ class UpdateItemAttributes(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
props = obj.data.BIMMeshProperties
|
tool.Geometry.update_item_attributes(obj)
|
||||||
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.reload_representation(bpy.context.scene.BIMGeometryProperties.representation_obj)
|
tool.Geometry.reload_representation(bpy.context.scene.BIMGeometryProperties.representation_obj)
|
||||||
tool.Geometry.import_item(obj)
|
tool.Geometry.import_item(obj)
|
||||||
tool.Root.reload_item_decorator()
|
tool.Root.reload_item_decorator()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import bonsai.bim
|
|||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
import bonsai.core.model as core
|
import bonsai.core.model as core
|
||||||
from bonsai.bim.module.model.wall import DumbWallJoiner
|
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 bpy.types import WorkSpaceTool, Menu
|
||||||
from bonsai.bim.module.model.data import AuthoringData, ItemData
|
from bonsai.bim.module.model.data import AuthoringData, ItemData
|
||||||
from bonsai.bim.module.system.data import PortData
|
from bonsai.bim.module.system.data import PortData
|
||||||
@@ -278,7 +278,7 @@ class EditItemUI:
|
|||||||
assert obj
|
assert obj
|
||||||
for item_attribute in obj.data.BIMMeshProperties.item_attributes:
|
for item_attribute in obj.data.BIMMeshProperties.item_attributes:
|
||||||
row = cls.layout.row()
|
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):
|
if len(obj.data.BIMMeshProperties.item_attributes):
|
||||||
row = cls.layout.row()
|
row = cls.layout.row()
|
||||||
row.operator("bim.update_item_attributes", icon="FILE_REFRESH", text="")
|
row.operator("bim.update_item_attributes", icon="FILE_REFRESH", text="")
|
||||||
|
|||||||
@@ -1539,12 +1539,27 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
props = obj.data.BIMMeshProperties
|
props = obj.data.BIMMeshProperties
|
||||||
props.item_attributes.clear()
|
props.item_attributes.clear()
|
||||||
item = tool.Ifc.get().by_id(props.ifc_definition_id)
|
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: Attribute = props.item_attributes.add()
|
||||||
new.name = "Depth"
|
attr_name = attribute.name()
|
||||||
|
new.name = attr_name
|
||||||
new.data_type = "float"
|
new.data_type = "float"
|
||||||
new.special_type = "LENGTH"
|
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
|
@classmethod
|
||||||
def import_item(cls, obj: bpy.types.Object) -> None:
|
def import_item(cls, obj: bpy.types.Object) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user