mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-06 12:26:26 +00:00
Move brick entity classes to BrickStore and create drop-down for entity type creation
This commit is contained in:
@@ -42,7 +42,6 @@ class BrickschemaData:
|
|||||||
cls.data = {
|
cls.data = {
|
||||||
"is_loaded": cls.get_is_loaded(),
|
"is_loaded": cls.get_is_loaded(),
|
||||||
"attributes": cls.attributes(),
|
"attributes": cls.attributes(),
|
||||||
"brick_equipment_classes": cls.brick_equipment_classes(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -103,24 +102,6 @@ class BrickschemaData:
|
|||||||
)
|
)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def brick_equipment_classes(cls):
|
|
||||||
if BrickStore.graph is None:
|
|
||||||
return []
|
|
||||||
results = []
|
|
||||||
query = BrickStore.graph.query(
|
|
||||||
"""
|
|
||||||
PREFIX brick: <https://brickschema.org/schema/Brick#>
|
|
||||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
|
||||||
SELECT ?class WHERE {
|
|
||||||
?class rdfs:subClassOf* brick:Equipment .
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
for uri in sorted([x[0].toPython() for x in query]):
|
|
||||||
results.append((uri, uri.split("#")[-1], ""))
|
|
||||||
return results
|
|
||||||
|
|
||||||
|
|
||||||
class BrickschemaReferencesData:
|
class BrickschemaReferencesData:
|
||||||
data = {}
|
data = {}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class AddBrick(bpy.types.Operator, Operator):
|
|||||||
tool.Brick,
|
tool.Brick,
|
||||||
element=tool.Ifc.get_entity(context.active_object) if context.selected_objects else None,
|
element=tool.Ifc.get_entity(context.active_object) if context.selected_objects else None,
|
||||||
namespace=props.namespace,
|
namespace=props.namespace,
|
||||||
brick_class=props.brick_equipment_class,
|
brick_class=props.brick_entity_classes,
|
||||||
library=library,
|
library=library,
|
||||||
label=props.new_brick_label,
|
label=props.new_brick_label,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -46,10 +46,9 @@ def get_namespaces(self, context):
|
|||||||
return BrickStore.namespaces
|
return BrickStore.namespaces
|
||||||
|
|
||||||
|
|
||||||
def get_brick_equipment_classes(self, context):
|
def get_brick_entity_classes(self, context):
|
||||||
if not BrickschemaData.is_loaded:
|
entity = context.scene.BIMBrickProperties.brick_entity_create_type
|
||||||
BrickschemaData.load()
|
return BrickStore.entity_classes[entity]
|
||||||
return BrickschemaData.data["brick_equipment_classes"]
|
|
||||||
|
|
||||||
|
|
||||||
def get_brick_roots(self, context):
|
def get_brick_roots(self, context):
|
||||||
@@ -74,9 +73,10 @@ class BIMBrickProperties(PropertyGroup):
|
|||||||
active_brick_index: IntProperty(name="Active Brick Index", update=update_active_brick_index)
|
active_brick_index: IntProperty(name="Active Brick Index", update=update_active_brick_index)
|
||||||
libraries: EnumProperty(name="Libraries", items=get_libraries)
|
libraries: EnumProperty(name="Libraries", items=get_libraries)
|
||||||
namespace: EnumProperty(name="Namespace", items=get_namespaces)
|
namespace: EnumProperty(name="Namespace", items=get_namespaces)
|
||||||
brick_equipment_class: EnumProperty(name="Brick Equipment Class", items=get_brick_equipment_classes)
|
brick_entity_classes: EnumProperty(name="Brick Equipment Class", items=get_brick_entity_classes)
|
||||||
brick_settings_toggled: BoolProperty(name="Brick Settings Toggled", default=False)
|
brick_settings_toggled: BoolProperty(name="Brick Settings Toggled", default=False)
|
||||||
new_brick_label: StringProperty(name="New Brick Label")
|
new_brick_label: StringProperty(name="New Brick Label")
|
||||||
new_brick_namespace_alias: StringProperty(name="New Brick Namespace Alias")
|
new_brick_namespace_alias: StringProperty(name="New Brick Namespace Alias")
|
||||||
new_brick_namespace_uri: StringProperty(name="New Brick Namespace URI")
|
new_brick_namespace_uri: StringProperty(name="New Brick Namespace URI")
|
||||||
brick_list_root: EnumProperty(name="Brick List Root", items=get_brick_roots)
|
brick_list_root: EnumProperty(name="Brick List Root", items=get_brick_roots)
|
||||||
|
brick_entity_create_type: EnumProperty(name="Brick Entity Types", items=get_brick_roots)
|
||||||
@@ -82,9 +82,13 @@ class BIM_PT_brickschema(Panel):
|
|||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text="Create Entity:")
|
row.label(text="Create Entity:")
|
||||||
|
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.prop(data=self.props, property="brick_entity_create_type", text="")
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.prop(data=self.props, property="new_brick_label", text="")
|
row.prop(data=self.props, property="new_brick_label", text="")
|
||||||
prop_with_search(row, self.props, "brick_equipment_class", text="")
|
prop_with_search(row, self.props, "brick_entity_classes", text="")
|
||||||
row.operator("bim.add_brick", text="", icon="ADD")
|
row.operator("bim.add_brick", text="", icon="ADD")
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
|
|||||||
@@ -269,6 +269,7 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
cs.load_file(filepath)
|
cs.load_file(filepath)
|
||||||
BrickStore.path = filepath
|
BrickStore.path = filepath
|
||||||
BrickStore.load_namespaces()
|
BrickStore.load_namespaces()
|
||||||
|
BrickStore.load_entity_classes()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new_brick_file(cls):
|
def new_brick_file(cls):
|
||||||
@@ -280,6 +281,7 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
cs.load_file(BrickStore.schema)
|
cs.load_file(BrickStore.schema)
|
||||||
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()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def pop_brick_breadcrumb(cls):
|
def pop_brick_breadcrumb(cls):
|
||||||
@@ -343,6 +345,7 @@ class BrickStore:
|
|||||||
current_changesets = 0
|
current_changesets = 0
|
||||||
history_size = 64
|
history_size = 64
|
||||||
namespaces = []
|
namespaces = []
|
||||||
|
entity_classes = {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def purge():
|
def purge():
|
||||||
@@ -350,6 +353,7 @@ class BrickStore:
|
|||||||
BrickStore.graph = None
|
BrickStore.graph = None
|
||||||
BrickStore.path = None
|
BrickStore.path = None
|
||||||
BrickStore.namespaces = []
|
BrickStore.namespaces = []
|
||||||
|
BrickStore.entity_classes = {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_project(cls):
|
def get_project(cls):
|
||||||
@@ -368,6 +372,25 @@ class BrickStore:
|
|||||||
if not ignore_namespace:
|
if not ignore_namespace:
|
||||||
BrickStore.namespaces.append((uri, f"{alias}: {uri}", ""))
|
BrickStore.namespaces.append((uri, f"{alias}: {uri}", ""))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load_entity_classes(cls):
|
||||||
|
root_classes = ["System", "Location", "Equipment", "Point"]
|
||||||
|
for root_class in root_classes:
|
||||||
|
query = BrickStore.graph.query(
|
||||||
|
"""
|
||||||
|
PREFIX brick: <https://brickschema.org/schema/Brick#>
|
||||||
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
|
SELECT ?class WHERE {
|
||||||
|
?class rdfs:subClassOf* brick:{root_class} .
|
||||||
|
}
|
||||||
|
""".replace(
|
||||||
|
"{root_class}", root_class
|
||||||
|
)
|
||||||
|
)
|
||||||
|
BrickStore.entity_classes[root_class] = []
|
||||||
|
for uri in sorted([x[0].toPython() for x in query]):
|
||||||
|
BrickStore.entity_classes[root_class].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