MoveLineTangencyCloserToCoord

From scripting
Jump to: navigation, search
Sub MoveLineTangencyCloserToCoord(CurvePar As HybridShapeLineTangency, XVal As Double, YVal As Double, ZVal As Double)
Dim CurOri
Dim OppOri
CurOri = CurvePar.Orientation
If CurOri = False Then
    OppOri = True
Else
    OppOri = False
End If

MyPart.UpdateObject CurvePar
Dim CMeas
Set CMeas = TheSPAWorkbench.GetMeasurable(CurvePar)
Dim CCoords()
ReDim CCoords(8)
CMeas.GetPointsOnCurve CCoords 

Dim FirstDist As Double
FirstDist = find3DDistance(CCoords(3), CCoords(4), CCoords(5), XVal, YVal, ZVal) 

CurvePar.Orientation = OppOri
IsUpdatable CurvePar
Dim CMeas2
Set CMeas2 = TheSPAWorkbench.GetMeasurable(CurvePar)
Dim CCoords2()
ReDim CCoords2(8)
CMeas2.GetPointsOnCurve CCoords2

Dim SecondDist As Double
SecondDist = find3DDistance(CCoords2(3), CCoords2(4), CCoords2(5), XVal, YVal, ZVal)

If SecondDist > FirstDist Then
    CurvePar.Orientation = CurOri
    IsUpdatable CurvePar
End If 

End Sub