make mate with reference planes robust against component replacement

Use this space to ask how to do whatever you're trying to use SolidWorks to do.
Kjara
Posts: 21
Joined: Mon Jul 19, 2021 2:49 am
Answers: 0
x 1

make mate with reference planes robust against component replacement

Unread post by Kjara »

I will first explain my problem on a concrete example and later explain what I need to achieve in a real-life context.

I have an assembly mateAssembly. It contains a suppressed component planeId27:
grafik.png
That component/file has a plane with id=27 and name Plane1:
grafik.png
grafik.png (14.73 KiB) Viewed 867 times
There is a mate (coincident mate) between the front plane of mateAssembly and planeId27's Plane1 (which can only be seen in GUI if the component is resolved - which I did for the following image):
grafik.png
I also have a file planeId29 which has a plane with id=29 and name Plane1:
grafik.png
grafik.png (14.76 KiB) Viewed 867 times
If I replace the suppressed component (currently planeId27) in mateAssembly with planeId29, and afterwards resolve the component, the mate becomes erroneous:
grafik.png
What can I do to make that mate robust against file replacements?

Here is what I found out so far:
- If the ids of the planes (as in API method IFeature.GetID()) in both replacement files are equal: The mate stays intact after replacement and resolve. Even if the names of both planes are different.
- If the ids of the planes (as in API method IFeature.GetID()) in both replacement files are not equal but their names are equal: If we first resolve the component and then replace, the mate stays intact.
- If the ids of the planes (as in API method IFeature.GetID()) in both replacement files are not equal and their names are not equal: After replacement/resolve (no matter in which order) the mate becomes erroneous.

Consequences:
- Swx seems to store only the id (as in API method IFeature.GetID()) of the plane in the mate. That is why, if the ids are equal, file replacement works with no problems, even if the component is suppressed and is only resolved after the replacement.
- Swx seems to use the name of the plane as fallback (if ids don't match) to update the mate after replacement to keep it intact. That is why it works if we resolve the component prior to replacing: For a resolved component, Swx can retrieve the name of a feature given by id. For a suppressed component (i.e. a not-loaded file) it cannot do this. That is why the mate becomes erroneous if we replace first and then resolve.

Use case / real-life context:
- We have a macro that does the following for a large number of assemblies: [1. Open assembly. That assembly may contain suppressed components. 2. Depending on certain conditions, replace one ore more of these components. 3. Save the modified assembly as a new file.] Sometime later the new assemblies will be loaded and depending on certain conditions, some components must be resolved (manually). There should be no errors in the assemblies at any time.
- The files that are replacements to each other are built at different times, possibly by different people. For example, we may start with only two such files and as product development goes on, new replacement variants will be created. Planes (and any other entities used in mates) that are to be considered "the same" regarding file replacement may be marked as such in any way Swx allows. For example, we have worked with equal names for planes and faces (for planes: just set the name in feature tree, for faces: set it in face properties) so far. We don't know if other ways exist.
- Resolving the to-be-replaced component prior to replacing (in the macro) is not an option. This is too a big hit on performance.

Final thoughts:
- Probably the best way to keep mates robust is to have a template model (sldprt/sldasm) with a number of predefined to-be-mated objects (like planes), and to create all replacement candidates from that template. This way, the to-be-mated objects will have matching ids. But this obviously is not a solution for already existing models (where ids don't match), and recreating them from a template is the last thing we want to do. Also, what if the template turns out to be too small during product development (e.g. we add more mates as the assembly and the variants evolve)? This is not a scalable solution.
- Is there a way to modify the id of an already existing feature/plane? Or to specify the id when creating a new feature/plane? If yes, it would solve the issue.
- Is there any extra data (besides name) that Swx uses as fallback in mate updating if ids don't match? Which one? Will it work better than name (i.e. also if the component is suppressed)?
Attachments
mateAssembly.zip
contains the three files mentioned in the topic description
(126.41 KiB) Downloaded 31 times
Post Reply