This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
InitGui.py
85 lines (71 loc) · 4.08 KB
/
InitGui.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#***************************************************************************
#* *
#* Copyright (c) 2016 *
#* <[email protected]> *
#* *
#* This program is free software; you can redistribute it and/or modify*
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software*
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307*
#* USA *
#* *
#************************************************************************
__title__="FreeCAD SweetHome3D Importer"
__author__ = "Julien Masnada"
__url__ = "https://github.com/rostskadat"
__vers__ ="py3.01"
import os
import FreeCAD
import FreeCADGui
import sys
class SweetHome3DWorkbench(FreeCADGui.Workbench):
"""The SweetHome3D workbench definition."""
def __init__(self):
from PySide.QtCore import QT_TRANSLATE_NOOP
__dirname__ = os.path.join(FreeCAD.getResourceDir(), "Mod", "FreeCAD-SH3D")
if not os.path.isdir(__dirname__):
__dirname__ = os.path.join(FreeCAD.getUserAppDataDir(), "Mod", "FreeCAD-SH3D")
if not os.path.isdir(__dirname__):
FreeCAD.Console.PrintError("Failed to determine the install location of the SweetHome3D workbench. Check your installation.\n")
_tooltip = ("The SweetHome3D workbench is used to import SweetHome3D materials")
self.__class__.ResourceDir = os.path.join(__dirname__, "Resources")
self.__class__.Icon = os.path.join(self.ResourceDir, "icons", "SH3D_Workbench.svg")
self.__class__.MenuText = QT_TRANSLATE_NOOP("SH3D", "SweetHome3D")
self.__class__.ToolTip = QT_TRANSLATE_NOOP("SH3D", _tooltip)
self.__class__.Version = "0.0.1"
FreeCAD.Console.PrintLog('Created SweetHome3D workbench.\n')
def Initialize(self):
"""When the workbench is first loaded."""
from PySide.QtCore import QT_TRANSLATE_NOOP
from draftutils.init_tools import init_toolbar, init_menu
import SH3D
# Set up toolbars
self.toolbar = [ "SH3D_Import", ]
init_toolbar(self, QT_TRANSLATE_NOOP("SH3D", "SweetHome3D tools"), self.toolbar)
init_menu(self, QT_TRANSLATE_NOOP("SH3D", "SweetHome3D"), self.toolbar)
# FreeCADGui.addIconPath(":/icons")
# FreeCADGui.addLanguagePath(":/translations")
FreeCAD.Console.PrintLog('Initialized SweetHome3D workbench.\n')
def Activated(self):
"""When entering the workbench."""
import importlib
modules = [module for name,module in sys.modules.items() if 'sh3d' in name]
list(map(lambda module: importlib.reload(module), modules))
FreeCAD.Console.PrintLog("SweetHome3D workbench activated.\n")
def Deactivated(self):
"""When leaving the workbench."""
FreeCAD.Console.PrintLog("SweetHome3D workbench deactivated.\n")
def GetClassName(self):
"""Type of workbench."""
return "Gui::PythonWorkbench"
FreeCADGui.addWorkbench(SweetHome3DWorkbench)