Question about adding mates using a Macro

Hi Everyone,


I'm still pretty new to the API, so pardon me if this is a dumb question, but I have been working on a macro to quickly add some common mates between components in an assembly, and the assembly's top plane.  Basically placing components "on the floor" for layouts and the like. 


Each time I run the macro, it creates the mates again, redundantly......and the redundant mates do not cause any errors/warnings.  I was wondering if this is common behavior?  Is there a way to work around this?  Like a chunk of code to use that detects if a mate already exists between the two selections (I'm using SelectbyID2) and that could then tell SolidWorks to not create the mate again?

Trying to find out the best way to do this without re-inventing the wheel.

Thanks!

-Drew

SolidworksApi macros