GetCOGFromArray

From scripting
Jump to: navigation, search
Function GetCOGFromArray(ObjArr As Variant) As Variant
Dim TotArr(2)
Dim TotCounter As Integer
TotCounter = 0
For X = 0 To UBound(ObjArr)
    If IsEmpty(ObjArr(X)) = False Then
        Dim CurObj
        Set CurObj = ObjArr(X)
        Dim COMeas
        Set COMeas = TheSPAWorkbench.GetMeasurable(CurObj)
        Dim COGCoords(2)
        COMeas.GetCOG COGCoords
         
        TotCounter = TotCounter + 1
        TotArr(0) = TotArr(0) + COGCoords(0)
        TotArr(1) = TotArr(1) + COGCoords(1)
        TotArr(2) = TotArr(2) + COGCoords(2)
    End If
Next X
TotArr(0) = TotArr(0) / TotCounter
TotArr(1) = TotArr(1) / TotCounter
TotArr(2) = TotArr(2) / TotCounter
GetCOGFromArray = TotArr
End Function