ReturnAllObjectsWithinDist

From scripting
Revision as of 19:53, 24 April 2017 by Nickpisca (talk | contribs) (Created page with " Function ReturnAllObjectsWithinDist(CurObj As Variant, ObjSet As HybridBody, WithinDist As Double) As Variant Dim tempArr() ReDim tempArr(0) If IsUpdatable(CurObj) = F...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function ReturnAllObjectsWithinDist(CurObj As Variant, ObjSet As HybridBody, WithinDist As Double) As Variant
Dim tempArr()
ReDim tempArr(0)
If IsUpdatable(CurObj) = False Then
    Exit Function
End If 

Dim JMeas
Set JMeas = TheSPAWorkbench.GetMeasurable(CurObj)
Dim JDist As Double
For X = 1 To ObjSet.HybridShapes.Count
    Dim Obj1 As HybridShape
    Set Obj1 = ObjSet.HybridShapes.Item(X)
    
    If IsUpdatable(Obj1) = True Then
        JDist = JMeas.GetMinimumDistance(Obj1)
        
        If JDist < WithinDist Then
            Set tempArr(UBound(tempArr)) = Obj1
            ReDim Preserve tempArr(UBound(tempArr) + 1)
        End If
    End If
Next X

If UBound(tempArr) <> 0 Then
    ReDim Preserve tempArr(UBound(tempArr) - 1)
End If
ReturnAllObjectsWithinDist = tempArr
End Function