Thursday, June 30, 2011

Hit Test Usage for Schematic

Using the ChooseLocationInteractively function to determine what is located at the cursor location when it is clicked.  The HitTest stores all of the objects located at the cursor when clicked.

Sub HitTestExample

If SchServer Is Nothing Then Exit Sub
Set CurrentSheet = SchServer.GetCurrentSchDocument
If CurrentSheet is Nothing Then Exit Sub

Set Alocation = CurrentSheet.Location
Call CurrentSheet.ChooseLocationInteractively(Alocation,"Select Label")
Set HitTest = CurrentSheet.CreateHitTest(eHitTest_AllObjects, ALocation)

If (HitTest.HitTestCount > 0) Then
   For I = 0 to (HitTest.HitTestCount-1)
      ShowMessage ("ObjectID Is " & HitTest.HitObject(I).ObjectId)

End If

End Sub