The broader problem is that I’m trying to test for symmetry of a multi-body part; the post essentially boils down to the following question: how can I determine when two bodies are coincident?

I’m attempting to use GetCoincidenceTransform2 in order to classify a (potentially multi-Body) .SLDPRT file as symmetric or non-symmetric. My approach is to mirror each Body about a common plane and then check if there is a single rigid transform that will bring each of the mirrored bodies in alignment with the original set. Such a transform will exist if the multi-body part is symmetric and will not exist if it is not symmetric.

For a single-body part, I can confirm symmetry by simply testing if body.GetCoincidenceTransform2(mirroredbody) returns an answer. For a multi-body part, it’s a little more complicated. I have to loop over every unique combination of body and mirroredbody, test if there is a rigid transform between them, then test if that transform can be applied to all mirroredbodies to bring them into alignment with the original bodies. There are a few issues that I haven’t figured out how to resolve which are consequences of my reliance on GetCoincidenceTransform2.

GetCoincidenceTransform2 is not guaranteed to return a transform even if the two bodies are symmetric. When I perform this test on parts using several different mirror planes i.e. {1,0,0}, (1/sqrt(2))){1,1,0}, (1/sqrt(3)){1,1,1}, the resulting body may fail to return a transform from GetCoincidenceTransform on the (1/sqrt(3)){1,1,1} reflection even though it had a result for the one about {1,0,0}. I saw that there is an SPR (#981632) for this method that includes specifying a tolerance, I wonder if this was motivated by a similar issue. The effect of this inconsistency is that I have to test several reflection planes and just sort of hope that a body that fails on several reflection planes is indeed non-symmetric. There will be some rare symmetric parts that my function fails to recognize as symmetric.

GetCoincidenceTransform2 will not necessarily return an Identity transform even if the two bodies are aligned. For instance, if bodyA and bodyB are visually aligned (I can see them z-fighting in the model view), bodyA.GetCoincidenceTransform2(bodyB, transform) could return some transform that rotates bodyB about the x axis, and then translates along Y and Z back into alignment with bodyA. It’s a valid transform but I think the implication of this is that I can’t rely on GetCoincidenceTransform2 to confirm for me that two bodies are aligned (and I’m struggling to come up with an alternative).

Issue 1 I can live with. I don’t like writing functions that fail to do what they describe but I think the edge cases are so extreme that it’s unlikely to be encountered where I intend to apply this method.

Issue 2 isn’t a flaw with the GetCoincidenceTransform2 but it completely screws my approach for confirming symmetry in multi-body parts. I can salvage it but I need an alternative method of comparing two Body2 instances to indicate when they are aligned with one another. If anyone has a suggestion for identifying alignment of two Body2 objects, I would appreciate it.

When I’m testing for symmetry in a multi-body part, the bodies in red are the temporary bodies that have been reflected about the right plane. I call GetCoincidenceTransform between each of them and each of the original bodies. I take each of those transforms and apply them to all of the mirrored bodies to see if any of them will line up with the original set of bodies. I color those bodies dark red and you can see that they do line up visually.

When I call GetCoincidenceTransform between two bodies that align visually (one of the dark red tubes and a tan tube that coincides), I will not necessarily get the Identity transform i.e. [1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,0,1]. I get a valid transform that will move the body back to its original position (rotate 180 degrees about Y, translate 1.2 along x, translate -1.76 along Z). I can’t differentiate between transforms that map a body back to itself, effectively just rotating it in place, and transforms that are between two bodies that are not already coincident. Therefore, I don’t think I can use this method to test for alignment between bodies and now I’m out of ideas.

No, I’m trying to test for symmetry of a .SLDPRT file. Those screenshots of the weldment frame are just illustrating the process; I perform a reflection (resulting in the set of bodies in bright red) and then check to see if a (non-reflection) transform can move the reflected bodies to be coincident with the original bodies.

My plan is to loop over every pair of mirrored and non-mirrored bodies, compute the transform, see if that transform causes all of the mirrored bodies to be coincident with the non-mirrored bodies. If the transform makes them line up, the part is symmetric, if it doesn’t, I have to keep trying until I exhaust every unique combination of mirrored and non-mirrored bodies in the multi-body part, then I can claim that the part is non-symmetric.

Creating mirrored copies, then comparing body geometry would also be my approach. So I have nothing to add, unfortunately. No idea how solidworks groups identical bodies.

I would go for the power of cutlist bodies: the same bodies get in the same cutlist folder. The “real” mirrors are not

I don’t understand why you want to know if they are symmetrical. Is it not enough to know if they are the same for manufacturing? Can you elaborate on that part?

I don’t understand why you want to know if they are symmetrical. Is it not enough to know if they are the same for manufacturing? Can you elaborate on that part?

My goal is to determine whether or not the entire part is symmetric. Being able to classify parts in this way will enable me to automate our assembly mirroring process, part of which involves manually selecting manufactured parts that are non-symmetric and mirroring them. We have encountered situations where non-symmetric part were misidentified by the user and ended up making duplicates rather than mirrors - resulting in scrap parts and/or expedited rework.

thanks for the larger context. Here are some thoughts besides the approaches mentioned before.

if the mirror plane is parallel to 1 of the standard work planes
One of the approaches you can use is get the point of gravity , move the part to the origin. Get the tessellation points and compare them (+ versus -) fi. 0,0,100 would correspond with 0,0,-100 as being the mirrored point. Do this for the 3 standard work planes.

if the mirror plane is NOT parallel to 1 of the standard work planes
You could get the distances from the point of gravity, order them and play with that.

The basis idea is that the mirror plane should go trough the point of gravity in homogenous components.

If you have SolidWorks pro, you can use the SolidWorks utilities API to compare geometry.