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:
- 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.)
- 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.
Thank you for your help. I am pretty new to Solidworks API.
Now I would like to move a component along +x,-x,+y,-y,+z and -z direction for 1 meters.
I think i need to use math transformation by creating a transformation matrix. below is the code I wrote for transformation in +x direction for 1 meter.
I was wondering if this code will work?
I learned from somewhere that the rotation submatrix is diagonal with diagonal entries to be 1 for pure translation. And the translation vector denotes the direction of translation.
MathTransform swXform = default(MathTransform);
MathUtility swMathUtil = default(MathUtility);
double arr=new double ;
arr=1; arr=0; arr=0;
arr=0; arr=1; arr=0;
arr=0; arr=0; arr=1;
arr=1; arr=0; arr=0;
swXform = swMathUtil.CreateTransform(arr);
Or if there is any other way to accomplish the event
Since this is a different question from your original one, I'd suggest that you ask it in a new thread. I'd be happy to help you there. If your original question was answered, please mark it as answered.
thank you for your help.
i have posted my new question. Hope you can help me with it.