(
element: ifcopenshell.entity_instance, obj: Union[IFC_CONNECTED_TYPE, tool.Geometry.TYPES_WITH_MESH_PROPERTIES]
)
| 267 | |
| 268 | @staticmethod |
| 269 | def link_element( |
| 270 | element: ifcopenshell.entity_instance, obj: Union[IFC_CONNECTED_TYPE, tool.Geometry.TYPES_WITH_MESH_PROPERTIES] |
| 271 | ) -> None: |
| 272 | # Please use tool.Ifc.link() instead of this method. We want to |
| 273 | # refactor this class and deprecate usage of IfcStore in favour of |
| 274 | # tools. |
| 275 | if not isinstance(obj, (bpy.types.Object, bpy.types.Material)): |
| 276 | tool.Geometry.get_mesh_props(obj).ifc_definition_id = element.id() |
| 277 | return |
| 278 | |
| 279 | existing_obj = IfcStore.id_map.get(element.id(), None) |
| 280 | if existing_obj == obj: |
| 281 | return |
| 282 | # TODO: When does this occur? |
| 283 | elif existing_obj and tool.Blender.is_valid_data_block(existing_obj): |
| 284 | IfcStore.unlink_element(obj=existing_obj) |
| 285 | |
| 286 | IfcStore.id_map[element.id()] = obj |
| 287 | if global_id := getattr(element, "GlobalId", None): |
| 288 | IfcStore.guid_map[global_id] = obj |
| 289 | |
| 290 | if element.is_a("IfcSurfaceStyle"): |
| 291 | props = tool.Style.get_material_style_props(obj) |
| 292 | props.ifc_definition_id = element.id() |
| 293 | else: |
| 294 | props = tool.Blender.get_object_bim_props(obj) |
| 295 | props.ifc_definition_id = element.id() |
| 296 | |
| 297 | tool.Ifc.setup_listeners(obj) |
| 298 | |
| 299 | if IfcStore.history: |
| 300 | data = OperationData(id=element.id(), obj=obj.name) |
| 301 | if global_id: |
| 302 | data["guid"] = global_id |
| 303 | IfcStore.history[-1]["operations"].append( |
| 304 | Operation(rollback=IfcStore.rollback_link_element, commit=IfcStore.commit_link_element, data=data) |
| 305 | ) |
| 306 | |
| 307 | @staticmethod |
| 308 | def get_object_by_name(name: str) -> Union[IFC_CONNECTED_TYPE, None]: |
no test coverage detected