-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbsh_forms.py
More file actions
137 lines (111 loc) · 4 KB
/
Copy pathbsh_forms.py
File metadata and controls
137 lines (111 loc) · 4 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# (c) 2019 Stefan Katerkamp
# LGPL: This file is part of the Bit Socket Holder Workbench for FreeCAD
__title__="Bit Socket Holder dialogs"
__author__="katerkamp"
__url__="github.com/katerkamp/FreeCAD/BitSocketHolder"
__license__="LGPL 3"
import FreeCAD,FreeCADGui,Part
pq=FreeCAD.Units.parseQuantity
import bsh_cmd
import bsh_utils
from prototype_forms import prototypeDialog
from os import listdir
from os.path import join, dirname, abspath
from PySide.QtCore import *
from PySide.QtGui import *
from math import degrees
from DraftVecUtils import rounded
from HolderProperties import HolderProperties
class insertSocketHolderForm(prototypeDialog):
def __init__(self):
super(insertSocketHolderForm,self).__init__('socketHolder.ui')
def accept(self):
HolderProperties().initDocument()
propList=[\
self.form.SocketTag.text(),\
self.form.SocketDiameter.value(),\
self.form.SocketInsertDepth.value(),\
self.form.createCutoutObject.isChecked(),\
self.form.createTagObject.isChecked()\
]
pos = bsh_utils.getNewPosition()
a=bsh_cmd.makeSocketHolder(propList, pos)
a.ViewObject.ShapeColor=(0.8,0.8,0.8)
print('created obj ' + a.Name + ' ' + a.Label)
if a.Tag:
a.Label = 'SocketHolder-' + a.Tag
FreeCADGui.Control.closeDialog()
FreeCAD.activeDocument().commitTransaction()
FreeCAD.activeDocument().recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")
# fixme: sometimes isChecked object gets already deleted runtime error
class insertBitHolderForm(prototypeDialog):
def __init__(self):
super(insertBitHolderForm,self).__init__('bitHolder.ui')
def accept(self):
HolderProperties().initDocument()
propList=[\
self.form.BitTag.text(),\
self.form.BitDiameter.value(),\
self.form.BitInsertDepth.value(),\
self.form.createCutoutObject.isChecked(),\
self.form.createTagObject.isChecked()\
]
pos = bsh_utils.getNewPosition()
a=bsh_cmd.makeBitHolder(propList, pos)
a.ViewObject.ShapeColor=(0.8,0.8,0.8)
print('created obj ' + a.Name + ' ' + a.Label)
if a.Tag:
a.Label = 'BitHolder-' + a.Tag
FreeCADGui.Control.closeDialog()
FreeCAD.activeDocument().commitTransaction()
FreeCAD.activeDocument().recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")
class insertPadForm(prototypeDialog):
def __init__(self):
super(insertPadForm,self).__init__('pad.ui')
def accept(self):
HolderProperties().initDocument()
propList=[\
self.form.trayWidth.value(),\
self.form.trayHeight.value(),\
self.form.trayDepth.value()\
]
pos = bsh_utils.getNewPosition()
a=bsh_cmd.makePad(propList, pos)
a.ViewObject.ShapeColor=(0.5,0.8,0.5)
FreeCADGui.Control.closeDialog()
FreeCAD.activeDocument().commitTransaction()
FreeCAD.activeDocument().recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")
class insertAnyHolderForm(prototypeDialog):
def __init__(self):
print("Any Holder Init")
super(insertAnyHolderForm,self).__init__('anyHolder.ui')
sketches = []
for o in FreeCAD.ActiveDocument.Objects:
if hasattr(o, "TypeId") and o.TypeId == 'Sketcher::SketchObject':
sketches.append(o)
self.form.shapesAvaliable = []
for s in sketches:
self.form.shapesAvailable.addItem(s.Label)
def accept(self):
print("Any Holder Accept")
HolderProperties().initDocument()
propList=[\
self.form.AnyTag.text(),\
self.form.shapesAvailable.currentText(),\
self.form.AnyInsertDepth.value(),\
self.form.createCutoutObject.isChecked(),\
self.form.createTagObject.isChecked()\
]
pos = bsh_utils.getNewPosition()
a=bsh_cmd.makeAnyHolder(propList, pos)
a.ViewObject.ShapeColor=(0.8,0.8,0.8)
print('created obj ' + a.Name + ' ' + a.Label)
if a.Tag:
a.Label = 'AnyHolder-' + a.Tag
FreeCADGui.Control.closeDialog()
FreeCAD.activeDocument().commitTransaction()
FreeCAD.activeDocument().recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")