-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandsHeap.py
More file actions
54 lines (46 loc) · 1.85 KB
/
CommandsHeap.py
File metadata and controls
54 lines (46 loc) · 1.85 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
#(c) 2017 R. T. LGPL: part of heapsOstuff w.b. for FreeCAD
__title__="heapsOstuff toolbar"
__author__="oddtopus"
__url__="github.com/oddtopus/heaps"
__license__="LGPL 3"
# import FreeCAD modules
import FreeCAD, FreeCADGui,inspect, os
# helper -------------------------------------------------------------------
def addCommand(name,cmdObject):
(list,num) = inspect.getsourcelines(cmdObject.Activated)
pos = 0
# check for indentation
while(list[1][pos] == ' ' or list[1][pos] == '\t'):
pos += 1
source = ""
for i in range(len(list)-1):
source += list[i+1][pos:]
FreeCADGui.addCommand(name,cmdObject,source)
#---------------------------------------------------------------------------
# The command classes
#---------------------------------------------------------------------------
class mergeThing:
'''
Simple dialog to merge .fcstd files in documents.
'''
def Activated (self):
import heaps
#heapsForm=heaps.mergeThingForm()
FreeCADGui.Control.showDialog(heaps.mergeThingForm())
def GetResources(self):
return{'Pixmap':os.path.join(os.path.dirname(os.path.abspath(__file__)),"icons","merge.svg"),'MenuText':'Merge things','ToolTip':'Open heap -> select stuff -> merge thing.'}
class heapsManager:
'''
Simple dialog to create heaps, add stuff to heaps
or add things to stuff.
'''
def Activated (self):
import heaps
heapsForm=heaps.HeapsManagerForm()
def GetResources(self):
return{'Pixmap':os.path.join(os.path.dirname(os.path.abspath(__file__)),"icons","manager.svg"),'MenuText':'Heaps manager','ToolTip':'Actions on heaps'}
#---------------------------------------------------------------------------
# Adds the commands to the FreeCAD command manager
#---------------------------------------------------------------------------
addCommand('mergeThing',mergeThing())
addCommand('heapsManager',heapsManager())