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
This commit is contained in:
rileywong311
2023-08-18 17:25:29 -07:00
committed by Riley Wong
parent 52f3392ece
commit b8ca287883
+8 -11
View File
@@ -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)