write_file added logic that ensures proper model hierarchy

This commit is contained in:
martinaCodes
2022-11-07 17:40:18 +01:00
parent 3361895e1d
commit 9bf6cb953f
3 changed files with 48 additions and 14 deletions
+3 -12
View File
@@ -118,16 +118,13 @@ class IFC_Sv_UpdateCurrent(bpy.types.Operator):
self.file.write("/Users/martina/Documents/GSoC/CodeTests/IfcFileTest_7_11_purged.ifc")
node_tree = context.space_data.node_tree
if node_tree:
print("### \tupdate tree", node_tree)
if self.force_mode or node_tree.sv_process:
print("### \tforce update")
try:
bpy.context.window.cursor_set("WAIT")
node_tree.force_update()
finally:
bpy.context.window.cursor_set("DEFAULT")
print("### \tupdate tree done")
self.report({"INFO"}, "Node tree updated")
self.report({"INFO"}, "Node tree updated.")
return {'FINISHED'}
class IFC_Sv_write_file(bpy.types.Operator):
@@ -193,13 +190,6 @@ class IFC_Sv_write_file(bpy.types.Operator):
raise Exception("Bad path. Provide a path to a file.")
else:
self.ensure_hirarchy(self.file)
print("### \thirarchy ensured")
# if not (self.file.by_type("IfcSpatialElement") or self.file.by_type("IfcSpatialStructureElement")):
# self.report({"INFO"},"No Ifc Spatial Element found. Adding all elements to IfcBuilding.")
# elements = self.file.by_type("IfcElement")
# building = ifcopenshell.api.run("root.create_entity", self.file, name="DefaultBuilding", ifc_class="IfcBuilding")
# for element in elements:
# ifcopenshell.api.run("spatial.assign_container", self.file, product=element, relating_structure=building)
self.file.write(self.filepath)
self.report({"INFO"}, f"File written to: {self.filepath}")
return {"FINISHED"}
@@ -226,8 +216,9 @@ class IFC_PT_write_file_panel(bpy.types.Panel):
layout = self.layout
row = layout.split(factor=0.2, align=True)
row = layout.row()
row2 = layout.row()
row.operator('ifc.sverchok_update_current', text='IFC Re-run all nodes')
row.operator("ifc.write_file_panel")
row2.operator("ifc.write_file_panel")
CLASSES = [IFC_Sv_UpdateCurrent,IFC_Sv_write_file, IFC_PT_write_file_panel]