Core: Datums: Fix axis placement and add migration script.

This commit is contained in:
PaddleStroke
2024-11-26 09:27:40 +01:00
parent d835cde3a5
commit 655ae579ed
6 changed files with 81 additions and 14 deletions

View File

@@ -1018,7 +1018,7 @@ static TopoShape _getTopoShape(const App::DocumentObject* obj,
if (linked->isDerivedFrom(App::Line::getClassTypeId())) {
static TopoDS_Shape _shape;
if (_shape.IsNull()) {
BRepBuilderAPI_MakeEdge builder(gp_Lin(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
BRepBuilderAPI_MakeEdge builder(gp_Lin(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)));
_shape = builder.Shape();
_shape.Infinite(Standard_True);
}

View File

@@ -1357,9 +1357,10 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st
}
if (pcReferenceAxis->isDerivedFrom<App::Line>()) {
const App::Line* line = static_cast<const App::Line*>(pcReferenceAxis);
base = Base::Vector3d(0, 0, 0);
line->Placement.getValue().multVec(Base::Vector3d(1, 0, 0), dir);
auto* line = static_cast<const App::Line*>(pcReferenceAxis);
Base::Placement plc = line->Placement.getValue();
base = plc.getPosition();
plc.getRotation().multVec(Base::Vector3d(0, 0, 1), dir);
verifyAxisFunc(checkAxis, sketchplane, gp_Dir(dir.x, dir.y, dir.z));
return;

View File

@@ -338,17 +338,17 @@ class DocumentBasicCases(unittest.TestCase):
res = obj.getSubObject("X_Axis", retType=2)
self.assertEqual(
res[1].multVec(FreeCAD.Vector(1, 0, 0)).getAngle(FreeCAD.Vector(1, 0, 0)), 0.0
res[1].multVec(FreeCAD.Vector(0, 0, 1)).getAngle(FreeCAD.Vector(1, 0, 0)), 0.0
)
res = obj.getSubObject("Y_Axis", retType=2)
self.assertEqual(
res[1].multVec(FreeCAD.Vector(1, 0, 0)).getAngle(FreeCAD.Vector(0, 1, 0)), 0.0
res[1].multVec(FreeCAD.Vector(0, 0, 1)).getAngle(FreeCAD.Vector(0, 1, 0)), 0.0
)
res = obj.getSubObject("Z_Axis", retType=2)
self.assertEqual(
res[1].multVec(FreeCAD.Vector(1, 0, 0)).getAngle(FreeCAD.Vector(0, 0, 1)), 0.0
res[1].multVec(FreeCAD.Vector(0, 0, 1)).getAngle(FreeCAD.Vector(0, 0, 1)), 0.0
)
res = obj.getSubObject("XY_Plane", retType=2)