forked from yorikvanhavre/BIM_Workbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInitGui.py
538 lines (447 loc) · 23.4 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
#***************************************************************************
#* *
#* Copyright (c) 2017 Yorik van Havre <[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 *
#* *
#***************************************************************************
# main workbench class
class BIMWorkbench(Workbench):
def __init__(self):
self.__class__.MenuText = "BIM"
self.__class__.ToolTip = "BIM workbench"
self.__class__.Icon = """
/* XPM */
static char * IFC_xpm[] = {
"16 16 9 1",
" c None",
". c #D80742",
"+ c #C20B5E",
"@ c #B11A71",
"# c #0E4A94",
"$ c #A12288",
"% c #61398E",
"& c #983563",
"* c #1E8BA6",
" ",
" # .. ",
" ### .... ",
" ## ##+ .. ",
" ## .## .. ",
" ## +. ## .. ",
" ## $$$+##**.. ",
" #%$$$%#**&. ",
" $$% ##*+..&* ",
" $$$###*@.. ** ",
" $$ #**$@@ ** ",
" $$ **%$ ** ",
" $$ ** ** ",
" $$$$**** ",
" $$ ** ",
" "};
"""
def Initialize(self):
# QT macro
def QT_TRANSLATE_NOOP(scope, text):
return text
import DraftTools
import Arch
import BimCommands
import BimWelcome
import BimSetup
import BimProject
import BimWindows
import BimIfcElements
import BimViews
import BimClassification
import BimBox
import BimTutorial
import BimLibrary
import BimMaterial
import BimIfcQuantities
import BimIfcProperties
import BimNudge
import BimPreflight
import BimReextrude
import BimDiff
import BimIfcExplorer
import BimLayers
import BimTogglePanels
import BimTrash
import BimClone
import BimStructure
import BimStatusBar
import BimWorkingPlaneTools
import BimPartTools
# add translations path
FreeCADGui.addLanguagePath(BimStatusBar.getLanguagePath())
# create BIM commands
# maybe this should go back in each module...
# these should be move out of BimCommands
FreeCADGui.addCommand('BIM_Help',BimCommands.BIM_Help())
FreeCADGui.addCommand('BIM_Glue',BimCommands.BIM_Glue())
FreeCADGui.addCommand('BIM_Sketch',BimCommands.BIM_Sketch())
FreeCADGui.addCommand('BIM_WPView',BimCommands.BIM_WPView())
FreeCADGui.addCommand('BIM_Convert',BimCommands.BIM_Convert())
FreeCADGui.addCommand('BIM_Ungroup',BimCommands.BIM_Ungroup())
FreeCADGui.addCommand('BIM_Rewire',BimCommands.BIM_Rewire())
FreeCADGui.addCommand('BIM_Door',BimCommands.BIM_Door())
FreeCADGui.addCommand('BIM_SetWPTop',BimWorkingPlaneTools.BIM_SetWPTop())
FreeCADGui.addCommand('BIM_SetWPFront',BimWorkingPlaneTools.BIM_SetWPFront())
FreeCADGui.addCommand('BIM_SetWPSide',BimWorkingPlaneTools.BIM_SetWPSide())
FreeCADGui.addCommand('BIM_TogglePanels',BimTogglePanels.BIM_TogglePanels())
FreeCADGui.addCommand('BIM_Trash',BimTrash.BIM_Trash())
FreeCADGui.addCommand('BIM_EmptyTrash',BimTrash.BIM_EmptyTrash())
FreeCADGui.addCommand('BIM_Copy',BimClone.BIM_Copy())
FreeCADGui.addCommand('BIM_Clone',BimClone.BIM_Clone())
FreeCADGui.addCommand('BIM_Column',BimStructure.BIM_Column())
FreeCADGui.addCommand('BIM_Beam',BimStructure.BIM_Beam())
FreeCADGui.addCommand('BIM_Slab',BimStructure.BIM_Slab())
FreeCADGui.addCommand('BIM_ResetCloneColors',BimClone.BIM_ResetCloneColors())
FreeCADGui.addCommand('BIM_Welcome',BimWelcome.BIM_Welcome())
FreeCADGui.addCommand('BIM_Setup',BimSetup.BIM_Setup())
FreeCADGui.addCommand('BIM_Project',BimProject.BIM_Project())
FreeCADGui.addCommand('BIM_Windows',BimWindows.BIM_Windows())
FreeCADGui.addCommand('BIM_IfcElements',BimIfcElements.BIM_IfcElements())
FreeCADGui.addCommand('BIM_Views',BimViews.BIM_Views())
FreeCADGui.addCommand('BIM_Classification',BimClassification.BIM_Classification())
FreeCADGui.addCommand('BIM_Box',BimBox.BIM_Box())
FreeCADGui.addCommand('BIM_Tutorial',BimTutorial.BIM_Tutorial())
FreeCADGui.addCommand('BIM_Library',BimLibrary.BIM_Library())
FreeCADGui.addCommand('BIM_Material',BimMaterial.BIM_Material())
FreeCADGui.addCommand('BIM_IfcQuantities',BimIfcQuantities.BIM_IfcQuantities())
FreeCADGui.addCommand('BIM_IfcProperties',BimIfcProperties.BIM_IfcProperties())
FreeCADGui.addCommand('BIM_Nudge_Switch',BimNudge.BIM_Nudge_Switch())
FreeCADGui.addCommand('BIM_Nudge_Up',BimNudge.BIM_Nudge_Up())
FreeCADGui.addCommand('BIM_Nudge_Down',BimNudge.BIM_Nudge_Down())
FreeCADGui.addCommand('BIM_Nudge_Left',BimNudge.BIM_Nudge_Left())
FreeCADGui.addCommand('BIM_Nudge_Right',BimNudge.BIM_Nudge_Right())
FreeCADGui.addCommand('BIM_Nudge_Extend',BimNudge.BIM_Nudge_Extend())
FreeCADGui.addCommand('BIM_Nudge_Shrink',BimNudge.BIM_Nudge_Shrink())
FreeCADGui.addCommand('BIM_Nudge_RotateLeft',BimNudge.BIM_Nudge_RotateLeft())
FreeCADGui.addCommand('BIM_Nudge_RotateRight',BimNudge.BIM_Nudge_RotateRight())
FreeCADGui.addCommand('BIM_Unclone',BimClone.BIM_Unclone())
FreeCADGui.addCommand('BIM_Preflight',BimPreflight.BIM_Preflight())
FreeCADGui.addCommand('BIM_Diff',BimDiff.BIM_Diff())
FreeCADGui.addCommand('BIM_IfcExplorer',BimIfcExplorer.BIM_IfcExplorer())
FreeCADGui.addCommand('BIM_Layers',BimLayers.BIM_Layers())
FreeCADGui.addCommand('BIM_Reextrude',BimReextrude.BIM_Reextrude())
# wrapped Part tools
FreeCADGui.addCommand('BIM_Builder',BimPartTools.BIM_Builder())
FreeCADGui.addCommand('BIM_Offset2D',BimPartTools.BIM_Offset2D())
FreeCADGui.addCommand('BIM_Extrude',BimPartTools.BIM_Extrude())
FreeCADGui.addCommand('BIM_Cut',BimPartTools.BIM_Cut())
FreeCADGui.addCommand('BIM_Fuse',BimPartTools.BIM_Fuse())
FreeCADGui.addCommand('BIM_Common',BimPartTools.BIM_Common())
FreeCADGui.addCommand('BIM_Compound',BimPartTools.BIM_Compound())
FreeCADGui.addCommand('BIM_SimpleCopy',BimPartTools.BIM_SimpleCopy())
self.draftingtools = ["BIM_Sketch","Draft_Line","Draft_Wire","Draft_Circle",
"Draft_Arc","Draft_Arc_3Points","Draft_Ellipse",
"Draft_Polygon","Draft_Rectangle", "Draft_BSpline", "Draft_BezCurve",
"Draft_Point"]
self.annotationtools = ["Draft_Text", "Draft_ShapeString", "Draft_Dimension",
"Draft_Label","Arch_Axis","Arch_AxisSystem","Arch_Grid",
"Arch_SectionPlane"]
self.bimtools = ["Arch_Site","Arch_Building","Arch_Floor","Arch_Space","Separator",
"Arch_Wall","BIM_Column","BIM_Beam","BIM_Slab","Arch_Rebar","BIM_Door","Arch_Window","Arch_Pipe",
"Arch_PipeConnector","Arch_Stairs","Arch_Roof","Arch_Panel","Arch_Frame",
"Separator","BIM_Box","BIM_Builder","Draft_Facebinder","BIM_Library","Arch_Component"]
self.modify = ["Draft_Move","BIM_Copy","Draft_Rotate","BIM_Clone","BIM_Unclone","Draft_Offset",
"BIM_Offset2D", "Draft_Trimex","Draft_Join","Draft_Split","Draft_Scale","Draft_Stretch",
"BIM_Rewire","BIM_Glue","Draft_Upgrade", "Draft_Downgrade",
"Draft_Draft2Sketch","Arch_CutPlane","Arch_Add","Arch_Remove","BIM_Reextrude",
"Draft_Array","Draft_PathArray","Draft_PointArray",
"Draft_Mirror","BIM_Extrude","BIM_Cut","BIM_Fuse","BIM_Common","BIM_Compound",
"BIM_SimpleCopy","Draft_Shape2DView"]
self.snap = ['Draft_ToggleGrid','Draft_Snap_Lock','Draft_Snap_Midpoint','Draft_Snap_Perpendicular',
'Draft_Snap_Grid','Draft_Snap_Intersection','Draft_Snap_Parallel',
'Draft_Snap_Endpoint','Draft_Snap_Angle','Draft_Snap_Center',
'Draft_Snap_Extension','Draft_Snap_Near','Draft_Snap_Ortho',
'Draft_Snap_Special','Draft_Snap_Dimensions','Draft_Snap_WorkingPlane',
'BIM_SetWPTop','BIM_SetWPFront','BIM_SetWPSide']
self.manage = ["BIM_Setup","BIM_Project","BIM_Views","BIM_Windows","BIM_IfcElements",
"BIM_IfcQuantities","BIM_IfcProperties","BIM_Classification",
"BIM_Material","Arch_Schedule","BIM_Preflight"]
# experimental arch tools (for 0.19 only)
try:
import ArchIFC
except:
# this is 0.18
self.experimentaltools = None
else:
from archguitools import gui_wall
from archguitools import gui_openings
from archguitools import gui_joinwalls
from archguitools import gui_archview
self.experimentaltools = ["Arch_Wall2","Arch_JoinWalls", "Arch_ExtendWall", "Separator",
"Arch_Opening", "Arch_Door2", "Arch_Window2", "Separator",
"Arch_View"]
# fixed command names
if "Draft_WorkingPlaneProxy" in Gui.listCommands():
_tool = "Draft_WorkingPlaneProxy"
else:
_tool = "Draft_SetWorkingPlaneProxy"
self.utils = ["BIM_TogglePanels","BIM_Trash","BIM_WPView",
"Draft_Slope", _tool, "Draft_AddConstruction",
"Arch_SplitMesh","Arch_MeshToShape",
"Arch_SelectNonSolidMeshes","Arch_RemoveShape",
"Arch_CloseHoles","Arch_MergeWalls","Arch_Check",
"Arch_ToggleIfcBrepFlag",
"Arch_ToggleSubs","Arch_Survey","BIM_Diff","BIM_IfcExplorer"]
nudge = ["BIM_Nudge_Switch","BIM_Nudge_Up","BIM_Nudge_Down","BIM_Nudge_Left","BIM_Nudge_Right",
"BIM_Nudge_RotateLeft","BIM_Nudge_RotateRight","BIM_Nudge_Extend","BIM_Nudge_Shrink"]
# post-0.18 tools
if "Draft_Layer" in Gui.listCommands():
self.manage.insert(8,"BIM_Layers")
if "Arch_Project" in Gui.listCommands():
self.bimtools.insert(0,"Arch_Project")
if "Arch_Reference" in Gui.listCommands():
self.bimtools.insert(-5,"Arch_Reference")
if "Arch_Fence" in Gui.listCommands():
self.bimtools.insert(-7,"Arch_Fence")
if "Draft_Arc_3Points" in Gui.listCommands():
self.draftingtools.insert(5,"Draft_Arc_3Points")
if 'Draft_CubicBezCurve' in Gui.listCommands():
self.draftingtools.insert(len(self.draftingtools)-2,'Draft_CubicBezCurve')
if "Draft_AnnotationStyleEditor" in Gui.listCommands():
self.manage.insert(4,"Draft_AnnotationStyleEditor")
if "Arch_Truss" in Gui.listCommands():
self.bimtools.insert(self.bimtools.index("Arch_Frame")+1,"Arch_Truss")
if "Arch_CurtainWall" in Gui.listCommands():
self.bimtools.insert(self.bimtools.index("Arch_Wall")+1,"Arch_CurtainWall")
if "Arch_Profile" in Gui.listCommands():
self.bimtools.insert(self.bimtools.index("BIM_Box"),"Arch_Profile")
# load rebar tools (Reinforcement addon)
try:
import RebarTools
except ImportError:
self.rebar = None
else:
# create popup group for Rebar tools
class RebarGroupCommand:
def GetCommands(self):
return tuple(["Arch_Rebar"]+RebarTools.RebarCommands)
def GetResources(self):
return {
'MenuText': QT_TRANSLATE_NOOP('Arch_RebarTools','Reinforcement tools'),
'ToolTip': QT_TRANSLATE_NOOP('Arch_RebarTools','Reinforcement tools')}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
FreeCADGui.addCommand('Arch_RebarTools', RebarGroupCommand())
self.bimtools[self.bimtools.index("Arch_Rebar")] = "Arch_RebarTools"
Log("Load Reinforcement Module...done\n")
if hasattr(RebarTools,"updateLocale"):
RebarTools.updateLocale()
# self.appendMenu(QT_TRANSLATE_NOOP("Arch_RebarTools","Reinforcement tools"),RebarTools.RebarCommands + ["Arch_Rebar"])
self.rebar = RebarTools.RebarCommands + ["Arch_Rebar"]
# try to load bimbots
try:
import bimbots
except ImportError:
pass
else:
class BIMBots:
def GetResources(self):
return bimbots.get_plugin_info()
def Activated(self):
bimbots.launch_ui()
FreeCADGui.addCommand('BIMBots', BIMBots())
self.utils.append("BIMBots")
# load Reporting
try:
import report
except ImportError:
pass
else:
if "Report_Create" in Gui.listCommands():
self.manage[self.manage.index("Arch_Schedule")] = "Report_Create"
# load webtools
try:
import BIMServer, Git, Sketchfab
except ImportError:
pass
else:
self.utils.extend(["WebTools_Git","WebTools_BimServer","WebTools_Sketchfab"])
# load flamingo
try:
import CommandsPolar,CommandsFrame,CommandsPipe
except ImportError:
flamingo = None
else:
flamingo = ["frameIt","fillFrame","insertPath","insertSection","FrameLineManager","spinSect",
"reverseBeam","shiftBeam","pivotBeam","levelBeam","alignEdge","rotJoin","alignFlange",
"stretchBeam","extend","adjustFrameAngle","insertPipe","insertElbow","insertReduct",
"insertCap","insertFlange","insertUbolt","insertPypeLine","breakPipe","mateEdges",
"extend2intersection","extend1intersection","laydown","raiseup"]
# load fasteners
try:
import FastenerBase,FastenersCmd
except ImportError:
fasteners = None
else:
fasteners = [c for c in FastenerBase.FSGetCommands("screws") if not isinstance(c,tuple)]
# create toolbars
self.appendToolbar(QT_TRANSLATE_NOOP("BIM","Drafting tools"),self.draftingtools)
self.appendToolbar(QT_TRANSLATE_NOOP("BIM","3D/BIM tools"),self.bimtools)
self.appendToolbar(QT_TRANSLATE_NOOP("BIM","Annotation tools"),self.annotationtools)
self.appendToolbar(QT_TRANSLATE_NOOP("BIM","Modification tools"),self.modify)
self.appendToolbar(QT_TRANSLATE_NOOP("BIM","Manage tools"),self.manage)
if self.experimentaltools:
self.appendToolbar(QT_TRANSLATE_NOOP("BIM","Experimental tools"),self.experimentaltools)
#if flamingo:
# self.appendToolbar("Flamingo tools",flamingo)
# create menus
# ugly!
# build a new list of bimtools only for menu
# and put rebar menu with sub menus into it
self.bimtools_menu = list(self.bimtools)
if "Arch_RebarTools" in self.bimtools_menu:
self.bimtools_menu.remove("Arch_RebarTools")
self.appendMenu(QT_TRANSLATE_NOOP("BIM","&2D Drafting"),self.draftingtools)
self.appendMenu(QT_TRANSLATE_NOOP("BIM","&3D/BIM"),self.bimtools_menu)
if self.rebar:
self.appendMenu([QT_TRANSLATE_NOOP("BIM","&3D/BIM"),QT_TRANSLATE_NOOP("Arch_RebarTools","Reinforcement tools")],self.rebar)
self.appendMenu(QT_TRANSLATE_NOOP("BIM","&Annotation"),self.annotationtools)
self.appendMenu(QT_TRANSLATE_NOOP("BIM","&Snapping"),self.snap)
self.appendMenu(QT_TRANSLATE_NOOP("BIM","&Modify"),self.modify)
self.appendMenu(QT_TRANSLATE_NOOP("BIM","&Manage"),self.manage)
if flamingo:
self.appendMenu(QT_TRANSLATE_NOOP("BIM","&Flamingo"),flamingo)
if fasteners:
self.appendMenu(QT_TRANSLATE_NOOP("BIM","&Fasteners"),fasteners)
self.appendMenu(QT_TRANSLATE_NOOP("BIM","&Utils"),self.utils)
self.appendMenu([QT_TRANSLATE_NOOP("BIM","&Utils"),QT_TRANSLATE_NOOP("BIM","Nudge")],nudge)
self.appendMenu("&Help",["BIM_Welcome","BIM_Help","BIM_Tutorial"])
# load Arch & Draft preference pages
if hasattr(FreeCADGui,"draftToolBar"):
if not hasattr(FreeCADGui.draftToolBar,"loadedArchPreferences"):
import Arch_rc
FreeCADGui.addPreferencePage(":/ui/preferences-arch.ui","Arch")
FreeCADGui.addPreferencePage(":/ui/preferences-archdefaults.ui","Arch")
FreeCADGui.draftToolBar.loadedArchPreferences = True
if not hasattr(FreeCADGui.draftToolBar,"loadedPreferences"):
import Draft_rc
FreeCADGui.addPreferencePage(":/ui/preferences-draft.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/preferences-draftsnap.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/preferences-draftvisual.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/preferences-drafttexts.ui","Draft")
FreeCADGui.draftToolBar.loadedPreferences = True
Log ('Loading BIM module... done\n')
FreeCADGui.updateLocale()
def setupMultipleObjectSelection(self):
import BimSelect
if hasattr(FreeCADGui,"addDocumentObserver") and not hasattr(self,"BimSelectObserver"):
self.BimSelectObserver = BimSelect.Setup()
FreeCADGui.addDocumentObserver(self.BimSelectObserver)
def Activated(self):
if hasattr(FreeCADGui,"draftToolBar"):
FreeCADGui.draftToolBar.Activated()
if hasattr(FreeCADGui,"Snapper"):
FreeCADGui.Snapper.show()
from DraftGui import todo
import BimStatusBar
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM").GetBool("FirstTime",True) and (not hasattr(FreeCAD,"TestEnvironment")):
todo.delay(FreeCADGui.runCommand,"BIM_Welcome")
todo.delay(BimStatusBar.setStatusIcons,True)
FreeCADGui.Control.clearTaskWatcher()
class BimWatcher:
def __init__(self,cmds,name,invert=False):
self.commands = cmds
self.title = name
self.invert = invert
def shouldShow(self):
if self.invert:
return (FreeCAD.ActiveDocument != None) and (FreeCADGui.Selection.getSelection() != [])
else:
return (FreeCAD.ActiveDocument != None) and (not FreeCADGui.Selection.getSelection())
FreeCADGui.Control.addTaskWatcher([BimWatcher(self.draftingtools+self.annotationtools,"2D geometry"),
BimWatcher(self.bimtools,"3D/BIM geometry"),
BimWatcher(self.modify,"Modify",invert=True)])
# restore views widget if needed
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM").GetBool("RestoreBimViews",True):
import BimViews
w = BimViews.findWidget()
if not w:
FreeCADGui.runCommand("BIM_Views")
else:
w.show()
self.setupMultipleObjectSelection()
Log("BIM workbench activated\n")
def Deactivated(self):
if hasattr(self,"BimSelectObserver"):
FreeCADGui.removeDocumentObserver(self.BimSelectObserver)
del self.BimSelectObserver
if hasattr(FreeCADGui,"draftToolBar"):
FreeCADGui.draftToolBar.Deactivated()
if hasattr(FreeCADGui,"Snapper"):
FreeCADGui.Snapper.hide()
from DraftGui import todo
import BimStatusBar
import BimViews
#print("Deactivating status icon")
todo.delay(BimStatusBar.setStatusIcons,False)
FreeCADGui.Control.clearTaskWatcher()
# store views widget state and vertical size
w = BimViews.findWidget()
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM").SetBool("RestoreBimViews",bool(w))
if w:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM").SetInt("BimViewsSize",w.height())
w.hide()
Log("BIM workbench deactivated\n")
def ContextMenu(self, recipient):
import DraftTools
if (recipient == "Tree"):
groups = False
ungroupable = False
for o in FreeCADGui.Selection.getSelection():
if o.isDerivedFrom("App::DocumentObjectGroup") or o.hasExtension("App::GroupExtension"):
groups = True
else:
groups = False
break
for o in FreeCADGui.Selection.getSelection():
for parent in o.InList:
if parent.isDerivedFrom("App::DocumentObjectGroup") or parent.hasExtension("App::GroupExtension"):
if o in parent.Group:
ungroupable = True
else:
ungroupable = False
break
if groups:
self.appendContextMenu("",["Draft_SelectGroup"])
if ungroupable:
self.appendContextMenu("",["BIM_Ungroup"])
if (len(FreeCADGui.Selection.getSelection()) == 1) and (FreeCADGui.Selection.getSelection()[0].Name == "Trash"):
self.appendContextMenu("",["BIM_EmptyTrash"])
elif (recipient == "View"):
self.appendContextMenu("Snapping",self.snap)
if FreeCADGui.Selection.getSelection():
if (FreeCADGui.Selection.getSelection()[0].Name != "Trash"):
self.appendContextMenu("",["BIM_Trash"])
self.appendContextMenu("",["Draft_AddConstruction"])
allclones = False
for obj in FreeCADGui.Selection.getSelection():
if hasattr(obj,"CloneOf") and obj.CloneOf:
allclones = True
else:
allclones = False
break
if allclones:
self.appendContextMenu("",["BIM_ResetCloneColors"])
def GetClassName(self):
return "Gui::PythonWorkbench"
FreeCADGui.addWorkbench(BIMWorkbench)