2 Replies Latest reply on Aug 26, 2014 8:33 PM by Yuan M

    Implementing Collision Detection

    Yuan M

      Hi all,


      I've been attempting to implement the collision detection feature for IDragOperator with no success. The closest form of help I've found was here https://forum.solidworks.com/message/146064?sr=search&searchId=87f3c218-beb1-42ea-91c5-7be30606b7cc&searchIndex=2#146064 but I am unsure how to select what the author marked as "Component to watch for collision".


      Similar to the previous author, I have implemented DragAsUi() successfully with CollisionDetection turned off. The current workflow goes like this:

      1. IDragOperator set up with DynamicClearance = false, CollisionDetectionEnabled = false, TransformType = 2, DragMode = 2, UseAbsoluteTransform = true;
      2. User select a part (component) in assembly.
      3. SelectionManager grabs that component and adds it to IDragOperator's components.
      4. DragAsUi(transformation)


      I have then tried to enable collision detection by setting CollisionDetectionEnabled = true; but as soon as the move started the part disappeared off the screen. I then attempted to set up CollisionDetection(Entity_Array, false, true), with Entity_Array the same component as the one in IDragOperator, the same occurred. From what I understood the Entity_Array is supposed to be the 'other' components which can collide with the one being dragged, so I tried IModelDocExtension.SelectAll() (which also included the part being dragged), this froze SolidWorks as the drag started. I suspect the use of SelectionFilter would be appropriate, but not sure how.


      Along with how to implement collision detection so that the drag stops at point of collision, I would also like to ask a few things:

      Could things be failing due to UseAbsoluteTransform = true?

      What does the different DragModes (min, max, relaxation, no propagation) represent?


      ps: It'd also be desirable to enable dynamic clearance later, but that'll be another topic.


      Many thanks.