Very very thanks for you reply. I run your code, and It is really import for the order of the loft.onekk wrote: ↑Tue Aug 09, 2022 10:27 am The problem is in the order of the loft:
...
Why is not clear, as I've checked the order of edges, it is easily done with the polygon changing starting and ending point, (note that to make a polygon you must have first and end point coincident, to close it properly)
And now I think I have known the why while I read source code of FreeCAD toughly.
The source code of FreeCAD https://github.com/FreeCAD/FreeCAD, and in https://github.com/FreeCAD/FreeCAD/blob ... reLoft.cpp line 192:
Code: Select all
BRepOffsetAPI_ThruSections mkTS(false, Ruled.getValue(), Precision::Confusion());
And I read the document of BRepOffsetAPI_ThruSections https://dev.opencascade.org/doc/occt-7. ... tions.html, I find the function CheckCompatibility.
This is the key why the AdditiveLoft is distorted!!! Because FreeCAD using CheckCompatibility(true) as default, so the OpenCASCADE will
.Sets/unsets the option to compute origin and orientation on wires to avoid twisted results and update wires to have same number of edges.
If I CheckCompatibility(false), all AdditiveLoft is well and not distorted!, My code is below using PythonOCC(one python wrap of OpenCASCADE):
Code: Select all
import Part
from OCC.Core import BRepOffsetAPI
from OCC.Core import TopoDS
def makeAdditiveLoft(sketches, solid, ruled, compatible):
mkTS = BRepOffsetAPI.BRepOffsetAPI_ThruSections(solid, ruled)
mkTS.CheckCompatibility(compatible)
for sketch in sketches:
for wire in sketch.Shape.Wires:
occ_shape = Part.__toPythonOCC__(wire)
occ_wire = TopoDS.topods_Wire(occ_shape)
mkTS.AddWire(occ_wire)
mkTS.Build()
occ_shape = mkTS.Shape()
shape = Part.__fromPythonOCC__(occ_shape)
return shape
sk0 = FreeCAD.getDocument("additiveloft_distorted").getObject("Sketch")
sk1 = FreeCAD.getDocument("additiveloft_distorted").getObject("Sketch001")
sk2 = FreeCAD.getDocument("additiveloft_distorted").getObject("Sketch002")
Part.show(makeAdditiveLoft([sk0, sk1, sk2], True, True, True), "sk123_compatible")
Part.show(makeAdditiveLoft([sk0, sk1, sk2], True, True, False), "sk123_notcompatible")
Part.show(makeAdditiveLoft([sk2, sk1, sk0], True, True, True), "sk321_compatible")
Part.show(makeAdditiveLoft([sk2, sk1, sk0], True, True, False), "sk321_notcompatible")