Document User Text pollution

In Rhino 6 we are suffering from Document User Text spreading all over our drawings.

This problem occurs, when…

… pasting Objects from a file containing document user text
… making a Worksessions inlcuding a file with document user text
… inserting a block that includes document user text

This totally messes up our document user text structure and thus it’s information.

Hi Matthias - this is being worked on in V7 at the moment.

https://mcneel.myjetbrains.com/youtrack/issue/RH-48141

-Pascal

Hello,
Any news how to fix this problem with Rhino 6?
Cheers, Jaro

Hi Jaro -

That problem was fixed in Rhino 7. In Rhino 6, you’ll have to delete the extra key-value pairs that are the result of pasting. You could export the document text before pasting, then paste, and then delete and reimport the data if manually finding and deleting those is very impractical.
-wim

Thank you, Wim.
This is the way I usually do - I export user texts to a CSV file.
Is there any way for automatic deletting user text entries, with a script? Is there any methods for such operations?
Cheers, Jaro

Well, I may have found the solution.

keys = rs.GetDocumentUserText()
for key in keys:
    key_new = rs.SetDocumentUserText(key, "")

Seems to clear all document user texts.
Cheers, Jaro