Skip to content

Commit

Permalink
Draft: fixed bug in Facebinder + added Extrusion property
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Oct 26, 2016
1 parent 5298005 commit bd8a296
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions src/Mod/Draft/Draft.py
Expand Up @@ -5640,28 +5640,45 @@ class _Facebinder(_DraftObject):
def __init__(self,obj):
_DraftObject.__init__(self,obj,"Facebinder")
obj.addProperty("App::PropertyLinkSubList","Faces","Draft",QT_TRANSLATE_NOOP("App::Property","Linked faces"))
obj.addProperty("App::PropertyBool","RemoveSplitter","Draft",QT_TRANSLATE_NOOP("App::Property","Specifies if splitter lines must be removed"))
obj.addProperty("App::PropertyDistance","Extrusion","Draft",QT_TRANSLATE_NOOP("App::Property","An optional extrusion value to be applied to all faces"))

def execute(self,obj):
import Part
pl = obj.Placement
if not obj.Faces:
return
faces = []
for f in obj.Faces:
if "Face" in f[1]:
try:
fnum = int(f[1][4:])-1
faces.append(f[0].Shape.Faces[fnum])
except(IndexError,Part.OCCError):
print("Draft: wrong face index")
return
for sel in obj.Faces:
for f in sel[1]:
if "Face" in f:
try:
fnum = int(f[4:])-1
faces.append(sel[0].Shape.Faces[fnum])
except(IndexError,Part.OCCError):
print("Draft: wrong face index")
return
if not faces:
return
import Part
try:
if len(faces) > 1:
sh = faces.pop()
sh = sh.multiFuse(faces)
sh = sh.removeSplitter()
sh = None
if hasattr(obj,"Extrusion"):
if obj.Extrusion.Value:
for f in faces:
f = f.extrude(f.normalAt(0,0).multiply(obj.Extrusion.Value))
if sh:
sh = sh.fuse(f)
else:
sh = f
if not sh:
sh = faces.pop()
sh = sh.multiFuse(faces)
if hasattr(obj,"RemoveSplitter"):
if obj.RemoveSplitter:
sh = sh.removeSplitter()
else:
sh = sh.removeSplitter()
else:
sh = faces[0]
sh.transformShape(sh.Matrix, True)
Expand Down

0 comments on commit bd8a296

Please sign in to comment.