intersection point vbempty argument

intersection point vbempty argument

MakCADD
Advocate Advocate
1,250 Views
2 Replies
Message 1 of 3

intersection point vbempty argument

MakCADD
Advocate
Advocate

I amd trying to find the intersection points of objects in selection set.   If the intersection point is nothing I need to perform a task if not do some thing else.  here I am getting the first first task done for both result

 

here is the code

 

 

For b = 0 To BarrSet.Count - 1

For C = 0 To ContSet.Count - 1
Set Cline = ContSet.Item(C)

Set BLine = BarrSet.Item(b).Copy


IntPt = BLine.IntersectWith(Cline, acExtendNone)

If VarType(IntPt) <> vbEmpty Then
ThisDrawing.ModelSpace.AddCircle Cline.EndPoint, 1
End If

If VarType(IntPt) = vbEmpty Then
MsgBox "ASDFASDF"
End If


BLine.Delete

Next
Next

 

 

0 Likes
1,251 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

you have to check If the returned variant is an empty array of Double (just check Ubound(returnedVariant) against -1) instead of a VbEmpty Variant

 

moreover I'd propose some little refactoring of your code:

- no need for copying BLine (and deleting it at the end)

- then set BLine outsied the ContSet loop

 

Option Explicit
Sub main()
    Dim b As Long, c As Long
    Dim IntPt As Variant
    Dim BLine As AcadEntity, CLine As AcadEntity
    Dim BarrSet As AcadSelectionSet, ContSet As AcadSelectionSet
    
    For b = 0 To BarrSet.Count - 1
        Set BLine = BarrSet.Item(b)
        For c = 0 To ContSet.Count - 1
            Set CLine = ContSet.Item(c)
            
            IntPt = BLine.IntersectWith(CLine, acExtendNone)
            If UBound(IntPt) <> -1 Then
                ThisDrawing.ModelSpace.AddCircle CLine.EndPoint, 1
            Else
                MsgBox "ASDFASDF"
            End If
        Next
    Next
End Sub

 

Message 3 of 3

MakCADD
Advocate
Advocate

from 

ubound(IntPt)

you can verify the number of intersection points

0 Likes