MoveOffsetCloserToCoord

From scripting
Jump to: navigation, search
Sub MoveOffsetCloserToCoord(CurvePar As HybridShapeOffset, XVal As Double, YVal As Double, ZVal As Double)
MyPart.UpdateObject CurvePar
Dim CMeas
Set CMeas = TheSPAWorkbench.GetMeasurable(CurvePar)
Dim CCoords()
ReDim CCoords(2)
CMeas.GetCOG CCoords                               

Dim FirstDist As Double
FirstDist = find3DDistance(CCoords(0), CCoords(1), CCoords(2), XVal, YVal, ZVal)

CurvePar.OffsetDirection = False
MyPart.UpdateObject CurvePar
Dim CMeas2
Set CMeas2 = TheSPAWorkbench.GetMeasurable(CurvePar)
Dim CCoords2()
ReDim CCoords2(2)
CMeas2.GetCOG CCoords2                                

Dim SecondDist As Double
SecondDist = find3DDistance(CCoords2(0), CCoords2(1), CCoords2(2), XVal, YVal, ZVal)

If SecondDist > FirstDist Then
    CurvePar.OffsetDirection = True
    MyPart.UpdateObject CurvePar
End If

End Sub