[ArchWall] getExtrusionData() fix normal problem by adding get_shape_normal() (#12603)

* [ArchWall] getExtrusionData() fix normal problem by adding get_shape_normal()

In geometry.py
- added get_shape_normal()
- fixed is_straight_line()
DraftGeomUtils.py
- added get_shape_normal()

FC Discussion - https://forum.freecad.org/viewtopic.php?p=726101#p726101

* [ArchWall] getExtrusionData() fix normal problem

Follow-up following discussion at https://github.com/FreeCAD/FreeCAD/pull/12603

- delete trailing whitespaces
- put Part.makePolygon() in try statement
- study and findings at https://github.com/FreeCAD/FreeCAD/pull/12603#issuecomment-1969277743

In geometry.py
- added get_shape_normal()
- fixed is_straight_line()
DraftGeomUtils.py
- added get_shape_normal()

FC Discussion - https://forum.freecad.org/viewtopic.php?p=726101#p726101

* Update geometry.py

* Update geometry.py

* Update geometry.py

---------

Co-authored-by: Yorik van Havre <yorik@uncreated.net>
This commit is contained in:
paul
2024-04-02 17:54:27 +08:00
committed by GitHub
parent 581dee4d48
commit d3d18ac7e0
3 changed files with 87 additions and 1 deletions

View File

@@ -1210,7 +1210,10 @@ class _Wall(ArchComponent.Component):
if not height:
return None
if obj.Normal == Vector(0,0,0):
normal = Vector(0,0,1)
import DraftGeomUtils
normal = DraftGeomUtils.get_shape_normal(obj.Base.Shape)
if normal == None:
normal = Vector(0,0,1)
else:
normal = Vector(obj.Normal)
base = None
@@ -1275,8 +1278,10 @@ class _Wall(ArchComponent.Component):
# If the object is a single edge, use that as the
# basewires.
# TODO 2023.11.26: Need to check if it isn't Sketch after all first
# or use algorithm for Sketch altogether?
elif len(obj.Base.Shape.Edges) == 1:
self.basewires = [Part.Wire(obj.Base.Shape.Edges)]