[VBA] Intersection between two lines, using ILocateCommandEvent

Greetings, and Happy New Year!

I have some trouble with the ILocateCommandEvent procedure.

What I am trying to accomplish is:

I have two parallel lines, let's call them A1 and A2. These two lines are intersected (perpendicularly) by two other lines, let's call them B1 and B2. Using ILocateCommandEvent, I first point out either A1 or A2. Secondly, I point out one of the B-lines and finally drawing a circle at the point of intersection between the two lines. Chosing A1 and B1, the circle is successfully drawn at the point of intersection

The problem occurs when I try to repeat this procedure again, now with A2 and B2. Instead of drawing a circle around the intersection between A2 and B2, the circle is drawn at the intersection between A1 and B2. It is as if the selection of A2 is not "registered", whereas the change from B1 to B2 is successful, obviously.

Let's call the ILocateCommandEvent class module "FindIntersection_LCE"

The code is (containing pseudo-code for the sake of simplicity):

Implements ILocateCommandEvents

[Declaring necessary variables]

Private Sub ILocateCommandEvents_Accept(ByVal Element As Element, Point As Point3d, ByVal View As View)

If [Element is an A-line] then

Set firstElement = Element
Dim oLocator As New FindIntersection_LCE
CommandState.StartLocate oLocator

Else if [Element is a B-line] then

Set secondElement = Element
DrawCircleAtIntersection(firstElement,secondElement)

End If

End Sub

 

Private Sub ILocateCommandEvents_Cleanup()

End Sub

 

Private Sub ILocateCommandEvents_Dynamics(Point As Point3d, ByVal View As View, ByVal DrawMode As MsdDrawingMode)

End Sub

 

Private Sub ILocateCommandEvents_LocateFailed()

End Sub

 

Private Sub ILocateCommandEvents_LocateFilter(ByVal Element As Element, Point As Point3d, Accepted As Boolean)

End Sub

 

Private Sub ILocateCommandEvents_LocateReset()

CommandState.StartDefaultCommand

End Sub

 

Private Sub ILocateCommandEvents_Start()

End Sub

 


So, the idea is to initiate the class element by pushing a tool button X. Then, first select the line A1. Then, the class module calls itself, allowing us to select another element, the line B1. When B1 is selected, the intersection is found and marked with a circle. The class module then terminates.

I now want to find the intersection between A2 and B2, so the class module is now initiated again by pushing the tool button X. And this is were problem occurs, as described above. When selecting A2 followed by B2, the circle is drawn at intersection between A1 and B2.

Do you have any idea why this is happening?

Parents Reply Children
No Data