This macro broke my model

The attached is the macro  (see "import diag macro" - i copied it from the editor)

I was using on folders with lots of imported solids. Works great for correcting import errors along with the utility #task (sharp task), I can batch process a folder with loads of imported files.

I decided to create an icon on my toolbar linked to this macro in case I needed it.

Well....

I had a model open that I have been working on for 20+ hours and I accidentally clicked on the icon it ran, and completely mangled my work. (see attachment "messed up part"

Next it crashed Solidworks, But not before saving the file and creating a back up in the temp folder...

I thought that the Import Diagnostic would not run on a part with any features in the tree other the "Imported" solid.

How can I stop this macro from corrupting a model with tree features?

SolidworksApi/macros