Why are my blocks getting cleared out by my API plugin?

Hi All,

I am writing an API plugin in C# to automate drawings by placing blocks into a drawing. The file contains all the block definitions, and the program just inserts blocks based on user input. I have it set up so that the drawing updates with every change in input by the user, which means that the existing blocks have to be erased and the new blocks put back in. To do that, I wrote a function called updateDS() which erases all the block instances by iterating through a list of all the block definition names, then inserts blocks based on an array of strings that was set by other functions. Here is the code (I had to use an image because there is no "insert code" feature as far as I can tell):BwzwhvTrlT05AAAAAElFTkSuQmCC

The issue is that some of the blocks that weren't inserted into the drawing get "cleared", and then when I insert them later on, they are blank. The block definition still exists, there is just nothing in it.

Any help or ideas would be greatly appreciated!

Thanks,

Rohan