-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathInitGui.py
More file actions
113 lines (89 loc) · 4.58 KB
/
InitGui.py
File metadata and controls
113 lines (89 loc) · 4.58 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# ***************************************************************************
# * Copyright (c) 2019 Eddy Verlinden , Genk Belgium (eddyverl) *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * 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. *
# * *
# * FreeCAD 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 Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with FreeCAD; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
# Based on examples at : https://www.freecadweb.org/wiki/Workbench_creation
# Version 01.08
# Version 01.02 (2020-01-15)
# added geodesic sphere
# version 01.03 (2020-01-23)
# added hexahedron (cube)
# version 01.04 (2020-01-30)
# renamed Mod to Pyramids-and-Polyhedrons
# version 01.05 (2020-12-26)
# additional namechanges, no functional changes
# version 01.07a (2020-12-30)
# flexibility for installation folder
# version 01.08 (2023-08-21)
# no printing of the workbenchfolders (issue bij Alex Neufeld)
import os
import FreeCAD
import FreeCADGui
import pyramids_utils
# Add translations path
FreeCADGui.addLanguagePath(
os.path.join(pyramids_utils.getWorkbenchFolder(), "Resources", "Translations")
)
FreeCADGui.updateLocale()
class PolyhydronsWorkbench(Workbench):
translate = FreeCAD.Qt.translate
MenuText = translate("Workbench", "Pyramids-and-Polyhedrons")
ToolTip = translate(
"Workbench", "A workbench for generating pyramids, polyhedrons and geodesic spheres"
)
def __init__(self):
import pyramids_utils
self.__class__.Icon = os.path.join(
pyramids_utils.getWorkbenchFolder(),
"Resources",
"Icons",
"Pyramids-and-Polyhedrons_workbench_icon.svg",
)
def Initialize(self):
"""This function is executed when FreeCAD starts"""
import polyhedrons # import here all the needed files that create your FreeCAD commands
self.list = ["Pyramid","Tetrahedron","Hexahedron","Octahedron","Dodecahedron","Icosahedron","Icosahedron_truncated",
"Geodesic_sphere","RegularSolid"] # A list of command names created in the line above
#self.appendMenu(["An existing Menu","My submenu"],self.list) # appends a submenu to an existing menu
QT_TRANSLATE_NOOP = FreeCAD.Qt.QT_TRANSLATE_NOOP
self.appendToolbar(
QT_TRANSLATE_NOOP("Workbench", "Pyramids-and-Polyhedrons"), self.list
) # creates a new toolbar with your commands
self.appendMenu(
QT_TRANSLATE_NOOP("Workbench", "Pyramids-and-Polyhedrons"), self.list
) # creates a new menu
def Activated(self):
"""This function is executed when the workbench is activated"""
return
def Deactivated(self):
"""This function is executed when the workbench is deactivated"""
return
def ContextMenu(self, recipient):
"""This is executed whenever the user right-clicks on screen"""
# "recipient" will be either "view" or "tree"
QT_TRANSLATE_NOOP = FreeCAD.Qt.QT_TRANSLATE_NOOP
self.appendContextMenu(
QT_TRANSLATE_NOOP("Workbench", "Pyramids-and-Polyhedrons"), self.list
) # add commands to the context menu
def GetClassName(self):
# this function is mandatory if this is a full python workbench
return "Gui::PythonWorkbench"
Gui.addWorkbench(PolyhydronsWorkbench())