forked from shaise/FreeCAD_SheetMetal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SheetMetalExtendCmd.py
607 lines (522 loc) · 21.4 KB
/
SheetMetalExtendCmd.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
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
# -*- coding: utf-8 -*-
###################################################################################
#
# SheetMetalJunction.py
#
# Copyright 2015 Shai Seger <shaise at gmail dot com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
###################################################################################
from FreeCAD import Gui
from PySide import QtCore, QtGui
from FreeCAD import Base
import FreeCAD, FreeCADGui, Part, os, math
__dir__ = os.path.dirname(__file__)
iconPath = os.path.join( __dir__, 'Resources', 'icons' )
smEpsilon = 0.0000001
import BOPTools.SplitFeatures
# IMPORTANT: please remember to change the element map version in case of any
# changes in modeling logic
smElementMapVersion = 'sm1.'
def smWarnDialog(msg):
diag = QtGui.QMessageBox(QtGui.QMessageBox.Warning, 'Error in macro MessageBox', msg)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()
def smBelongToBody(item, body):
if (body is None):
return False
for obj in body.Group:
if obj.Name == item.Name:
return True
return False
def smIsPartDesign(obj):
return str(obj).find("<PartDesign::") == 0
def smIsOperationLegal(body, selobj):
#FreeCAD.Console.PrintLog(str(selobj) + " " + str(body) + " " + str(smBelongToBody(selobj, body)) + "\n")
if smIsPartDesign(selobj) and not smBelongToBody(selobj, body):
smWarnDialog("The selected geometry does not belong to the active Body.\nPlease make the container of this item active by\ndouble clicking on it.")
return False
return True
def smMakeFace(edge, dir, extLen, gap1 = 0.0,
gap2 = 0.0, angle1 = 0.0, angle2 = 0.0, op = ''):
len1 = extLen * math.tan(math.radians(angle1))
len2 = extLen * math.tan(math.radians(angle2))
p1 = edge.valueAt(edge.LastParameter - gap2)
p2 = edge.valueAt(edge.FirstParameter + gap1)
p3 = edge.valueAt(edge.FirstParameter + gap1 + len1) + dir.normalize() * extLen
p4 = edge.valueAt(edge.LastParameter - gap2 - len2) + dir.normalize() * extLen
e2 = Part.makeLine(p2, p3)
e4 = Part.makeLine(p4, p1)
section = e4.section(e2)
if section.Vertexes :
p5 = section.Vertexes[0].Point
w = Part.makePolygon([p1,p2,p5,p1])
else :
w = Part.makePolygon([p1,p2,p3,p4,p1])
face = Part.Face(w)
if hasattr(face, 'mapShapes'):
face.mapShapes([(edge,face)],None,op)
return face
def smFace(selItem, obj) :
# find face if Edge Selected
if type(selItem) == Part.Edge :
Facelist = obj.ancestorsOfType(selItem, Part.Face)
if Facelist[0].Area < Facelist[1].Area :
selFace = Facelist[0]
else :
selFace = Facelist[1]
elif type(selItem) == Part.Face :
selFace = selItem
return selFace
def smTouchFace(Face, obj, thk) :
# find face Modified During loop
#Part.show(Face,'Face')
facelist =[]
for face in obj.Faces :
#Part.show(face,'face')
face_common = face.common(Face)
if not(face_common.Faces) :
continue
edge = face.Vertexes[0].extrude(face.normalAt(0,0) * -thk * 2)
#Part.show(edge,'edge')
edge_common = obj.common(edge)
#Part.show(edge_common,'edge_common')
if (edge_common.Edges[0].Length - thk) < smEpsilon :
facelist.append( face)
break
return facelist[0]
def smgetSubface(face, obj, edge, thk):
# Project thickness side edge to get one side rectangle
normal = face.normalAt(0,0)
faceVert = face.Vertexes[0].Point
pt1 = edge.Vertexes[0].Point.projectToPlane(faceVert, normal)
pt2 = edge.Vertexes[1].Point.projectToPlane(faceVert, normal)
vec1 = (pt2-pt1)
# find min & max point of cut shape
wallsolidlist =[]
for solid in obj.Solids:
pt_list =[]
for vertex in solid.Vertexes :
poi = vertex.Point
pt = poi.projectToPlane(faceVert, normal)
pt_list.append(pt)
p1 = Base.Vector(min([pts.x for pts in pt_list]), min([pts.y for pts in pt_list]), min([pts.z for pts in pt_list]))
p2 = Base.Vector(max([pts.x for pts in pt_list]), max([pts.y for pts in pt_list]), max([pts.z for pts in pt_list]))
#print([p1, p2])
# Find angle between diagnoal & thickness side edge
vec2 = (p2 - p1)
angle1 = vec2.getAngle(vec1)
angle = math.degrees(angle1)
#print(angle)
# Check & correct orientation of diagnoal edge rotation
e = Part.makeLine(p1, p2)
e.rotate(p1, normal, -angle)
vec2 = (e.valueAt(e.LastParameter) - e.valueAt(e.FirstParameter)).normalize()
coeff = vec2.dot(vec1.normalize())
#print(coeff)
if coeff != 1.0 :
angle = 90 - angle
# Create Cut Rectangle Face from min/max points & angle
e = Part.Line(p1, p2).toShape()
e1 = e.copy()
e1.rotate(p1, normal, -angle)
e2 = e.copy()
e2.rotate(p2, normal, 90-angle)
section1 = e1.section(e2)
#Part.show(section1,'section1')
p3 = section1.Vertexes[0].Point
e3 = e.copy()
e3.rotate(p1, normal, 90-angle)
e4 = e.copy()
e4.rotate(p2, normal, -angle)
section2 = e3.section(e4)
#Part.show(section2,'section2')
p4 = section2.Vertexes[0].Point
w = Part.makePolygon([p1,p3,p2,p4,p1])
#Part.show(w, "wire")
face = Part.Face(w)
wallSolid = face.extrude(normal * -thk)
wallsolidlist.append(wallSolid)
return wallsolidlist
def smExtrude(extLength = 10.0, gap1 = 0.0, gap2 = 0.0, subtraction = False, offset = 0.02, refine = True,
sketch = '', selFaceNames = '', selObject = ''):
finalShape = selObject
for selFaceName in selFaceNames:
selItem = selObject.getElement(selFaceName)
selFace = smFace(selItem, selObject)
# find the narrow edge
thk = 999999.0
for edge in selFace.Edges:
if abs( edge.Length ) < thk:
thk = abs( edge.Length )
thkEdge = edge
# find a length edge = revolve axis direction
p0 = thkEdge.valueAt(thkEdge.FirstParameter)
for lenEdge in selFace.Edges:
p1 = lenEdge.valueAt(lenEdge.FirstParameter)
p2 = lenEdge.valueAt(lenEdge.LastParameter)
if lenEdge.isSame(thkEdge):
continue
if (p1 - p0).Length < smEpsilon:
revAxisV = p2 - p1
break
if (p2 - p0).Length < smEpsilon:
revAxisV = p1 - p2
break
# find the large face connected with selected face
list2 = selObject.ancestorsOfType(lenEdge, Part.Face)
for Cface in list2 :
if not(Cface.isSame(selFace)) :
break
#Part.show(Cface, "Cface")
# Main Length Edge, Extrusion direction
# MlenEdge = lenEdge
# leng = MlenEdge.Length
revAxisV.normalize()
thkDir = Cface.normalAt(0,0) * -1
FaceDir = selFace.normalAt(0,0)
# if sketch is as wall
sketches = False
if sketch :
if sketch.Shape.Wires[0].isClosed() :
sketches = True
else :
pass
# Split solid Based on Top Face into two solid
Topface_Solid = Cface.Wires[0].extrude(Cface.normalAt(0,0) * -thk)
#Part.show(Topface_Solid,"Topface_Solid")
SplitSolids = BOPTools.SplitAPI.slice(finalShape, Topface_Solid.Faces, "Standard", 0.0)
#Part.show(SplitSolids,"SplitSolids")
for SplitSolid in SplitSolids.Solids:
check_face = SplitSolid.common(Cface)
if check_face.Faces:
SplitSolid1 = SplitSolid
break
#Part.show(SplitSolid1,"SplitSolid1")
for SplitSolid in SplitSolids.Solids:
if not(SplitSolid.isSame(SplitSolid1)) :
SplitSolid2 = SplitSolid
break
#Part.show(SplitSolid2, "SplitSolid2")
# Make solid from sketch, if sketch is present
solidlist =[]
if sketches :
Wall_face = Part.makeFace(sketch.Shape.Wires, "Part::FaceMakerBullseye")
check_face =Wall_face.common(Cface)
if not(check_face.Faces) :
thkDir = thkDir * -1
wallSolid = Wall_face.extrude(thkDir * thk)
#Part.show(wallSolid, "wallSolid")
solidlist.append(wallSolid)
# To find Overlapping Solid, non thickness side Face that touch Overlapping Solid
overlap_solid = wallSolid.common(SplitSolid2)
#Part.show(overlap_solid, "overlap_solid")
substract_face = smTouchFace(wallSolid, SplitSolid2, thk)
#Part.show(substract_face, "substract_face")
# To get solids that aligned/normal to touching face
overlap_solidlist = smgetSubface(substract_face, overlap_solid, lenEdge, thk)
# Substract solid from Initial Solid
if subtraction :
for solid in overlap_solidlist:
CutSolid = solid.makeOffsetShape(offset, 0.0, fill = False, join = 2)
#Part.show(CutSolid, "CutSolid")
finalShape = finalShape.cut(CutSolid)
#Part.show(finalShape,"finalShape")
elif extLength > 0.0 :
# create wall, if edge or face selected
Wall_face = smMakeFace(lenEdge, FaceDir, extLength, gap1, gap2, op='SMW')
wallSolid = Wall_face.extrude(thkDir * thk)
#Part.show(wallSolid,"wallSolid")
solidlist.append(wallSolid)
# Fuse All solid created to Split solid
if len(solidlist) > 0 :
resultSolid = SplitSolid1.fuse(solidlist[0])
if refine :
resultSolid = resultSolid.removeSplitter()
#Part.show(resultSolid,"resultSolid")
# Merge final list
finalShape = finalShape.cut(resultSolid)
#Part.show(finalShape,"finalShape")
finalShape = finalShape.fuse(resultSolid)
#Part.show(finalShape,"finalShape")
return finalShape
class SMExtrudeWall:
def __init__(self, obj):
'''"Add Sheetmetal Wall by Extending" '''
selobj = Gui.Selection.getSelectionEx()[0]
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Length of Wall")
obj.addProperty("App::PropertyLength","length","Parameters",_tip_).length = 10.0
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Gap from left side")
obj.addProperty("App::PropertyDistance","gap1","Parameters",_tip_).gap1 = 0.0
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Gap from right side")
obj.addProperty("App::PropertyDistance","gap2","Parameters",_tip_).gap2 = 0.0
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Base object")
obj.addProperty("App::PropertyLinkSub", "baseObject", "Parameters",_tip_).baseObject = (selobj.Object, selobj.SubElementNames)
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Wall Sketch")
obj.addProperty("App::PropertyLink","Sketch","ParametersExt",_tip_)
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Use Subtraction")
obj.addProperty("App::PropertyBool","UseSubtraction","ParametersExt",_tip_).UseSubtraction = False
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Offset for subtraction")
obj.addProperty("App::PropertyDistance","Offset","ParametersExt",_tip_).Offset = 0.02
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Use Refine")
obj.addProperty("App::PropertyBool","Refine","ParametersExt",_tip_).Refine = True
obj.Proxy = self
def getElementMapVersion(self, _fp, ver, _prop, restored):
if not restored:
return smElementMapVersion + ver
def execute(self, fp):
if (not hasattr(fp,"Sketch")):
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Wall Sketch")
fp.addProperty("App::PropertyLink","Sketch","ParametersExt",_tip_)
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Use Subtraction")
fp.addProperty("App::PropertyBool","UseSubtraction","ParametersExt",_tip_).UseSubtraction = False
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Offset for subtraction")
fp.addProperty("App::PropertyDistance","Offset","ParametersExt",_tip_).Offset = 0.02
_tip_ = QtCore.QT_TRANSLATE_NOOP("App::Property","Use Refine")
fp.addProperty("App::PropertyBool","Refine","ParametersExt",_tip_).Refine = False
# pass selected object shape
Main_Object = fp.baseObject[0].Shape.copy()
face = fp.baseObject[1]
s = smExtrude(extLength = fp.length.Value, gap1 = fp.gap1.Value, gap2 = fp.gap2.Value, subtraction = fp.UseSubtraction,
offset = fp.Offset.Value, refine = fp.Refine, sketch = fp.Sketch, selFaceNames = face, selObject = Main_Object)
fp.baseObject[0].ViewObject.Visibility = False
if fp.Sketch :
fp.Sketch.ViewObject.Visibility = False
fp.Shape = s
class SMViewProviderTree:
"A View provider that nests children objects under the created one"
def __init__(self, obj):
obj.Proxy = self
self.Object = obj.Object
def attach(self, obj):
self.Object = obj.Object
return
def setupContextMenu(self, viewObject, menu):
action = menu.addAction(FreeCAD.Qt.translate("QObject", "Edit %1").replace("%1", viewObject.Object.Label))
action.triggered.connect(lambda: self.startDefaultEditMode(viewObject))
return False
def startDefaultEditMode(self, viewObject):
document = viewObject.Document.Document
if not document.HasPendingTransaction:
text = FreeCAD.Qt.translate("QObject", "Edit %1").replace("%1", viewObject.Object.Label)
document.openTransaction(text)
viewObject.Document.setEdit(viewObject.Object, 0)
def updateData(self, fp, prop):
return
def getDisplayModes(self,obj):
modes=[]
return modes
def setDisplayMode(self,mode):
return mode
def onChanged(self, vp, prop):
return
def __getstate__(self):
# return {'ObjectName' : self.Object.Name}
return None
def __setstate__(self,state):
if state is not None:
import FreeCAD
doc = FreeCAD.ActiveDocument #crap
self.Object = doc.getObject(state['ObjectName'])
def claimChildren(self):
objs = []
if hasattr(self.Object,"baseObject"):
objs.append(self.Object.baseObject[0])
if hasattr(self.Object,"Sketch"):
objs.append(self.Object.Sketch)
return objs
def getIcon(self):
return os.path.join( iconPath , 'SheetMetal_Extrude.svg')
def setEdit(self,vobj,mode):
taskd = SMBendWallTaskPanel()
taskd.obj = vobj.Object
taskd.update()
self.Object.ViewObject.Visibility=False
self.Object.baseObject[0].ViewObject.Visibility=True
FreeCADGui.Control.showDialog(taskd)
return True
def unsetEdit(self,vobj,mode):
FreeCADGui.Control.closeDialog()
self.Object.baseObject[0].ViewObject.Visibility=False
self.Object.ViewObject.Visibility=True
return False
class SMViewProviderFlat:
"A View provider that places objects flat under base object"
def __init__(self, obj):
obj.Proxy = self
self.Object = obj.Object
def attach(self, obj):
self.Object = obj.Object
return
def updateData(self, fp, prop):
return
def getDisplayModes(self,obj):
modes=[]
return modes
def setDisplayMode(self,mode):
return mode
def onChanged(self, vp, prop):
return
def __getstate__(self):
# return {'ObjectName' : self.Object.Name}
return None
def __setstate__(self,state):
if state is not None:
import FreeCAD
doc = FreeCAD.ActiveDocument #crap
self.Object = doc.getObject(state['ObjectName'])
def claimChildren(self):
objs = []
if hasattr(self.Object,"Sketch"):
objs.append(self.Object.Sketch)
return objs
def getIcon(self):
return os.path.join( iconPath , 'SheetMetal_Extrude.svg')
def setEdit(self,vobj,mode):
taskd = SMBendWallTaskPanel()
taskd.obj = vobj.Object
taskd.update()
self.Object.ViewObject.Visibility=False
self.Object.baseObject[0].ViewObject.Visibility=True
FreeCADGui.Control.showDialog(taskd)
return True
def unsetEdit(self,vobj,mode):
FreeCADGui.Control.closeDialog()
self.Object.baseObject[0].ViewObject.Visibility=False
self.Object.ViewObject.Visibility=True
return False
class SMBendWallTaskPanel:
'''A TaskPanel for the Sheetmetal'''
def __init__(self):
self.obj = None
self.form = QtGui.QWidget()
self.form.setObjectName("SMBendWallTaskPanel")
self.form.setWindowTitle("Binded faces/edges list")
self.grid = QtGui.QGridLayout(self.form)
self.grid.setObjectName("grid")
self.title = QtGui.QLabel(self.form)
self.grid.addWidget(self.title, 0, 0, 1, 2)
self.title.setText("Select new face(s)/Edge(s) and press Update")
# tree
self.tree = QtGui.QTreeWidget(self.form)
self.grid.addWidget(self.tree, 1, 0, 1, 2)
self.tree.setColumnCount(2)
self.tree.setHeaderLabels(["Name","Subelement"])
# buttons
self.addButton = QtGui.QPushButton(self.form)
self.addButton.setObjectName("addButton")
self.addButton.setIcon(QtGui.QIcon(os.path.join( iconPath , 'SheetMetal_Update.svg')))
self.grid.addWidget(self.addButton, 3, 0, 1, 2)
QtCore.QObject.connect(self.addButton, QtCore.SIGNAL("clicked()"), self.updateElement)
self.update()
def isAllowedAlterSelection(self):
return True
def isAllowedAlterView(self):
return True
def getStandardButtons(self):
return int(QtGui.QDialogButtonBox.Ok)
def update(self):
'fills the treewidget'
self.tree.clear()
if self.obj:
f = self.obj.baseObject
if isinstance(f[1],list):
for subf in f[1]:
#FreeCAD.Console.PrintLog("item: " + subf + "\n")
item = QtGui.QTreeWidgetItem(self.tree)
item.setText(0,f[0].Name)
item.setIcon(0,QtGui.QIcon(":/icons/Tree_Part.svg"))
item.setText(1,subf)
else:
item = QtGui.QTreeWidgetItem(self.tree)
item.setText(0,f[0].Name)
item.setIcon(0,QtGui.QIcon(":/icons/Tree_Part.svg"))
item.setText(1,f[1][0])
self.retranslateUi(self.form)
def updateElement(self):
if self.obj:
sel = FreeCADGui.Selection.getSelectionEx()[0]
if sel.HasSubObjects:
obj = sel.Object
for elt in sel.SubElementNames:
if "Face" in elt or "Edge" in elt:
face = self.obj.baseObject
found = False
if (face[0] == obj.Name):
if isinstance(face[1],tuple):
for subf in face[1]:
if subf == elt:
found = True
else:
if (face[1][0] == elt):
found = True
if not found:
self.obj.baseObject = (sel.Object, sel.SubElementNames)
self.update()
def accept(self):
FreeCAD.ActiveDocument.recompute()
FreeCADGui.ActiveDocument.resetEdit()
#self.obj.ViewObject.Visibility=True
return True
def retranslateUi(self, TaskPanel):
#TaskPanel.setWindowTitle(QtGui.QApplication.translate("draft", "Faces", None))
self.addButton.setText(QtGui.QApplication.translate("draft", "Update", None))
class SMExtrudeCommandClass():
"""Extrude face"""
def GetResources(self):
return {'Pixmap' : os.path.join( iconPath , 'SheetMetal_Extrude.svg'), # the name of a svg file available in the resources
'MenuText': QtCore.QT_TRANSLATE_NOOP('SheetMetal','Extend Face'),
'Accel': "E",
'ToolTip' : QtCore.QT_TRANSLATE_NOOP('SheetMetal','Extends one or more face, on existing sheet metal.\n'
'1. Select edges or thickness side faces to create walls.\n'
'2. Select a sketch in property editor to create tabs. \n'
'3. Use Property editor to modify other parameters')}
def Activated(self):
doc = FreeCAD.ActiveDocument
view = Gui.ActiveDocument.ActiveView
activeBody = None
selobj = Gui.Selection.getSelectionEx()[0].Object
if hasattr(view,'getActiveObject'):
activeBody = view.getActiveObject('pdbody')
if not smIsOperationLegal(activeBody, selobj):
return
doc.openTransaction("Extend")
if (activeBody is None):
a = doc.addObject("Part::FeaturePython","Extend")
SMExtrudeWall(a)
SMViewProviderTree(a.ViewObject)
else:
a = doc.addObject("PartDesign::FeaturePython","Extend")
SMExtrudeWall(a)
SMViewProviderFlat(a.ViewObject)
activeBody.addObject(a)
FreeCADGui.Selection.clearSelection()
doc.recompute()
doc.commitTransaction()
return
def IsActive(self):
if len(Gui.Selection.getSelection()) < 1 or len(Gui.Selection.getSelectionEx()[0].SubElementNames) < 1:
return False
selobj = Gui.Selection.getSelection()[0]
if selobj.isDerivedFrom("Sketcher::SketchObject"):
return False
for selFace in Gui.Selection.getSelectionEx()[0].SubObjects:
if type(selFace) == Part.Vertex :
return False
return True
Gui.addCommand('SMExtrudeFace',SMExtrudeCommandClass())