Add Brick "Set View" operator to change list hierarchy

- "System" as a root may need different logic since children of a system are not "subClasses" but rather "parts". Currently, "part" would be listed as attribute rather than a direct object in the group.
This commit is contained in:
Trashman247
2023-07-12 23:22:43 -07:00
committed by Riley Wong
parent c80a2e1d64
commit 1eb7c006f1
6 changed files with 37 additions and 11 deletions
@@ -35,6 +35,7 @@ classes = (
operator.ViewBrickItem,
operator.SerializeBrick,
operator.AddBrickNamespace,
operator.SetBrickListRoot,
prop.Brick,
prop.BIMBrickProperties,
ui.BIM_PT_brickschema,
@@ -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)
@@ -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)
brick_list_root: EnumProperty(name="Brick List Root", items=get_brick_roots)
@@ -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:")
+14 -6
View File
@@ -17,10 +17,10 @@
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
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()
+4
View File
@@ -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: