mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-06 12:26:26 +00:00
Load Brick relationships from schema
This commit is contained in:
@@ -56,15 +56,7 @@ def get_brick_roots(self, context):
|
|||||||
|
|
||||||
|
|
||||||
def get_brick_relations(self, context): # this will be queried from graph
|
def get_brick_relations(self, context): # this will be queried from graph
|
||||||
return [("https://brickschema.org/schema/Brick#hasLocation", "hasLocation", ""),
|
return BrickStore.relationships
|
||||||
("https://brickschema.org/schema/Brick#isLocationOf", "isLocationOf", ""),
|
|
||||||
("https://brickschema.org/schema/Brick#hasPart", "hasPart", ""),
|
|
||||||
("https://brickschema.org/schema/Brick#isPartOf", "isPartOf", ""),
|
|
||||||
("https://brickschema.org/schema/Brick#hasPoint", "hasPoint", ""),
|
|
||||||
("https://brickschema.org/schema/Brick#isPointOf", "isPointOf", ""),
|
|
||||||
("https://brickschema.org/schema/Brick#feeds", "feeds", ""),
|
|
||||||
("https://brickschema.org/schema/Brick#isFedBy", "isFedBy", ""),
|
|
||||||
("http://www.w3.org/2000/01/rdf-schema#label", "label", "")]
|
|
||||||
|
|
||||||
|
|
||||||
class Brick(PropertyGroup):
|
class Brick(PropertyGroup):
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
BrickStore.path = filepath
|
BrickStore.path = filepath
|
||||||
BrickStore.load_namespaces()
|
BrickStore.load_namespaces()
|
||||||
BrickStore.load_entity_classes()
|
BrickStore.load_entity_classes()
|
||||||
|
BrickStore.load_relationships()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new_brick_file(cls):
|
def new_brick_file(cls):
|
||||||
@@ -298,6 +299,7 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
BrickStore.graph.bind("digitaltwin", Namespace("https://example.org/digitaltwin#"))
|
BrickStore.graph.bind("digitaltwin", Namespace("https://example.org/digitaltwin#"))
|
||||||
BrickStore.load_namespaces()
|
BrickStore.load_namespaces()
|
||||||
BrickStore.load_entity_classes()
|
BrickStore.load_entity_classes()
|
||||||
|
BrickStore.load_relationships()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def pop_brick_breadcrumb(cls):
|
def pop_brick_breadcrumb(cls):
|
||||||
@@ -363,6 +365,7 @@ class BrickStore:
|
|||||||
namespaces = []
|
namespaces = []
|
||||||
root_classes = ["Equipment", "Location", "System", "Point"]
|
root_classes = ["Equipment", "Location", "System", "Point"]
|
||||||
entity_classes = {}
|
entity_classes = {}
|
||||||
|
relationships = []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def purge():
|
def purge():
|
||||||
@@ -371,6 +374,7 @@ class BrickStore:
|
|||||||
BrickStore.path = None
|
BrickStore.path = None
|
||||||
BrickStore.namespaces = []
|
BrickStore.namespaces = []
|
||||||
BrickStore.entity_classes = {}
|
BrickStore.entity_classes = {}
|
||||||
|
BrickStore.relationships = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_project(cls):
|
def get_project(cls):
|
||||||
@@ -407,6 +411,20 @@ class BrickStore:
|
|||||||
for uri in sorted([x[0].toPython() for x in query]):
|
for uri in sorted([x[0].toPython() for x in query]):
|
||||||
BrickStore.entity_classes[root_class].append((uri, uri.split("#")[-1], ""))
|
BrickStore.entity_classes[root_class].append((uri, uri.split("#")[-1], ""))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load_relationships(cls):
|
||||||
|
query = BrickStore.graph.query(
|
||||||
|
"""
|
||||||
|
PREFIX brick: <https://brickschema.org/schema/Brick#>
|
||||||
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
|
SELECT DISTINCT ?relation WHERE {
|
||||||
|
?relation rdfs:subPropertyOf brick:Relationship .
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
for uri in sorted([x[0].toPython() for x in query]):
|
||||||
|
BrickStore.relationships.append((uri, uri.split("#")[-1], ""))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_history_size(cls, size):
|
def set_history_size(cls, size):
|
||||||
cls.history_size = size
|
cls.history_size = size
|
||||||
|
|||||||
Reference in New Issue
Block a user