-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringer.py
More file actions
325 lines (276 loc) · 22.7 KB
/
stringer.py
File metadata and controls
325 lines (276 loc) · 22.7 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
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
import FreeCAD, FreeCADGui, Part, Draft
import os
import math
import framing
import stringer_sketch
__title__ = "FreeCAD Stick Framers Toolkit"
__author__ = "Paul Randall"
__url = "http://www.mathcodeprint.com/"
def makeStringer(name):
newstringer = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", name)
Stringer(newstringer)
ViewProviderCollarBeam(newstringer.ViewObject)
#Two Story Placement
# newcollar.Placement = FreeCAD.Placement( FreeCAD.Vector (2e-14, 88.89999999999887, 5064.135),FreeCAD.Rotation (0.0, 0.0, -0.7071067811865475, 0.7071067811865476) )
#Single Story Placement
# Debugging JSON Serialize error
# newstringer.Placement = FreeCAD.Placement( FreeCAD.Vector (2e-14, 88.89999999999887, 2430.465),FreeCAD.Rotation (0.0, 0.0, -0.7071067811865475, 0.7071067811865476) )
FreeCAD.ActiveDocument.recompute()
return newstringer
class Stringer_Command:
"""
The Stringer is a single pre-cut stair stringer.
"""
def GetResources(self):
icon_path = framing.getIconImage( "stringer" )
# image_path = "/" + framing.mod_name + '/icons/stringer.png'
# image_path = '/stickframe/icons/stringer.png'
# global_path = FreeCAD.getHomePath()+"Mod"
# user_path = FreeCAD.getUserAppDataDir()+"Mod"
# icon_path = ""
# if os.path.exists(user_path + image_path):
# icon_path = user_path + image_path
# elif os.path.exists(global_path + image_path):
# icon_path = global_path + image_path
return {"MenuText": "Stringer",
"ToolTip": "Add a Stringer to the Construction",
'Pixmap': str(icon_path)}
def IsActive(self):
if FreeCAD.ActiveDocument == None:
return False
else:
return True
def Activated(self):
print ("Stringer activated")
newstringer = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython", "Stringer")
ViewProviderStringer(newstringer.ViewObject)
Stringer(newstringer)
newstringer.Visibility = True
FreeCAD.ActiveDocument.recompute()
FreeCADGui.SendMsgToActiveView("ViewFit")
class Stringer():
def __init__(self, obj):
obj.addProperty("App::PropertyLength", "Rise", "Dimension","Change the total Rise of the Stringer").Rise = 177.8
obj.addProperty("App::PropertyLength", "Run", "Dimension","Change the total Rin of the Sringer").Run=279.4
obj.addProperty("App::PropertyLength", "Landing", "Dimension","Pre-Set Landing ( NOT IMPLEMENTED )").Landing = "4 ft"
obj.setEditorMode("Landing", 1)
obj.addProperty("App::PropertyFloat", "Cost", "Member","Enter the cost of the construction member").Cost = 2.99
obj.addProperty("App::PropertyEnumeration", "Function", "Member", "Where this member is being used").Function = ['1st Level Stairs','2nd Level Stairs','Attic Stairs','Basement Stairs']
obj.addProperty("App::PropertyString", "MemberName", "Member","Where this member is being used").MemberName = "Stringer"
obj.Proxy = self
# obj.addExtension('Part::AttachExtensionPython', obj)
#TODO:Use part to extrude the sketch
# "PartDesign::Body','Body'
# "PartDesign::Pad","Pad"
sketch = stringer_sketch.makeStringerSketch( "StringerSketch" )
sketch.Visibility = False
# sketch.ShowInTree = False
newextrusion = FreeCAD.ActiveDocument.addObject('Part::Extrusion', 'StringerExtrusion')
# extrusion = obj
newextrusion.Base = FreeCAD.ActiveDocument.getObject(sketch.Name)
newextrusion.Dir = ( 0,1,0 )
newextrusion.LengthFwd = '1.5 in'
newextrusion.Solid = True
obj.addObject( sketch )
obj.addObject( newextrusion )
def onChanged(self, fp, prop):
if prop == "Length" or prop == "Width" or prop == "Height":
fp.Shape = Part.makeBox(fp.Length,fp.Width,fp.Height)
if prop == "Rise":
fp.Group[0].setDatum(66, fp.Rise )
FreeCAD.ActiveDocument.recompute()
if prop == "Run":
fp.Group[0].setDatum(67, fp.Run )
FreeCAD.ActiveDocument.recompute()
def execute(self, fp):
fp.recompute()
# print ("Stringer execute(d)")
class ViewProviderStringer:
def __init__(self, obj):
''' Set this object to the proxy object of the actual view provider '''
obj.Proxy = self
def attach(self, obj):
''' Setup the scene sub-graph of the view provider, this method is mandatory '''
return
def updateData(self, fp, prop):
''' If a property of the handled feature has changed we have the chance to handle this here '''
return
def getDisplayModes(self,obj):
''' Return a list of display modes. '''
modes=[]
return modes
def getDefaultDisplayMode(self):
''' Return the name of the default display mode. It must be defined in getDisplayModes. '''
return "Lines"
def setDisplayMode(self,mode):
''' Map the display mode defined in attach with those defined in getDisplayModes.
Since they have the same names nothing needs to be done. This method is optional.
'''
return mode
def onChanged(self, vp, prop):
''' Print the name of the property that has changed '''
# FreeCAD.Console.PrintMessage("Change property: " + str(prop) + "\n")
def getIcon(self):
''' Return the icon in XMP format which will appear in the tree view. This method is optional
and if not defined a default icon is shown.
'''
return """
/* XPM */
static char * stairstringer_xpm[] = {
"128 128 15 1",
" c None",
". c #000000",
"+ c #FFAE4C",
"@ c #FFC054",
"# c #FF9933",
"$ c #FFCC66",
"% c #FFCC99",
"& c #FFCC33",
"* c #FFFF66",
"= c #FFFF99",
"- c #777777",
"; c #663300",
"> c #CC6633",
", c #FF6600",
"' c #FF9900",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" . . ",
" ...................... ",
" ...................... ",
" .. +@@#$$+$$%&$$$$+@.. ",
" .. +@@#$$+$$%&$$$$+@.. ",
" .. +@@#$$+$$%&$$$$+@.. ",
" .. +@@#$$+$$%&$$$$+@.. ",
" .. +@@#$$+$$%&$$$+@@.. ",
" .. +@@#$$+$$%&$$$+@@.. ",
" .. @@@#$$+$$%&$$$+@@.. ",
" .. @@@#$$+$$%&$$$+@@.. ",
" .. @@@#$$+$$%&$$$+@@.. ",
" .. @@@#$$+$$%&$$$+@@.. ",
" ...@@@#$$+$$%&$$$+@@...................... ",
" .... @#$$+$$%&$$$+@@...................... ",
" ....#$$+$$%&$$$+@@+ $$+$$$+$$@@$@@$$+ .. ",
" .... $+$$%&$$$+@@+$$$+$$$+$$@@@@@$$+ .. ",
" .... $$%&$$$+@@+$$$+$$$$+$$@@@@$$+ .. ",
" ... $%&$$$+@@+$$$+$$$$+$$@@$@$$+ .. ",
" .... &$$$+@@+$$$+$$$$+$$@@@@$$+ .. ",
" ....$$$+@@+$$$+$$$$+$$@@@$$$+ .. ",
" .... $+@@+$$$+$%$$+$$@@@$$$+ .. ",
" ....+@@+$$$+$%$$+$$$@@$$$+ .. ",
" .... @+$$$+$%$$+$$$@@$$$+ .. ",
" .... $$$+$%$$+$$$@@$$$+ .. ",
" ... $$+$%$$+$$$@@$$$+ .. .. ",
" .... +$%$$+$$$@@$$$+ ...................... ",
" ....$%$$+$$$@@$$$+$..................... ",
" .... $$+$$$@@$$$+$$&@@$$$+@@@+%$@$*=#.. ",
" ....$+$$$@@$$$+$$&@@$$$+@@@+%$@$*=#.. ",
" .... $$$@@$$$+$$&@@$$$+@@@+%$@$*=#.. ",
" .... $@@$$$+$$&@@$$$+@@@+%$@$*=#.. ",
" ... @@$$$+$$&@@$$$+@@@+%$@$*=#.. ",
" .... $$$+$$&@@$$$+@@@+%$@$*=#.. ",
" ....$$+$$&@@$$$+@@@+%$@$*=#.. ",
" .... +$$&@@$$$+@@@+%$@$*=#.. ",
" ....$$&@@$$$+@@@+%$@$*=#.. ",
" .... &@@%$$+@@@+%$@$*=#.. ",
" .... @%$$+@@@+%$@$*=#...................... ",
" ... %$$+@@@+%$@$*=#...................... ",
" .... $+@@@+%$@$*=#-;>+$&$$+@@#$$+$$%&$.. ",
" ....+@@@+%$@$*=#-;>+$&$$+@@#$$+$$%&$.. ",
" .... @@+%$@$*=#-;>+$&$$+@@#$$+$$%&$.. ",
" ....@+%$@$*=#-;>+$&$$+@@#$$+$$%&$.. ",
" .... %$@$*=#-;>+$&$$+@@#$$+$$%&$.. ",
" .... @$*=#-;>+$&$$+@@#$$+$$%&$.. ",
" ... $*=#-;>+$&$$+@@#$$+$$%&$.. ",
" .... =#-;>+$&$$+@@#$$+$$%&$.. ",
" ....#-;>+$&$$+@@#$$+$$%&$.. ",
" .... ;>+$&$$+@@#$$+$$%&$.. ",
" ....>+$&$$+@@#$$+$$%&$.. . ",
" .... $&$$+@@#$$+$$%&$...................... ",
" .... $$+@@#$$+$$%&$...................... ",
" ... $+@@#$$+$$%&$$$$+@+$$$+$+$#$##,# .. ",
" .... @@#$$+$$%&$$$$+@+$$$+$+$#$',## .. ",
" ....@#$$+$$%&$$$$+@+$$+$$+$#$#+#$ .. ",
" .... $$+$$%&$$$$+@+$$+$$+$#$#+#$ .. ",
" ....$+$$%&$$$$+@@+$+$$+$#$#+'$ .. ",
" .... $$%&$$$$+@@+$+$$+$#$#+#$ .. ",
" .... %&$$$$+@@+$+$$+$#$#+'$ .. ",
" ... &$$$$+@@+$+$$+$#$###$ .. ",
" .... $$$+@@+$+$$+$$#$#$$ .. ",
" ....$$+@@+$+$$+$$#$$$$ .. ",
" .... @@@+$+$$+$$$#$$$...................... ",
" ....@@+$+$$+$$$#$$$ ..................... ",
" .... $$+$$+$$$$###$$@@$+$&@@%$$+@@@+%$.. ",
" .... +$$+$$&$$$$$&@@$+$&@@%$$+@@@+%$.. ",
" ... $$+$$&&$$$$&@@$+$&@@%$$+@@@+%$.. ",
" .... +$$$&$$$$&@@$+$&@@%$$+@@@+%$.. ",
" ....+$$$@$$&@@$$+$&@@$$$+@@@+%$.. ",
" .... $$@&$&@@$+$$&@@$$$+@@@+%$.. ",
" ....$@@$@@$$+$$&@@$$$+@@@+%$.. ",
" .... @@@@$$+$$&@@$$$+@@@+%$.. ",
" .... @@$$+$$&@@$$$+@@@+%$.. ",
" ... @$$+$$&@@$$$+@@@+%$.. ",
" ........................ ",
" ...................... ",
" .. .. ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};
"""
def __getstate__(self):
''' When saving the document this object gets stored using Python's cPickle module.
Since we have some un-pickable here -- the Coin stuff -- we must define this method
to return a tuple of all pickable objects or None.
'''
return None
def __setstate__(self,state):
''' When restoring the pickled object from document we have the chance to set some
internals here. Since no data were pickled nothing needs to be done here.
'''
return None
FreeCADGui.addCommand('Stringer', Stringer_Command())