I was curious about this, too, and contacted SolidWorks.
This method does not work right now. There is an SPR out for it: SPR 664841.
In the mean time you have to do the following to use the following alternative method to get the faces used by mates:
1.Traverse the feature tree and gets the mates
2. From mates gets the MateEntity.
3. From MateEntity get the references , and set these reference to the Entity object.
4. And Set this Entity object to the Face2 object .
Attached is a macro and sample file that SolidWorks Corp supplied me with that accomplishes these steps.
GetFacesUsedByMates.zip 82.1 KB
Thank you for sharing the code.
First of all, I tried it and got the names of the components in each of the mates. For instance, Concentric1 between Part 1 and Part 2. However, the code above doesn't output the features in the mate (e.g. Face1_part1 and Face2_part2). One can see these features by right clicking on individual mates.
Secondly, in my assembly, the final mate is between Top Plane of the assembly and Top Plane of part2. The code outputs me the name of assembly and the name part2 by using swMate.MateEntity(0).ReferenceComponent.Name2 and swMate.MateEntity(1).ReferenceComponent.Name2, respectively. However, it gives the InvalidCastExpection error at swFace = swEntity line. Any idea what's happening there? Is it because the mate is between planes and not faces?
Any help would be much appreciated. I'd like to take the opportunity to thank you for giving me your valuable time.
I also met this problem，I can't find any way to solve this problem. I want your help to solve this problem.
Any help would be much appreciated,
In advance thank you very much!