Arch Added a Flip property to roofs to fix inverted direction

This commit is contained in:
Yorik van Havre
2017-07-26 13:29:34 -03:00
parent c8931b5541
commit 4fc53e1bd2

View File

@@ -177,6 +177,7 @@ class _Roof(ArchComponent.Component):
obj.addProperty("App::PropertyInteger","Face","Base", QT_TRANSLATE_NOOP("App::Property","The face number of the base object used to build this roof"))
obj.addProperty("App::PropertyLength","RidgeLength","Arch", QT_TRANSLATE_NOOP("App::Property","The total length of ridges and hips of this roof"))
obj.addProperty("App::PropertyLength","BorderLength","Arch", QT_TRANSLATE_NOOP("App::Property","The total length of borders of this roof"))
obj.addProperty("App::PropertyBool","Flip","Arch",QT_TRANSLATE_NOOP("App::Property","Flip the roof direction if going the wrong way"))
self.Type = "Roof"
obj.Proxy = self
obj.setEditorMode("RidgeLength",1)
@@ -200,6 +201,9 @@ class _Roof(ArchComponent.Component):
def getPerpendicular(self, vec, rotEdge, l):
" Get the perpendicular vec of given edge on xy plane "
norm = FreeCAD.Vector(0,0,1)
if hasattr(self,"normal"):
if self.normal:
norm = FreeCAD.Vector(self.normal)
perpendicular = vec.cross(norm)
if -180. <= rotEdge < -90.:
perpendicular[0] = abs(perpendicular[0])*-1
@@ -218,6 +222,9 @@ class _Roof(ArchComponent.Component):
perpendicular[2] = abs(perpendicular[2])
perpendicular.normalize()
perpendicular = perpendicular.multiply(l)
if hasattr(self,"flip"):
if self.flip:
return perpendicular.negative()
return perpendicular
def makeRoofProfilsDic(self, id, angle, run, idrel, overhang, thickness,):
@@ -518,7 +525,10 @@ class _Roof(ArchComponent.Component):
import Part, math, DraftGeomUtils
pl = obj.Placement
#self.baseface = None
self.flip = False
if hasattr(obj,"Flip"):
if obj.Flip:
self.flip = True
base = None
w = None
if obj.Base: