Arch: Use the smallest face as profile when discovering extrusions in IFC objects - thanks @geometrygym

This commit is contained in:
Yorik van Havre
2018-08-24 23:10:10 -03:00
parent f0d6a43d3d
commit 69d9a3f949

View File

@@ -1253,13 +1253,14 @@ def getExtrusionData(shape):
if round(f[1].getAngle(faces[pair[0]][1]),4) != 1.5708:
ok = False
if ok:
valids.append([faces[pair[0]][0],faces[pair[1]][0].CenterOfMass.sub(faces[pair[0]][0].CenterOfMass)])
for v in valids:
# prefer vertical extrusions
if v[1].getAngle(FreeCAD.Vector(0,0,1)) < 0.0001:
return v
# otherwise return the first found
# prefer the face with the lowest z
if faces[pair[0]][0].CenterOfMass.z < faces[pair[1]][0].CenterOfMass.z:
valids.append([faces[pair[0]][0],faces[pair[1]][0].CenterOfMass.sub(faces[pair[0]][0].CenterOfMass)])
else:
valids.append([faces[pair[1]][0],faces[pair[0]][0].CenterOfMass.sub(faces[pair[1]][0].CenterOfMass)])
if valids:
# sort by smallest area
valids.sort(key=lambda v: v[0].Area)
return valids[0]
return None