Implement early testing for serialize operator (not functional)

All the right code seems to be in place, but it seems the package won't go through with the serialize function because of read/write permissions (ERRNO 13)
This commit is contained in:
Trashman247
2023-06-25 23:56:15 -07:00
parent 580f8f6218
commit d9196882dc
5 changed files with 20 additions and 0 deletions
@@ -33,6 +33,7 @@ classes = (
operator.RewindBrickClass,
operator.ViewBrickClass,
operator.ViewBrickItem,
operator.SerializeBrick,
prop.Brick,
prop.BIMBrickProperties,
ui.BIM_PT_brickschema,
@@ -189,3 +189,10 @@ class RemoveBrick(bpy.types.Operator, Operator):
library=tool.Ifc.get().by_id(int(props.libraries)) if props.libraries else None,
brick_uri=props.bricks[props.active_brick_index].uri,
)
class SerializeBrick(bpy.types.Operator, Operator):
bl_idname = "bim.serialize_brick"
bl_label = "Serialize Brick"
def _execute(self, context):
core.serialize_brick(tool.Brick)
@@ -58,6 +58,9 @@ class BIM_PT_brickschema(Panel):
row.operator("bim.add_brick_feed", text="", icon="PLUGIN")
row.operator("bim.remove_brick", text="", icon="X")
row = self.layout.row(align=True)
row.operator("bim.serialize_brick")
self.layout.template_list("BIM_UL_bricks", "", self.props, "bricks", self.props, "active_brick_index")
for attribute in BrickschemaData.data["attributes"]:
+3
View File
@@ -109,3 +109,6 @@ def remove_brick(ifc, brick, library=None, brick_uri=None):
ifc.run("library.remove_reference", reference=reference)
brick.remove_brick(brick_uri)
brick.run_refresh_brick_viewer()
def serialize_brick(brick, file_name="BlenderBIMSerializeTest.ttl"):
brick.serialize_brick(file_name)
+6
View File
@@ -320,6 +320,12 @@ class Brick(blenderbim.core.tool.Brick):
BrickStore.VersionedGraphCollection.redo()
BrickStore.reload_brick_graph()
@classmethod
def serialize_brick(cls, file_name):
BrickStore.reload_brick_graph()
print("Serializing: \"" + file_name + "\" ... ")
BrickStore.graph.serialize(file_name)
print("finished!")
class BrickStore:
schema = None # this is now a path