From 69d9a3f949c0669ef4c780c5df68e057cecfb809 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 24 Aug 2018 23:10:10 -0300 Subject: [PATCH] Arch: Use the smallest face as profile when discovering extrusions in IFC objects - thanks @geometrygym --- src/Mod/Arch/ArchCommands.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Mod/Arch/ArchCommands.py b/src/Mod/Arch/ArchCommands.py index e2a39d4c65..9072a98bc7 100644 --- a/src/Mod/Arch/ArchCommands.py +++ b/src/Mod/Arch/ArchCommands.py @@ -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