Skip to content

Commit a884eb5

Browse files
committed
Add "rdfs:label" to Brick relation options
This is a tricky one because "rdfs:label" cannot really be queried from the Brick ontology, so it is a special case that probably needs to get added manually. Furthermore, an entity really shouldn't have multiple labels, so the option to give an entity an "rdfs:label" should only appear if it doesn't have one already. The way I did it meant I had to manually reset the Enum type in Blender because it was the active one selection and made the Enum blank since it got removed now that the entity has a "rdfs:label." One possible alternative solution is to allow multiple labels, but in the query to import bricks in the UI list only select one label somehow.
1 parent 796d19a commit a884eb5

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/blenderbim/blenderbim/bim/module/brick/prop.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ def get_brick_roots(self, context):
5555
return [(root, root, "") for root in BrickStore.root_classes]
5656

5757

58-
def get_brick_relations(self, context): # this will be queried from graph
58+
def get_brick_relations(self, context):
59+
def is_label(relation):
60+
return relation["predicate_name"] == "label"
61+
if not list(filter(is_label, BrickschemaData.data["active_relations"])):
62+
new_relations = BrickStore.relationships.copy()
63+
new_relations.append(("http://www.w3.org/2000/01/rdf-schema#label", "label", ""))
64+
return new_relations
5965
return BrickStore.relationships
6066

6167

src/blenderbim/blenderbim/bim/module/brick/ui.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ def draw(self, context):
122122
col.alignment = "RIGHT"
123123
row.prop(data=self.props, property="split_screen_toggled", text="", icon="WINDOW")
124124

125-
row = self.layout.row(align=True)
126-
prop_with_search(row, self.props, "new_brick_relation_namespace", text="")
125+
if not self.props.new_brick_relation_type == "http://www.w3.org/2000/01/rdf-schema#label":
126+
row = self.layout.row(align=True)
127+
prop_with_search(row, self.props, "new_brick_relation_namespace", text="")
127128

128129
row = self.layout.row(align=True)
129130
prop_with_search(row, self.props, "new_brick_relation_type", text="")

src/blenderbim/blenderbim/tool/brick.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ def add_brickifc_reference(cls, brick, element, project):
101101

102102
@classmethod
103103
def add_relation(cls, brick_uri, predicate, namespace, object):
104+
if predicate == "http://www.w3.org/2000/01/rdf-schema#label":
105+
with BrickStore.new_changeset() as cs:
106+
cs.add((URIRef(brick_uri), URIRef(predicate), Literal(object)))
107+
bpy.context.scene.BIMBrickProperties.new_brick_relation_type = BrickStore.relationships[0][0]
108+
bpy.context.scene.BIMBrickProperties.add_relation_failed = False
109+
return
104110
object_uri = namespace + object
105111
query = BrickStore.graph.query(
106112
"ASK { <{object_uri}> ?predicate ?object . }".replace(

0 commit comments

Comments
 (0)