4 Replies Latest reply on Jan 11, 2015 2:40 PM by Fivezdw Fivezdw

    Can I do collision detection for two parts in an assembly using presentation transformations ?

    Fivezdw Fivezdw

      I learned that presentation transformation will not change anything. I want to move a part in an assembly model along x axis and check whether there is collision on the path of movement. 

      Because I don't want the mates and any constraints to disappear after moving a part, I figured that presentation transformation will work for me. my concern is can I still do collision detection if i don't want to make any changes to mate features. And if anybody can show me some code of presentation transformation and collision detection, i would really appreciate the help.

        • Re: Can I do collision detection for two parts in an assembly using presentation transformations ?
          Keith Rice

          Hi,

           

          I have not tried it, but I don't think IDragOperator::CollisionDetection will work on presentation transforms. To use IDragOperator::CollisionDetection, you need to pass in the array of components to run the collision test on, but these components will be in their original positions, not in the presentation transformation position. Presentation transforms do not actually transform the original components, as stated in the API Help remarks for IComponent2::PresentationTransform.

           

          Perhaps I could be proven wrong, but setting up a test to do so would be rather time consuming.

           

          If I were in your shoes, what I would do is use temporary bodies. You can apply transforms to temporary bodies and then possibly use IDragOperator::CollisionDetection, though I don't know if temporary bodies work with IDragOperator. I would guess that they do, but I don't know for certain.

           

          If IDragOperator::CollisionDection doesn't work, you have two other good options for detecting collision:

           

          1. IBody2::GetIntersectionEdges -- this will return any intersecting edges. If the returned array is empty, you know the bodies aren't intersecting. (Not sure how this would work with organic shapes that don't have edges, however.)
          2. Perhaps the most certain approach would use IBody2::Operations2. You could copy the bodies in question using IBody2::Copy and then try to add them with IBody2::Operations2. If you get a "no intersect" error from the out argument, then you know you're not colliding.

           

          There's probably some differences in performance between each of these three approaches, but I'm not going to speculate as to which would be fastest and by how much. Just be aware, if performance is a major concern. Unless you're dealing with very complex geometry, however, the performance difference should be negligible.

           

          Keith

          SolidWorks API Tutorials