How to properly implement collision detection.

Hello,

I am attempting to build a macro which will move a component and stop upon a collision.

I have successfuly implemented the selection, translation, rotation, and tracking of the component I wish to move.

What I am having difficulty with is the Collision detection.

I have searched the forums high and low for a method to accurately perform what it is I require. The many reponses to similar questions point out the DragAsUI Method or the Drag Method (both part of the IDragOperator), however the example "Rotate Assembly Component on Axis (VBA)" does not indicate the proper use of collision detection (or if it does, I do not understand it).

My understanding is that I need to utilize the CollisionDetection Method and send an array of components.

What I've done is the following:

'Select multiple parts individually

boolstatus = swModelExt.SelectByID2("Component to move", "Component", 0,  0, 0, False, 0, Nothing, 0)

boolstatus = swModelExt.SelectByID2("Component to watch for collision", "Component", 0,  0, 0, True, 1, Nothing, 0)

'go through some code to setup the drag operator on the "Component to Move"

'setup collision detection

bRet = swDragOp.CollisionDetection("component to watch for collision", False, True)

swDragOp.CollisionDetectionEnabled = True

'Move component

bRet = swDragOp.Drag(Apply Transform)

'Inform user

If bRet = False then

     MsgBox "Failed to move compoent"

End If

I am using Solid Works 2010 SP2.1, and the macro is in VBA. Can I get some assistance in getting collision detection to work? I don't quite understand or know how to properly implement it. If I need to supply additional information, please let me know.

SolidworksApi macros