I wanted to see what the API was like so I "one-upped" the "lock all external relations" API example. I had fun being able to use .NET (running a progress status window on a separate thread). I have a model that has become unmanageably slow (presumably a few careless circular references, I guess) and so I have to at least lock all the relations or it will drive me nuts.
I can already imagine what doing a complicated API project can be like.... From a Component, you can do GetModelDoc2, from which you can call LockAllExternalReferences. But BreakAllExternalFileReferences2 is a member of ModelDocExtension, which you get an instance of by calling ModelDoc2.Extension. Me and my nasty habit of "learning class members by Intellisense" took quite a while to find that one. If the SolidWorks core code has as inconsistent naming and confusing class structure I can't imagine why they would have any bugs in it.
Anyway, I still have high hopes for future API adventures.
I don't know how to distribute this macro. I don't know if people will need the other ones that get copied to the "bin" folder, so I hope someone tries this and lets me know. LockOrBreak.dll is my macro; the rest are prerequisites. Then I'll post the source as well if people are interested.
I developed this with VS2005, Windows 7 x64, and SW2010 SP3.1. Before you try this macro, please agree to the following:
1. I am providing this as-is and cannot guarantee it won't ruin your day. However, I did write it because I needed the functionality, and have used it myself.
2. Make a backup copy of anything important you try this on.
3. If it doesn't work for you, I will do what I can but I have limited testing ability as I only have one machine to play with this kind of stuff on.
(Thanks to Chris for the graphics.)
SolidworksApi macros