From b8ca287883d666fc8d1a3e4140d2f2a1ce04ee1e Mon Sep 17 00:00:00 2001 From: rileywong311 Date: Fri, 18 Aug 2023 17:25:29 -0700 Subject: [PATCH] Fix up convert_ifc_to_brick Remove line separation between code, but add comments Add full URI to Brick relations Fix typo where "system_uris" was written as "space_uris" Remove unnecessary get of "distribution_elements = brick.get_convertable_brick_elements()" again --- src/blenderbim/blenderbim/core/brick.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/blenderbim/blenderbim/core/brick.py b/src/blenderbim/blenderbim/core/brick.py index 167b8ae4d8..5c8cd6ee58 100644 --- a/src/blenderbim/blenderbim/core/brick.py +++ b/src/blenderbim/blenderbim/core/brick.py @@ -91,6 +91,7 @@ def add_brick_relation(brick, brick_uri=None, predicate=None, object=None): def convert_ifc_to_brick(brick, namespace=None, library=None): + # convert spaces to brick spaces = brick.get_convertable_brick_spaces() space_uris = {} for space in spaces: @@ -98,39 +99,35 @@ def convert_ifc_to_brick(brick, namespace=None, library=None): space_uris[space] = brick_uri if library: brick.run_assign_brick_reference(element=space, library=library, brick_uri=brick_uri) - for space in spaces: parent = brick.get_parent_space(space) if parent: - brick.add_relation(space_uris[parent], "hasPart", space_uris[space]) - + brick.add_relation(space_uris[parent], "https://brickschema.org/schema/Brick#hasPart", space_uris[space]) + # convert systems to brick systems = brick.get_convertable_brick_systems() system_uris = {} for system in systems: brick_uri = brick.add_brick_from_element(system, namespace, brick.get_brick_class(system)) - space_uris[space] = brick_uri + system_uris[system] = brick_uri if library: brick.run_assign_brick_reference(element=system, library=library, brick_uri=brick_uri) - + # convert services to brick distribution_elements = brick.get_convertable_brick_elements() equipment_uris = {} for element in distribution_elements: brick_uri = brick.add_brick_from_element(element, namespace, brick.get_brick_class(element)) equipment_uris[element] = brick_uri space = brick.get_element_container(element) - brick.add_relation(brick_uri, "hasLocation", space_uris[space]) + brick.add_relation(brick_uri, "https://brickschema.org/schema/Brick#hasLocation", space_uris[space]) systems = brick.get_element_systems(element) for system in systems: - brick.add_relation(system_uris[system], "hasPart", brick_uri) + brick.add_relation(system_uris[system], "https://brickschema.org/schema/Brick#hasPart", brick_uri) if library: brick.run_assign_brick_reference(element=element, library=library, brick_uri=brick_uri) - - distribution_elements = brick.get_convertable_brick_elements() for element in distribution_elements: feeds = brick.get_element_feeds(element) for downstream_equipment in feeds: - brick.add_relation(equipment_uris[element], "feeds", equipment_uris[downstream_equipment]) - + brick.add_relation(equipment_uris[element], "https://brickschema.org/schema/Brick#feeds", equipment_uris[downstream_equipment]) brick.run_refresh_brick_viewer() brick.run_refresh_brick_viewer(split_screen=True)