-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathimport_report_config.py
46 lines (34 loc) · 1.24 KB
/
import_report_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import FreeCAD
import FreeCADGui
import report
from report_utils.resource_utils import iconPath
from report_utils.selection_utils import findSelectedReportConfig
from report_utils import qtutils
class ImportReportConfigCommand:
toolbarName = 'Reporting_Tools'
commandName = 'Import_Report'
def GetResources(self):
return {'MenuText': "Import Report",
'ToolTip': "Import a new Report object from a JSOn File",
'Pixmap': iconPath('ImportConfig.svg')
}
def Activated(self):
selectedFile = qtutils.userSelectedFile(
'Config File', qtutils.JSON_FILES)
if selectedFile is None:
return
fileObject = open(selectedFile, 'r')
report.createReport(fileObject)
def IsActive(self):
"""If there is no active document we can't do anything."""
return not FreeCAD.ActiveDocument is None
if __name__ == "__main__":
command = ImportReportConfigCommand()
if command.IsActive():
command.Activated()
else:
qtutils.showInfo("No open Document", "There is no open document")
else:
import reporting_toolbars
reporting_toolbars.toolbarManager.registerCommand(
ImportReportConfigCommand())