diff --git a/src/blenderbim/blenderbim/bim/module/brick/__init__.py b/src/blenderbim/blenderbim/bim/module/brick/__init__.py index c3bb7f5c12..f2f3e03d6f 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/brick/__init__.py @@ -35,6 +35,7 @@ classes = ( operator.ViewBrickItem, operator.SerializeBrick, operator.AddBrickNamespace, + operator.SetBrickListRoot, prop.Brick, prop.BIMBrickProperties, ui.BIM_PT_brickschema, diff --git a/src/blenderbim/blenderbim/bim/module/brick/operator.py b/src/blenderbim/blenderbim/bim/module/brick/operator.py index a9950bdc24..966a97e801 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/operator.py +++ b/src/blenderbim/blenderbim/bim/module/brick/operator.py @@ -40,7 +40,8 @@ class LoadBrickProject(bpy.types.Operator, Operator): filter_glob: bpy.props.StringProperty(default="*.ttl", options={"HIDDEN"}) def _execute(self, context): - core.load_brick_project(tool.Brick, filepath=self.filepath) + root = context.scene.BIMBrickProperties.brick_list_root + core.load_brick_project(tool.Brick, filepath=self.filepath, brick_root=root) def invoke(self, context, event): context.window_manager.fileselect_add(self) @@ -180,7 +181,8 @@ class NewBrickFile(bpy.types.Operator): return {"FINISHED"} def _execute(self, context): - core.new_brick_file(tool.Brick) + root = context.scene.BIMBrickProperties.brick_list_root + core.new_brick_file(tool.Brick, brick_root=root) def rollback(self, data): BrickStore.purge() @@ -252,3 +254,13 @@ class AddBrickNamespace(bpy.types.Operator, Operator): alias = props.new_brick_namespace_alias uri = props.new_brick_namespace_uri core.add_namespace(tool.Brick, alias=alias, uri=uri) + + +class SetBrickListRoot(bpy.types.Operator, Operator): + bl_idname = "bim.set_brick_list_root" + bl_label = "Set Brick View Type" + bl_options = {"REGISTER", "UNDO"} + + def _execute(self, context): + root = context.scene.BIMBrickProperties.brick_list_root + core.set_brick_list_root(tool.Brick, brick_root=root) \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/module/brick/prop.py b/src/blenderbim/blenderbim/bim/module/brick/prop.py index e44a8848c3..840170dae8 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/prop.py +++ b/src/blenderbim/blenderbim/bim/module/brick/prop.py @@ -54,7 +54,7 @@ def get_brick_equipment_classes(self, context): return BrickschemaData.data["brick_equipment_classes"] -def get_brick_view_types(self, context): +def get_brick_roots(self, context): return [("System", "System", ""), ("Location", "Location", ""), ("Equipment", "Equipment", ""), @@ -81,4 +81,4 @@ class BIMBrickProperties(PropertyGroup): new_brick_label: StringProperty(name="New Brick Label") new_brick_namespace_alias: StringProperty(name="New Brick Namespace Alias") new_brick_namespace_uri: StringProperty(name="New Brick Namespace URI") - brick_view_type: EnumProperty(name="Brick View Type", items=get_brick_view_types) \ No newline at end of file + brick_list_root: EnumProperty(name="Brick List Root", items=get_brick_roots) \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/module/brick/ui.py b/src/blenderbim/blenderbim/bim/module/brick/ui.py index 64ee774ea3..0ddf62a9ae 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/ui.py +++ b/src/blenderbim/blenderbim/bim/module/brick/ui.py @@ -77,7 +77,8 @@ class BIM_PT_brickschema(Panel): row.operator("bim.add_brick_namespace", text="", icon="ADD") row = box.row(align=True) - row.prop(data=self.props, property="brick_view_type", text="List View") + row.operator("bim.set_brick_list_root", text="Set View") + row.prop(data=self.props, property="brick_list_root", text="") row = self.layout.row(align=True) row.label(text="Create Entity:") diff --git a/src/blenderbim/blenderbim/core/brick.py b/src/blenderbim/blenderbim/core/brick.py index ab9e8afe53..9a8c4409ef 100644 --- a/src/blenderbim/blenderbim/core/brick.py +++ b/src/blenderbim/blenderbim/core/brick.py @@ -17,10 +17,10 @@ # along with BlenderBIM Add-on. If not, see . -def load_brick_project(brick, filepath=None): +def load_brick_project(brick, filepath=None, brick_root=None): brick.load_brick_file(filepath) - brick.import_brick_classes("Class") - brick.set_active_brick_class("Class") + brick.import_brick_classes(brick_root) + brick.set_active_brick_class(brick_root) def view_brick_class(brick, brick_class=None): @@ -92,10 +92,10 @@ def convert_ifc_to_brick(brick, namespace=None, library=None): brick.run_refresh_brick_viewer() -def new_brick_file(brick): +def new_brick_file(brick, brick_root=None): brick.new_brick_file() - brick.import_brick_classes("Class") - brick.set_active_brick_class("Class") + brick.import_brick_classes(brick_root) + brick.set_active_brick_class(brick_root) def refresh_brick_viewer(brick): @@ -118,3 +118,11 @@ def serialize_brick(brick): def add_namespace(brick, alias=None, uri=None): brick.add_namespace(alias, uri) + + +def set_brick_list_root(brick, brick_root=None): + brick.clear_brick_browser() + brick.import_brick_classes(brick_root) + brick.set_active_brick_class(brick_root) + brick.clear_breadcrumbs() + diff --git a/src/blenderbim/blenderbim/tool/brick.py b/src/blenderbim/blenderbim/tool/brick.py index eeaa4b430b..76b44964bc 100644 --- a/src/blenderbim/blenderbim/tool/brick.py +++ b/src/blenderbim/blenderbim/tool/brick.py @@ -326,6 +326,10 @@ class Brick(blenderbim.core.tool.Brick): def add_namespace(cls, alias, uri): BrickStore.graph.bind(alias, Namespace(uri)) # need some way to reload namespace enum view + + @classmethod + def clear_breadcrumbs(cls): + bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.clear() class BrickStore: