Only allow drawing / sheet / schedule creation once the IFC is saved to enforce correct relative paths.

This commit is contained in:
Dion Moult
2023-04-12 21:21:32 +10:00
parent e78ab0db93
commit 5e91b77df0
2 changed files with 47 additions and 3 deletions
@@ -58,9 +58,17 @@ class SheetsData:
@classmethod
def load(cls):
cls.data = {"total_sheets": cls.total_sheets(), "titleblocks": cls.titleblocks()}
cls.data = {
"has_saved_ifc": cls.has_saved_ifc(),
"total_sheets": cls.total_sheets(),
"titleblocks": cls.titleblocks(),
}
cls.is_loaded = True
@classmethod
def has_saved_ifc(cls):
return os.path.isfile(tool.Ifc.get_path())
@classmethod
def total_sheets(cls):
return len([d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SHEET"])
@@ -88,9 +96,17 @@ class DrawingsData:
@classmethod
def load(cls):
cls.data = {"total_drawings": cls.total_drawings(), "location_hint": cls.location_hint()}
cls.data = {
"has_saved_ifc": cls.has_saved_ifc(),
"total_drawings": cls.total_drawings(),
"location_hint": cls.location_hint(),
}
cls.is_loaded = True
@classmethod
def has_saved_ifc(cls):
return os.path.isfile(tool.Ifc.get_path())
@classmethod
def total_drawings(cls):
return len([e for e in tool.Ifc.get().by_type("IfcAnnotation") if e.ObjectType == "DRAWING"])
@@ -112,9 +128,13 @@ class SchedulesData:
@classmethod
def load(cls):
cls.data = {"total_schedules": cls.total_schedules()}
cls.data = {"has_saved_ifc": cls.has_saved_ifc(), "total_schedules": cls.total_schedules()}
cls.is_loaded = True
@classmethod
def has_saved_ifc(cls):
return os.path.isfile(tool.Ifc.get_path())
@classmethod
def total_schedules(cls):
return len([d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SCHEDULE"])
@@ -158,6 +158,14 @@ class BIM_PT_drawings(Panel):
if not DrawingsData.is_loaded:
DrawingsData.load()
if not DrawingsData.data["has_saved_ifc"]:
row = self.layout.row()
row.label(text="Project Not Yet Saved", icon="ERROR")
row = self.layout.row()
op = row.operator("export_ifc.bim", icon="EXPORT", text="Save Project")
op.should_save_as = False
return
self.props = context.scene.DocProperties
if not self.props.is_editing_drawings:
@@ -221,6 +229,14 @@ class BIM_PT_schedules(Panel):
if not SchedulesData.is_loaded:
SchedulesData.load()
if not SchedulesData.data["has_saved_ifc"]:
row = self.layout.row()
row.label(text="Project Not Yet Saved", icon="ERROR")
row = self.layout.row()
op = row.operator("export_ifc.bim", icon="EXPORT", text="Save Project")
op.should_save_as = False
return
self.props = context.scene.DocProperties
if not self.props.is_editing_schedules:
@@ -264,6 +280,14 @@ class BIM_PT_sheets(Panel):
if not SheetsData.is_loaded:
SheetsData.load()
if not SheetsData.data["has_saved_ifc"]:
row = self.layout.row()
row.label(text="Project Not Yet Saved", icon="ERROR")
row = self.layout.row()
op = row.operator("export_ifc.bim", icon="EXPORT", text="Save Project")
op.should_save_as = False
return
self.props = context.scene.DocProperties
if not self.props.is_editing_sheets: