paullee0
2019-04-04 04:51:46 +08:00
committed by Yorik van Havre
parent c2e64c3028
commit 4e35701577

View File

@@ -285,7 +285,8 @@ class _Stairs(ArchComponent.Component):
if not "WidthOfLanding" in pl:
obj.addProperty("App::PropertyFloatList","WidthOfLanding","Stairs",QT_TRANSLATE_NOOP("App::Property","The width of a Landing (Second edge and after - First edge follows Width property)"))
# steps properties
# steps and risers properties
if not "NumberOfSteps" in pl:
obj.addProperty("App::PropertyInteger","NumberOfSteps","Steps",QT_TRANSLATE_NOOP("App::Property","The number of risers in these stairs"))
if not "TreadDepth" in pl:
@@ -302,6 +303,9 @@ class _Stairs(ArchComponent.Component):
obj.addProperty("App::PropertyFloat","BlondelRatio","Steps",QT_TRANSLATE_NOOP("App::Property","The Blondel ratio indicates comfortable stairs and should be between 62 and 64cm or 24.5 and 25.5in"))
obj.setEditorMode("BlondelRatio",1)
if not "RiserThickness" in pl:
obj.addProperty("App::PropertyLength","RiserThickness","Steps",QT_TRANSLATE_NOOP("App::Property","The thickness of the risers"))
if not hasattr(obj,"LandingDepth"):
obj.addProperty("App::PropertyLength","LandingDepth","Steps",QT_TRANSLATE_NOOP("App::Property","The depth of the landing of these stairs"))
@@ -328,7 +332,7 @@ class _Stairs(ArchComponent.Component):
obj.setEditorMode("OutlineRight",1)
# Can't accept 'None' in list, need NaN
#if not hasattr(obj,"OutlineRailArcLeft"):
#if not hasattr(obj,"OutlineRailArcLeft"):
#obj.addProperty("App::PropertyVectorList","OutlineRailArcLeft","Segment and Parts",QT_TRANSLATE_NOOP("App::Property","The 'left outline' 'arc points' of stairs railing"))
#obj.setEditorMode("OutlineRailArcLeft",1)
#if not hasattr(obj,"OutlineRailArcRight"):
@@ -422,6 +426,8 @@ class _Stairs(ArchComponent.Component):
return
self.steps = []
self.risers = []
self.pseudosteps = []
self.structures = []
pl = obj.Placement
@@ -484,8 +490,9 @@ class _Stairs(ArchComponent.Component):
self.makeStraightStairsWithLanding(obj,edge)
if self.structures or self.steps:
base = Part.makeCompound(self.structures + self.steps)
if self.structures or self.steps or self.risers:
base = Part.makeCompound(self.structures + self.steps + self.risers)
elif self.pseudosteps:
shape = Part.makeCompound(self.pseudosteps)
obj.Shape = shape
@@ -694,7 +701,7 @@ class _Stairs(ArchComponent.Component):
#vBase2vec = (vBase2-vBase[i]) # - would not be correct if Align is not Left
''' (1a) calc & append vLength - Need v (vec) '''
vLength.append(Vector(v[i].x,v[i].y,v[i].z)) # TODO check all function below ok with curve? # TODO vLength in this f() is 3d
vLength.append(Vector(v[i].x,v[i].y,v[i].z)) # TODO check all function below ok with curve? # TODO vLength in this f() is 3d
''' (1b, 2a) calc & append vWidth - Need vLength, netWidthI '''
@@ -1136,15 +1143,23 @@ class _Stairs(ArchComponent.Component):
vNose = DraftVecUtils.scaleTo(vLength,-abs(obj.Nosing.Value))
a = math.atan(vHeight.Length/vLength.Length)
# steps
for i in range(numberofsteps-1):
p1 = vBase.add((Vector(vLength).multiply(i)).add(Vector(vHeight).multiply(i+1)))
vBasedAligned = self.align(vBase,obj.Align,vWidth)
vRiserThickness = DraftVecUtils.scaleTo(vLength,obj.RiserThickness.Value) # 50)
p1 = self.align(p1,obj.Align,vWidth)
p1 = p1.add(vNose).add(Vector(0,0,-abs(obj.TreadThickness.Value)))
# steps and risers
for i in range(numberofsteps-1):
#p1 = vBase.add((Vector(vLength).multiply(i)).add(Vector(vHeight).multiply(i+1)))
p1 = vBasedAligned.add((Vector(vLength).multiply(i)).add(Vector(vHeight).multiply(i+1)))
#p1 = self.align(p1,obj.Align,vWidth)
#p1 = p1.add(vNose).add(Vector(0,0,-abs(obj.TreadThickness.Value)))
p1 = p1.add(Vector(0,0,-abs(obj.TreadThickness.Value)))
r1 = p1
p1 = p1.add(vNose)
p2 = p1.add(DraftVecUtils.neg(vNose)).add(vLength)
p3 = p2.add(vWidth)
p4 = p3.add(DraftVecUtils.neg(vLength)).add(vNose)
step = Part.Face(Part.makePolygon([p1,p2,p3,p4,p1]))
if obj.TreadThickness.Value:
step = step.extrude(Vector(0,0,abs(obj.TreadThickness.Value)))
@@ -1152,33 +1167,58 @@ class _Stairs(ArchComponent.Component):
else:
self.pseudosteps.append(step)
''' risers - add to steps or pseudosteps in the meantime before adding self.risers / self.pseudorisers '''
#vResHeight = vHeight.add(Vector(0,0,-abs(obj.TreadThickness.Value)))
r2 = r1.add(DraftVecUtils.neg(vHeight)) #vResHeight
if i == 0:
r2 = r2.add(Vector(0,0,abs(obj.TreadThickness.Value)))
r3 = r2.add(vWidth)
r4 = r3.add(vHeight) #vResHeight
if i == 0:
r4 = r4.add(Vector(0,0,-abs(obj.TreadThickness.Value)))
riser = Part.Face(Part.makePolygon([r1,r2,r3,r4,r1]))
if obj.RiserThickness.Value:
riser = riser.extrude(vRiserThickness) #Vector(0,100,0))
self.steps.append(riser)
else:
self.pseudosteps.append(riser)
##
# structure
lProfile = []
struct = None
if obj.Structure == "Massive":
if obj.StructureThickness.Value:
# Massive Structure to respect 'align' attribute
vBasedAligned = self.align(vBase,obj.Align,vWidth)
vBase = vBasedAligned
# '# Massive Structure to respect 'align' attribute'
vBase = vBasedAligned.add(vRiserThickness)
for i in range(numberofsteps-1):
if not lProfile:
lProfile.append(vBase)
last = lProfile[-1]
if len(lProfile) == 1:
last = last.add(Vector(0,0,-abs(obj.TreadThickness.Value)))
lProfile.append(last.add(vHeight))
lProfile.append(lProfile[-1].add(vLength))
lProfile[-1] = lProfile[-1].add(-vRiserThickness)
resHeight1 = obj.StructureThickness.Value/math.cos(a)
lProfile.append(lProfile[-1].add(Vector(0,0,-resHeight1)))
resHeight2 = ((numberofsteps-1)*vHeight.Length)-(resHeight1+obj.TreadThickness.Value)
resLength = (vLength.Length/vHeight.Length)*resHeight2
h = DraftVecUtils.scaleTo(vLength,-resLength)
lProfile.append(lProfile[-1].add(Vector(h.x,h.y,-resHeight2)))
lProfile.append(vBase)
#print(lProfile)
pol = Part.makePolygon(lProfile)
struct = Part.Face(pol)
evec = vWidth
@@ -1261,7 +1301,6 @@ class _Stairs(ArchComponent.Component):
vLength = DraftVecUtils.scaleTo(v,treadDepth)
else:
reslength = edge.Length
#
treadDepth = float(reslength)/(obj.NumberOfSteps-1) # why needs 'float'?
obj.TreadDepth = treadDepth
vLength = DraftVecUtils.scaleTo(v,treadDepth)
@@ -1363,7 +1402,7 @@ class _Stairs(ArchComponent.Component):
if obj.LastSegment.Proxy.OutlineRailArcLeftAll: # need if?
outlineRailArcLeftAll.extend(obj.LastSegment.Proxy.OutlineRailArcLeftAll)
if (outlineLeftAll[-1] - obj.OutlineLeft[0]).Length < 0.01: # To avoid 2 points overlapping fail creating LineSegment # TODO to allow tolerance Part.LineSegment / edge.toShape() allow?
if (outlineLeftAll[-1] - obj.OutlineLeft[0]).Length < 0.01: # To avoid 2 points overlapping fail creating LineSegment # TODO to allow tolerence Part.LineSegment / edge.toShape() allow?
# no need abs() after .Length right?
del outlineLeftAll[-1]
del outlineRailArcLeftAll[-1]