mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 12:07:59 +00:00
Use helper.import_attributes for representation item attributes
This commit is contained in:
@@ -43,6 +43,7 @@ import bonsai.core.spatial
|
|||||||
import bonsai.core.style
|
import bonsai.core.style
|
||||||
import bonsai.core.system
|
import bonsai.core.system
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
|
import bonsai.bim.helper
|
||||||
import bonsai.bim.import_ifc
|
import bonsai.bim.import_ifc
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from math import radians, pi
|
from math import radians, pi
|
||||||
@@ -1539,20 +1540,18 @@ 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)
|
||||||
attributes = item.wrapped_data.declaration().as_entity().all_attributes()
|
allowed_attributes = [
|
||||||
for attribute in attributes:
|
a.name()
|
||||||
if not attribute.type_of_attribute()._is("IfcLengthMeasure"):
|
for a in item.wrapped_data.declaration().as_entity().all_attributes()
|
||||||
continue
|
if a.type_of_attribute()._is("IfcLengthMeasure")
|
||||||
new: Attribute = props.item_attributes.add()
|
]
|
||||||
attr_name = attribute.name()
|
|
||||||
new.name = attr_name
|
def callback(attr_name: str, *_) -> Union[None, Literal[False]]:
|
||||||
new.data_type = "float"
|
if attr_name not in allowed_attributes:
|
||||||
new.special_type = "LENGTH"
|
return False
|
||||||
value = getattr(item, attr_name)
|
return None
|
||||||
is_null = value is None
|
|
||||||
new.is_null = is_null
|
bonsai.bim.helper.import_attributes2(item, props.item_attributes, callback=callback)
|
||||||
new.float_value = 0.0 if is_null else value
|
|
||||||
new.is_optional = attribute.optional()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_item_attributes(cls, obj: bpy.types.Object) -> None:
|
def update_item_attributes(cls, obj: bpy.types.Object) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user