Seems like an OCE problem. Dave suggested rewriting loct() function with GeomAPI_ProjectPointOnCurve, instead of ShapeAnalysis_Curve.